Composable Commerce PHP SDKPHP SDK
  • Namespace
  • Class
  • Tree

Namespaces

  • Commercetools
    • Commons
      • Helper
    • Core
      • Builder
        • Request
        • Update
      • Cache
      • Client
        • Adapter
        • OAuth
      • Error
      • Helper
        • Annotate
        • State
          • Renderer
        • Subscriber
          • Log
      • Model
        • ApiClient
        • Cart
        • CartDiscount
        • Category
        • Channel
        • Common
        • Customer
        • CustomerGroup
        • CustomField
        • CustomObject
        • DiscountCode
        • Extension
        • Inventory
        • Message
        • Order
        • OrderEdit
        • Payment
        • Product
          • Search
        • ProductDiscount
        • ProductSelection
        • ProductType
        • Project
        • Review
        • ShippingMethod
        • ShoppingList
        • State
        • Store
        • Subscription
        • TaxCategory
        • Type
        • Zone
      • Request
        • ApiClients
        • CartDiscounts
          • Command
        • Carts
          • Command
        • Categories
          • Command
        • Channels
          • Command
        • CustomerGroups
          • Command
        • Customers
          • Command
        • CustomField
          • Command
        • CustomObjects
        • DiscountCodes
          • Command
        • Extensions
          • Command
        • GraphQL
        • InStores
        • Inventory
          • Command
        • Me
          • Command
        • Messages
        • OrderEdits
          • Command
          • StagedOrder
            • Command
        • Orders
          • Command
        • Payments
          • Command
        • ProductDiscounts
          • Command
        • Products
          • Command
        • ProductSelections
          • Command
        • ProductTypes
          • Command
        • Project
          • Command
        • Query
        • Reviews
          • Command
        • ShippingMethods
          • Command
        • ShoppingLists
          • Command
        • States
          • Command
        • Stores
          • Command
        • Subscriptions
          • Command
        • TaxCategories
          • Command
        • Types
          • Command
        • Zones
          • Command
      • Response

Classes

  • ActionBuilder
  • CartDiscountsActionBuilder
  • CartsActionBuilder
  • CategoriesActionBuilder
  • ChannelsActionBuilder
  • CustomerGroupsActionBuilder
  • CustomersActionBuilder
  • CustomFieldActionBuilder
  • DiscountCodesActionBuilder
  • ExtensionsActionBuilder
  • InventoryActionBuilder
  • MeActionBuilder
  • OrderEditsActionBuilder
  • OrdersActionBuilder
  • PaymentsActionBuilder
  • ProductDiscountsActionBuilder
  • ProductsActionBuilder
  • ProductSelectionsActionBuilder
  • ProductTypesActionBuilder
  • ProjectActionBuilder
  • ReviewsActionBuilder
  • ShippingMethodsActionBuilder
  • ShoppingListsActionBuilder
  • StagedOrderActionBuilder
  • StatesActionBuilder
  • StoresActionBuilder
  • SubscriptionsActionBuilder
  • TaxCategoriesActionBuilder
  • TypesActionBuilder
  • ZonesActionBuilder
  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  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 
<?php

namespace Commercetools\Core\Builder\Update;

use Commercetools\Core\Error\InvalidArgumentException;
use Commercetools\Core\Request\AbstractAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeAddAttributeDefinitionAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeAddLocalizedEnumValueAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeAddPlainEnumValueAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeAttributeConstraintAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeAttributeNameAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeAttributeOrderAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeAttributeOrderByNameAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeDescriptionAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeEnumKeyAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeInputHintAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeIsSearchableAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeLabelAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeLocalizedEnumLabelAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeLocalizedEnumValueOrderAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangeNameAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangePlainEnumLabelAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeChangePlainEnumValueOrderAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeRemoveAttributeDefinitionAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeRemoveEnumValuesAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeSetInputTipAction;
use Commercetools\Core\Request\ProductTypes\Command\ProductTypeSetKeyAction;

