1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<?php
/**
* @author @jenschude <jens.schulze@commercetools.de>
* @created: 27.01.15, 10:51
*/
namespace Commercetools\Core\Model\Category;
use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Model\Common\JsonObject;
use Commercetools\Core\Model\Common\LocalizedString;
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
use Commercetools\Core\Model\Common\AssetDraftCollection;
/**
* @package Commercetools\Core\Model\Category
* @link https://docs.commercetools.com/http-api-projects-categories.html#categorydraft
* @method LocalizedString getName()
* @method LocalizedString getSlug()
* @method LocalizedString getDescription()
* @method CategoryReference getParent()
* @method string getOrderHint()
* @method string getExternalId()
* @method CategoryDraft setName(LocalizedString $name = null)
* @method CategoryDraft setSlug(LocalizedString $slug = null)
* @method CategoryDraft setDescription(LocalizedString $description = null)
* @method CategoryDraft setParent(CategoryReference $parent = null)
* @method CategoryDraft setOrderHint(string $orderHint = null)
* @method CategoryDraft setExternalId(string $externalId = null)
* @method CustomFieldObjectDraft getCustom()
* @method CategoryDraft setCustom(CustomFieldObjectDraft $custom = null)
* @method LocalizedString getMetaDescription()
* @method CategoryDraft setMetaDescription(LocalizedString $metaDescription = null)
* @method LocalizedString getMetaTitle()
* @method CategoryDraft setMetaTitle(LocalizedString $metaTitle = null)
* @method LocalizedString getMetaKeywords()
* @method CategoryDraft setMetaKeywords(LocalizedString $metaKeywords = null)
* @method AssetDraftCollection getAssets()
* @method CategoryDraft setAssets(AssetDraftCollection $assets = null)
* @method string getKey()
* @method CategoryDraft setKey(string $key = null)
*/
class CategoryDraft extends JsonObject
{
public function fieldDefinitions()
{
return [
'name' => [static::TYPE => LocalizedString::class],
'slug' => [static::TYPE => LocalizedString::class],
'description' => [static::TYPE => LocalizedString::class, static::OPTIONAL => true],
'parent' => [static::TYPE => CategoryReference::class, static::OPTIONAL => true],
'orderHint' => [static::TYPE => 'string', static::OPTIONAL => true],
'externalId' => [static::TYPE => 'string', static::OPTIONAL => true],
'metaDescription' => [static::TYPE => LocalizedString::class, static::OPTIONAL => true],
'metaTitle' => [static::TYPE => LocalizedString::class, static::OPTIONAL => true],
'metaKeywords' => [static::TYPE => LocalizedString::class, static::OPTIONAL => true],
'custom' => [static::TYPE => CustomFieldObjectDraft::class, static::OPTIONAL => true],
'assets' => [static::TYPE => AssetDraftCollection::class, static::OPTIONAL => true],
'key' => [static::TYPE => 'string', static::OPTIONAL => true],
];
}
/**
* @param LocalizedString $name
* @param LocalizedString $slug
* @param Context|callable $context
* @return CategoryDraft
*/
public static function ofNameAndSlug(LocalizedString $name, LocalizedString $slug, $context = null)
{
$draft = static::of($context);
return $draft->setName($name)->setSlug($slug);
}
}