This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Type): add type change key action
- Loading branch information
Jens Schulze
committed
Mar 11, 2016
1 parent
72e4bd2
commit 1c2ebf4
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* @author @jayS-de <jens.schulze@commercetools.de> | ||
*/ | ||
|
||
namespace Commercetools\Core\Request\Types\Command; | ||
|
||
use Commercetools\Core\Model\Common\Context; | ||
use Commercetools\Core\Request\AbstractAction; | ||
use Commercetools\Core\Model\Common\LocalizedString; | ||
|
||
/** | ||
* @package Commercetools\Core\Request\Types\Command | ||
* @link https://dev.commercetools.com/http-api-projects-types.html#change-key | ||
* @method string getAction() | ||
* @method TypeChangeKeyAction setAction(string $action = null) | ||
* @method string getKey() | ||
* @method TypeChangeKeyAction setKey(string $key = null) | ||
*/ | ||
class TypeChangeKeyAction extends AbstractAction | ||
{ | ||
public function fieldDefinitions() | ||
{ | ||
return [ | ||
'action' => [static::TYPE => 'string'], | ||
'key' => [static::TYPE => 'string'], | ||
]; | ||
} | ||
|
||
/** | ||
* @param array $data | ||
* @param Context|callable $context | ||
*/ | ||
public function __construct(array $data = [], $context = null) | ||
{ | ||
parent::__construct($data, $context); | ||
$this->setAction('changeKey'); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param Context|callable $context | ||
* @return TypeChangeKeyAction | ||
*/ | ||
public static function ofKey($key, $context = null) | ||
{ | ||
return static::of($context)->setKey($key); | ||
} | ||
} |