class ProductTypesActionBuilder
{
    private $actions = [];

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#add-attributedefinition
     * @param ProductTypeAddAttributeDefinitionAction|callable $action
     * @return $this
     */
    public function addAttributeDefinition($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeAddAttributeDefinitionAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#add-localizableenumvalue-to-attributedefinition
     * @param ProductTypeAddLocalizedEnumValueAction|callable $action
     * @return $this
     */
    public function addLocalizedEnumValue($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeAddLocalizedEnumValueAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#add-plainenumvalue-to-attributedefinition
     * @param ProductTypeAddPlainEnumValueAction|callable $action
     * @return $this
     */
    public function addPlainEnumValue($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeAddPlainEnumValueAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-attributedefinition-attributeconstraint
     * @param ProductTypeChangeAttributeConstraintAction|callable $action
     * @return $this
     */
    public function changeAttributeConstraint($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeAttributeConstraintAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-attributedefinition-name
     * @param ProductTypeChangeAttributeNameAction|callable $action
     * @return $this
     */
    public function changeAttributeName($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeAttributeNameAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes#change-the-order-of-attributedefinitions
     * @param ProductTypeChangeAttributeOrderAction|callable $action
     * @return $this
     */
    public function changeAttributeOrder($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeAttributeOrderAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes#change-the-order-of-attributedefinitions
     * @param ProductTypeChangeAttributeOrderByNameAction|callable $action
     * @return $this
     */
    public function changeAttributeOrderByName($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeAttributeOrderByNameAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-description
     * @param ProductTypeChangeDescriptionAction|callable $action
     * @return $this
     */
    public function changeDescription($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeDescriptionAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-the-key-of-an-enumvalue
     * @param ProductTypeChangeEnumKeyAction|callable $action
     * @return $this
     */
    public function changeEnumKey($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeEnumKeyAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-attributedefinition-inputhint
     * @param ProductTypeChangeInputHintAction|callable $action
     * @return $this
     */
    public function changeInputHint($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeInputHintAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-attributedefinition-issearchable
     * @param ProductTypeChangeIsSearchableAction|callable $action
     * @return $this
     */
    public function changeIsSearchable($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeIsSearchableAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-attributedefinition-label
     * @param ProductTypeChangeLabelAction|callable $action
     * @return $this
     */
    public function changeLabel($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeLabelAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-the-label-of-an-localizedenumvalue
     * @param ProductTypeChangeLocalizedEnumLabelAction|callable $action
     * @return $this
     */
    public function changeLocalizedEnumValueLabel($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeLocalizedEnumLabelAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-the-order-of-localizedenumvalues
     * @param ProductTypeChangeLocalizedEnumValueOrderAction|callable $action
     * @return $this
     */
    public function changeLocalizedEnumValueOrder($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeLocalizedEnumValueOrderAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-name
     * @param ProductTypeChangeNameAction|callable $action
     * @return $this
     */
    public function changeName($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangeNameAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-the-label-of-an-enumvalue
     * @param ProductTypeChangePlainEnumLabelAction|callable $action
     * @return $this
     */
    public function changePlainEnumValueLabel($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangePlainEnumLabelAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#change-the-order-of-enumvalues
     * @param ProductTypeChangePlainEnumValueOrderAction|callable $action
     * @return $this
     */
    public function changePlainEnumValueOrder($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeChangePlainEnumValueOrderAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#remove-attributedefinition
     * @param ProductTypeRemoveAttributeDefinitionAction|callable $action
     * @return $this
     */
    public function removeAttributeDefinition($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeRemoveAttributeDefinitionAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#remove-enumvalues-from-attributedefinition
     * @param ProductTypeRemoveEnumValuesAction|callable $action
     * @return $this
     */
    public function removeEnumValues($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeRemoveEnumValuesAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#set-attributedefinition-inputtip
     * @param ProductTypeSetInputTipAction|callable $action
     * @return $this
     */
    public function setInputTip($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeSetInputTipAction::class, $action));
        return $this;
    }

    /**
     * @link https://docs.commercetools.com/http-api-projects-productTypes.html#set-key
     * @param ProductTypeSetKeyAction|callable $action
     * @return $this
     */
    public function setKey($action = null)
    {
        $this->addAction($this->resolveAction(ProductTypeSetKeyAction::class, $action));
        return $this;
    }

    /**
     * @return ProductTypesActionBuilder
     */
    public static function of()
    {
        return new self();
    }

    /**
     * @param $class
     * @param $action
     * @return AbstractAction
     * @throws InvalidArgumentException
     */
    private function resolveAction($class, $action = null)
    {
        if (is_null($action) || is_callable($action)) {
            $callback = $action;
            $emptyAction = $class::of();
            $action = $this->callback($emptyAction, $callback);
        }
        if ($action instanceof $class) {
            return $action;
        }
        throw new InvalidArgumentException(
            sprintf('Expected method to be called with or callable to return %s', $class)
        );
    }

    /**
     * @param $action
     * @param callable $callback
     * @return AbstractAction
     */
    private function callback($action, callable $callback = null)
    {
        if (!is_null($callback)) {
            $action = $callback($action);
        }
        return $action;
    }

    /**
     * @param AbstractAction $action
     * @return $this;
     */
    public function addAction(AbstractAction $action)
    {
        $this->actions[] = $action;
        return $this;
    }

    /**
     * @return array
     */
    public function getActions()
    {
        return $this->actions;
    }


    /**
     * @param array $actions
     * @return $this
     */
    public function setActions(array $actions)
    {
        $this->actions = $actions;
        return $this;
    }
}
PHP SDK API documentation generated by ApiGen