Overview
  • Package
  • Class
  • Tree
  • Todo

Packages

  • AddonValue
    • Interfaces
  • ApiV2Controllers
  • Category
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • Customer
    • Address
    • Country
    • CountryZone
    • Interfaces
    • Validation
    • ValueObjects
  • Email
    • Collections
    • Entities
    • Exceptions
    • Interfaces
    • Repository
    • ValueObjects
  • Http
    • Collections
    • Exceptions
    • Factories
    • Interfaces
    • ValueObjects
  • Loaders
    • CrossCuttingLoader
    • GXCoreLoader
    • Interfaces
  • None
  • Order
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Repositories
    • Storages
    • ValueObjects
  • Product
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • ProductModule
    • Collections
    • Deleter
    • Entities
    • Factories
    • Interface
    • Interfaces
    • Reader
    • Repositories
    • Writer
  • Shared
    • Exceptions
    • FileSystem
    • Interfaces
    • Storage
    • Types
  • Statistics
    • Interfaces
  • UserConfiguration
    • Interfaces
    • Repository

Classes

  • AbstractAddonValueServiceFactory
  • AbstractAddonValueStorage
  • AbstractApiV2Controller
  • AbstractCategoryServiceFactory
  • AbstractCollection
  • AbstractCustomerFactory
  • AbstractCustomerServiceFactory
  • AbstractFileStorage
  • AbstractHttpContextFactory
  • AbstractHttpViewControllerRegistryFactory
  • AbstractImagesApiV2Controller
  • AbstractOrderServiceFactory
  • AbstractProductAttributeServiceFactory
  • AbstractProductServiceFactory
  • AddonValueService
  • AddonValueServiceFactory
  • AddonValueStorageFactory
  • AddressBlock
  • AddressBookService
  • AddressClass
  • AddressesApiV2Controller
  • AddressFormatProvider
  • AdminHttpViewController
  • AdminPageHttpControllerResponse
  • Asset
  • AssetCollection
  • AttachmentCollection
  • AttachmentName
  • AttachmentPath
  • AttachmentsApiV2Controller
  • AttachmentsHandler
  • BoolType
  • CategoriesApiV2Controller
  • Category
  • CategoryAddonValueStorage
  • CategoryFactory
  • CategoryIconsApiV2Controller
  • CategoryImagesApiV2Controller
  • CategoryListItem
  • CategoryListItemCollection
  • CategoryListProvider
  • CategoryListProviderFactory
  • CategoryObjectService
  • CategoryReadService
  • CategoryRepository
  • CategoryRepositoryDeleter
  • CategoryRepositoryReader
  • CategoryRepositoryWriter
  • CategoryServiceFactory
  • CategorySettings
  • CategorySettingsRepository
  • CategorySettingsRepositoryReader
  • CategorySettingsRepositoryWriter
  • CategoryWriteService
  • ContactCollection
  • ContactName
  • ContactType
  • CountriesApiV2Controller
  • CountryService
  • CrossCuttingLoader
  • CurrencyCode
  • Customer
  • CustomerAccountInputValidator
  • CustomerAddress
  • CustomerAddressDeleter
  • CustomerAddressInputValidator
  • CustomerAddressReader
  • CustomerAddressRepository
  • CustomerAddressWriter
  • CustomerB2BStatus
  • CustomerCallNumber
  • CustomerCity
  • CustomerCompany
  • CustomerCountry
  • CustomerCountryIso2
  • CustomerCountryIso3
  • CustomerCountryName
  • CustomerCountryReader
  • CustomerCountryRepository
  • CustomerCountryZone
  • CustomerCountryZoneIsoCode
  • CustomerCountryZoneName
  • CustomerCountryZoneReader
  • CustomerCountryZoneRepository
  • CustomerDateOfBirth
  • CustomerDeleter
  • CustomerEmail
  • CustomerFactory
  • CustomerFirstname
  • CustomerGender
  • CustomerInputValidator
  • CustomerInputValidatorSettings
  • CustomerLastname
  • CustomerNumber
  • CustomerPassword
  • CustomerPostcode
  • CustomerReader
  • CustomerReadService
  • CustomerRegistrationInputValidatorService
  • CustomerRepository
  • CustomersApiV2Controller
  • CustomerService
  • CustomerServiceFactory
  • CustomerServiceSettings
  • CustomerStatusInformation
  • CustomerStatusProvider
  • CustomerStreet
  • CustomerSuburb
  • CustomerVatNumber
  • CustomerWriter
  • CustomerWriteService
  • DecimalType
  • DefaultApiV2Controller
  • EditableCollection
  • EditableKeyValueCollection
  • Email
  • EmailAddress
  • EmailAttachment
  • EmailCollection
  • EmailContact
  • EmailContent
  • EmailDeleter
  • EmailFactory
  • EmailReader
  • EmailRepository
  • EmailsApiV2Controller
  • EmailService
  • EmailStringType
  • EmailSubject
  • EmailWriter
  • EmptyCurrencyCode
  • EmptyDateTime
  • EmptyLanguageCode
  • EmptyOrderItemDownloadInformation
  • EmptyProductImage
  • EnvCategoryServiceSettings
  • EnvironmentHttpContextFactory
  • EnvironmentHttpViewControllerRegistryFactory
  • EnvProductImageFileStorageSettings
  • ExistingDirectory
  • ExistingFile
  • FilenameStringType
  • GXCoreLoader
  • GXCoreLoaderSettings
  • GXEngineOrder
  • GXEngineProduct
  • HttpApiV2Controller
  • HttpContext
  • HttpContextReader
  • HttpControllerResponse
  • HttpDispatcher
  • HttpResponseProcessor
  • HttpService
  • HttpServiceFactory
  • HttpViewController
  • HttpViewControllerFactory
  • HttpViewControllerRegistry
  • IdCollection
  • IdType
  • ImageFileStorage
  • IntType
  • JsonHttpControllerResponse
  • KeyValueCollection
  • LanguageCode
  • LegacyProductImageProcessing
  • MailerAdapter
  • NonEmptyStringType
  • OrderAddonValueStorage
  • OrderFactory
  • OrderItem
  • OrderItemAddonValueStorage
  • OrderItemAttribute
  • OrderItemAttributeCollection
  • OrderItemAttributeFactory
  • OrderItemAttributeRepository
  • OrderItemAttributeRepositoryDeleter
  • OrderItemAttributeRepositoryFactory
  • OrderItemAttributeRepositoryReader
  • OrderItemAttributeRepositoryWriter
  • OrderItemCollection
  • OrderItemDownloadInformation
  • OrderItemFactory
  • OrderItemProperty
  • OrderItemPropertyFactory
  • OrderItemPropertyRepository
  • OrderItemPropertyRepositoryDeleter
  • OrderItemPropertyRepositoryReader
  • OrderItemPropertyRepositoryWriter
  • OrderItemRepository
  • OrderItemRepositoryDeleter
  • OrderItemRepositoryReader
  • OrderItemRepositoryWriter
  • OrderListGenerator
  • OrderListItem
  • OrderListItemCollection
  • OrderObjectService
  • OrderPaymentType
  • OrderReadService
  • OrderRepository
  • OrderRepositoryDeleter
  • OrderRepositoryReader
  • OrderRepositoryWriter
  • OrdersApiV2Controller
  • OrderServiceFactory
  • OrderServiceSettings
  • OrderShippingType
  • OrdersHistoryApiV2Controller
  • OrdersItemsApiV2Controller
  • OrdersItemsAttributesApiV2Controller
  • OrderStatusHistoryListItem
  • OrderStatusHistoryListItemCollection
  • OrderStatusHistoryStorage
  • OrdersTotalsApiV2Controller
  • OrderTotal
  • OrderTotalCollection
  • OrderTotalFactory
  • OrderTotalRepository
  • OrderTotalRepositoryDeleter
  • OrderTotalRepositoryReader
  • OrderTotalRepositoryWriter
  • OrderWriteService
  • ProductAddonValueStorage
  • ProductAttribute
  • ProductAttributeCollection
  • ProductAttributeFactory
  • ProductAttributeObjectService
  • ProductAttributeRepository
  • ProductAttributeRepositoryDeleter
  • ProductAttributeRepositoryReader
  • ProductAttributeRepositoryWriter
  • ProductAttributeService
  • ProductAttributeServiceFactory
  • ProductCategoryLinker
  • ProductFactory
  • ProductImage
  • ProductImageCollection
  • ProductImageContainer
  • ProductImageContainerRepository
  • ProductImageFileStorage
  • ProductImagesApiV2Controller
  • ProductListItem
  • ProductListItemCollection
  • ProductListProvider
  • ProductListProviderFactory
  • ProductObjectService
  • ProductPermissionSetter
  • ProductReadService
  • ProductRepository
  • ProductRepositoryDeleter
  • ProductRepositoryReader
  • ProductRepositoryWriter
  • ProductsApiV2Controller
  • ProductServiceFactory
  • ProductSettings
  • ProductSettingsRepository
  • ProductSettingsRepositoryReader
  • ProductSettingsRepositoryWriter
  • ProductsLinksApiV2Controller
  • ProductWriteService
  • RedirectHttpControllerResponse
  • StaticCrossCuttingLoader
  • StaticGXCoreLoader
  • StatisticsService
  • StoredCategory
  • StoredOrderItem
  • StoredOrderItemAttribute
  • StoredOrderItemAttributeCollection
  • StoredOrderItemCollection
  • StoredOrderItemProperty
  • StoredOrderTotal
  • StoredOrderTotalCollection
  • StoredProduct
  • StoredProductAttribute
  • StoredProductAttributeCollection
  • StringCollection
  • StringType
  • UserConfigurationReader
  • UserConfigurationService
  • UserConfigurationWriter
  • VatNumberValidator
  • WritableDirectory
  • WritableFile
  • YetAnotherLanguageProvider
  • ZonesApiV2Controller

Interfaces

  • AddonValueContainerInterface
  • AddonValueServiceInterface
  • AddonValueStorageFactoryInterface
  • AddressBlockInterface
  • AddressBookServiceInterface
  • AddressClassInterface
  • AddressFormatProviderInterface
  • AssetCollectionInterface
  • AssetInterface
  • AttachmentCollectionInterface
  • AttachmentNameInterface
  • AttachmentPathInterface
  • AttachmentsHandlerInterface
  • CategoryFactoryInterface
  • CategoryInterface
  • CategoryListProviderFactoryInterface
  • CategoryListProviderInterface
  • CategoryObjectServiceInterface
  • CategoryReadServiceInterface
  • CategoryRepositoryDeleterInterface
  • CategoryRepositoryInterface
  • CategoryRepositoryReaderInterface
  • CategoryRepositoryWriterInterface
  • CategoryServiceSettingsInterface
  • CategorySettingsInterface
  • CategorySettingsRepositoryInterface
  • CategorySettingsRepositoryReaderInterface
  • CategorySettingsRepositoryWriterInterface
  • CategoryWriteServiceInterface
  • ContactCollectionInterface
  • ContactNameInterface
  • ContactTypeInterface
  • ContentViewInterface
  • CountryServiceInterface
  • CrossCuttingLoaderInterface
  • CrossCuttingObjectInterface
  • CustomerAccountInputValidatorInterface
  • CustomerAddressDeleterInterface
  • CustomerAddressInputValidatorInterface
  • CustomerAddressInterface
  • CustomerAddressReaderInterface
  • CustomerAddressRepositoryInterface
  • CustomerAddressWriterInterface
  • CustomerB2BStatusInterface
  • CustomerCallNumberInterface
  • CustomerCityInterface
  • CustomerCompanyInterface
  • CustomerCountryInterface
  • CustomerCountryIso2Interface
  • CustomerCountryIso3Interface
  • CustomerCountryNameInterface
  • CustomerCountryReaderInterface
  • CustomerCountryRepositoryInterface
  • CustomerCountryZoneInterface
  • CustomerCountryZoneIsoCodeInterface
  • CustomerCountryZoneNameInterface
  • CustomerCountryZoneReaderInterface
  • CustomerCountryZoneRepositoryInterface
  • CustomerDeleterInterface
  • CustomerEmailInterface
  • CustomerFirstnameInterface
  • CustomerGenderInterface
  • CustomerInputValidatorInterface
  • CustomerInputValidatorSettingsInterface
  • CustomerInterface
  • CustomerLastnameInterface
  • CustomerNumberInterface
  • CustomerPasswordInterface
  • CustomerPostcodeInterface
  • CustomerReaderInterface
  • CustomerReadServiceInterface
  • CustomerRegistrationInputValidatorServiceInterface
  • CustomerRepositoryInterface
  • CustomerServiceInterface
  • CustomerServiceSettingsInterface
  • CustomerStatusProviderInterface
  • CustomerStreetInterface
  • CustomerSuburbInterface
  • CustomerVatNumberInterface
  • CustomerWriterInterface
  • CustomerWriteServiceInterface
  • EmailAddressInterface
  • EmailAttachmentInterface
  • EmailCollectionInterface
  • EmailContactInterface
  • EmailContentInterface
  • EmailDeleterInterface
  • EmailFactoryInterface
  • EmailInterface
  • EmailReaderInterface
  • EmailRepositoryInterface
  • EmailServiceInterface
  • EmailSubjectInterface
  • EmailWriterInterface
  • GXCoreLoaderInterface
  • GXCoreLoaderSettingsInterface
  • HttpContextInterface
  • HttpContextReaderInterface
  • HttpControllerResponseInterface
  • HttpDispatcherInterface
  • HttpResponseProcessorInterface
  • HttpServiceFactoryInterface
  • HttpServiceInterface
  • HttpViewControllerFactoryInterface
  • HttpViewControllerInterface
  • HttpViewControllerRegistryInterface
  • IdInterface
  • LanguageProviderInterface
  • MailerAdapterInterface
  • OrderFactoryInterface
  • OrderInterface
  • OrderItemAttributeFactoryInterface
  • OrderItemAttributeInterface
  • OrderItemAttributeRepositoryDeleterInterface
  • OrderItemAttributeRepositoryFactoryInterface
  • OrderItemAttributeRepositoryInterface
  • OrderItemAttributeRepositoryReaderInterface
  • OrderItemAttributeRepositoryWriterInterface
  • OrderItemFactoryInterface
  • OrderItemInterface
  • OrderItemPropertyFactoryInterface
  • OrderItemPropertyRepositoryDeleterInterface
  • OrderItemPropertyRepositoryReaderInterface
  • OrderItemPropertyRepositoryWriterInterface
  • OrderItemRepositoryDeleterInterface
  • OrderItemRepositoryInterface
  • OrderItemRepositoryReaderInterface
  • OrderItemRepositoryWriterInterface
  • OrderListGeneratorInterface
  • OrderObjectServiceInterface
  • OrderPaymentTypeInterface
  • OrderReadServiceInterface
  • OrderRepositoryDeleterInterface
  • OrderRepositoryInterface
  • OrderRepositoryReaderInterface
  • OrderRepositoryWriterInterface
  • OrderServiceSettingsInterface
  • OrderShippingTypeInterface
  • OrderStatusHistoryReaderInterface
  • OrderStatusHistoryWriterInterface
  • OrderTotalFactoryInterface
  • OrderTotalInterface
  • OrderTotalRepositoryDeleterInterface
  • OrderTotalRepositoryInterface
  • OrderTotalRepositoryReaderInterface
  • OrderTotalRepositoryWriterInterface
  • OrderWriteServiceInterface
  • ProductAttributeFactoryInterface
  • ProductAttributeInterface
  • ProductAttributeObjectServiceInterface
  • ProductAttributeRepositoryDeleterInterface
  • ProductAttributeRepositoryInterface
  • ProductAttributeRepositoryReaderInterface
  • ProductAttributeRepositoryWriterInterface
  • ProductAttributeServiceInterface
  • ProductCategoryLinkerInterface
  • ProductFactoryInterface
  • ProductImageContainerInterface
  • ProductImageContainerRepositoryInterface
  • ProductImageInterface
  • ProductImagePathsSettingsInterface
  • ProductImageProcessingInterface
  • ProductInterface
  • ProductListProviderFactoryInterface
  • ProductListProviderInterface
  • ProductObjectServiceInterface
  • ProductPermissionSetterInterface
  • ProductReadServiceInterface
  • ProductRepositoryDeleterInterface
  • ProductRepositoryInterface
  • ProductRepositoryReaderInterface
  • ProductRepositoryWriterInterface
  • ProductSettingsInterface
  • ProductSettingsRepositoryInterface
  • ProductSettingsRepositoryReaderInterface
  • ProductSettingsRepositoryWriterInterface
  • ProductWriteServiceInterface
  • StatisticsServiceInterface
  • StoredCategoryInterface
  • StoredOrderItemAttributeInterface
  • StoredOrderItemInterface
  • StoredOrderTotalInterface
  • StoredProductAttributeInterface
  • StoredProductInterface
  • UserConfigurationReaderInterface
  • UserConfigurationServiceInterface
  • UserConfigurationWriterInterface
  • VatNumberValidatorInterface

Exceptions

  • AjaxException
  • AttachmentNotFoundException
  • FileNotFoundException
  • HttpApiV2Exception
  • MissingControllerNameException
  • UnknownEnvironmentException
  1 <?php
  2 
  3 /* --------------------------------------------------------------
  4    CategoryWriteService.inc.php 2016-02-15
  5    Gambio GmbH
  6    http://www.gambio.de
  7    Copyright (c) 2016 Gambio GmbH
  8    Released under the GNU General Public License (Version 2)
  9    [http://www.gnu.org/licenses/gpl-2.0.html]
 10    --------------------------------------------------------------
 11 */
 12 
 13 /**
 14  * Class CategoryWriteService
 15  * 
 16  * This class provides methods for creating, updating and deleting categories data.
 17  *
 18  * @category   System
 19  * @package    Category
 20  * @implements CategoryWriteServiceInterface
 21  */
 22 class CategoryWriteService implements CategoryWriteServiceInterface
 23 {
 24     /**
 25      * Category repository.
 26      * 
 27      * @var CategoryRepositoryInterface
 28      */
 29     protected $categoryRepo;
 30 
 31     /**
 32      * Category image.
 33      * 
 34      * @var AbstractFileStorage
 35      */
 36     protected $categoryImageStorage;
 37 
 38     /**
 39      * Category icon.
 40      * 
 41      * @var AbstractFileStorage
 42      */
 43     protected $categoryIconStorage;
 44     
 45     /**
 46      * ProductPermissionSetter
 47      * 
 48      * @var ProductPermissionSetterInterface
 49      */
 50     protected $productPermissionSetter;
 51 
 52 
 53     /**
 54      * CategoryWriteService constructor.
 55      *
 56      * @param CategoryRepositoryInterface      $categoryRepo            Category repository.
 57      * @param AbstractFileStorage              $categoryImageStorage    Category image.
 58      * @param AbstractFileStorage              $categoryIconStorage     Category icon.
 59      * @param ProductPermissionSetterInterface $productPermissionSetter ProductPermissionSetter.
 60      */
 61     public function __construct(CategoryRepositoryInterface $categoryRepo,
 62                                 AbstractFileStorage $categoryImageStorage,
 63                                 AbstractFileStorage $categoryIconStorage,
 64                                 ProductPermissionSetterInterface $productPermissionSetter)
 65     {
 66         $this->categoryRepo            = $categoryRepo;
 67         $this->categoryImageStorage    = $categoryImageStorage;
 68         $this->categoryIconStorage     = $categoryIconStorage;
 69         $this->productPermissionSetter = $productPermissionSetter;
 70     }
 71 
 72 
 73     /**
 74      * Stores a category in the database and returns the newly created ID of it.
 75      *
 76      * @param CategoryInterface $category The category to store.
 77      *
 78      * @return int Returns the ID of the new category record.
 79      */
 80     public function createCategory(CategoryInterface $category)
 81     {
 82         return $this->categoryRepo->add($category);
 83     }
 84 
 85 
 86     /**
 87      * Updates the provided category and returns itself.
 88      *
 89      * @param StoredCategoryInterface $category The category to update.
 90      *
 91      * @return CategoryWriteService Same instance for chained method calls.
 92      */
 93     public function updateCategory(StoredCategoryInterface $category)
 94     {
 95         $this->categoryRepo->store($category);
 96 
 97         return $this;
 98     }
 99 
100 
101     /**
102      * Deletes a category depending on the provided category ID.
103      *
104      * @param IdType $categoryId Category ID of the category to delete.
105      *
106      * @return CategoryWriteService Same instance for chained method calls.
107      */
108     public function deleteCategoryById(IdType $categoryId)
109     {
110         $category = $this->categoryRepo->getCategoryById($categoryId);
111         
112         $this->categoryIconStorage->deleteFile(new FilenameStringType($category->getIcon()));
113         $this->categoryImageStorage->deleteFile(new FilenameStringType($category->getImage()));
114         
115         $this->categoryRepo->deleteCategoryById($categoryId);
116 
117         return $this;
118     }
119     
120     
121     /**
122      * Moves a category into another category.
123      *
124      * This method moves a category specified by its category ID into another parent category specified by its
125      * category ID.
126      *
127      * @param IdType $categoryId  Category ID of the category to move.
128      * @param IdType $newParentId The new parent ID.
129      *
130      * @return CategoryWriteService Same instance for chained method calls.
131      */
132     public function moveCategory(IdType $categoryId, IdType $newParentId)
133     {
134         $storedCategory = $this->categoryRepo->getCategoryById($categoryId);
135         $storedCategory->setParentId($newParentId);
136 
137         $this->categoryRepo->store($storedCategory);
138 
139         return $this;
140     }
141     
142     
143     /**
144      * Duplicates a category specified by its category ID.
145      *
146      * This method duplicates the category which are identified by the provided category ID and links the duplicated
147      * category with the provided parent category ID. Containing subcategories and products will also be recursively
148      * duplicated with their attributes, specials and cross selling data depending on the last four arguments.
149      *
150      * @param IdType   $categoryId            The category ID of the category to duplicate.
151      * @param IdType   $targetParentId        The target parent ID of the duplicated category.
152      * @param BoolType $duplicateProducts     Should the products be duplicated?
153      * @param BoolType $duplicateAttributes   Should the attributes be duplicated?
154      * @param BoolType $duplicateSpecials     Should the specials be duplicated?
155      * @param BoolType $duplicateCrossSelling Should cross selling be duplicated?
156      *
157      * @return int Returns the ID of the new category record.
158      *
159      * @todo Implement the last four arguments when finished in UML.
160      */
161     public function duplicateCategory(IdType $categoryId,
162                                       IdType $targetParentId,
163                                       BoolType $duplicateProducts = null,
164                                       BoolType $duplicateAttributes = null,
165                                       BoolType $duplicateSpecials = null,
166                                       BoolType $duplicateCrossSelling = null)
167     {
168         $storedCategory = $this->categoryRepo->getCategoryById($categoryId);
169         $storedCategory->setParentId($targetParentId);
170         $newCategoryId = $this->categoryRepo->add($storedCategory);
171 
172         return $newCategoryId;
173     }
174 
175 
176     /**
177      * Imports an image file and stores it.
178      *
179      * @param ExistingFile       $sourceFile     The image file to import.
180      * @param FilenameStringType $saveAsFilename The name under which the image should to be stored.
181      *
182      * @return string The new filename.
183      */
184     public function importCategoryImageFile(ExistingFile $sourceFile, FilenameStringType $saveAsFilename)
185     {
186         return $this->categoryImageStorage->importFile($sourceFile, $saveAsFilename);
187     }
188 
189 
190     /**
191      * Imports an icon file and stores it.
192      *
193      * @param ExistingFile       $sourceFile     The icon file to import.
194      * @param FilenameStringType $saveAsFilename The name under which the icon should be stored.
195      *
196      * @return string The new filename.
197      */
198     public function importCategoryIconFile(ExistingFile $sourceFile, FilenameStringType $saveAsFilename)
199     {
200         return $this->categoryIconStorage->importFile($sourceFile, $saveAsFilename);
201     }
202 
203 
204     /**
205      * Renames a category image file.
206      *
207      * @param FilenameStringType $oldName Old file name.
208      * @param FilenameStringType $newName New file name.
209      *
210      * @return CategoryWriteServiceInterface Same instance for chained method calls.
211      */
212     public function renameCategoryImageFile(FilenameStringType $oldName, FilenameStringType $newName)
213     {
214         $this->categoryImageStorage->renameFile($oldName, $newName);
215 
216         return $this;
217     }
218 
219 
220     /**
221      * Renames a category icon file.
222      *
223      * @param FilenameStringType $oldName Old file name.
224      * @param FilenameStringType $newName New file name.
225      *
226      * @return CategoryWriteServiceInterface Same instance for chained method calls.
227      */
228     public function renameCategoryIconFile(FilenameStringType $oldName, FilenameStringType $newName)
229     {
230         $this->categoryIconStorage->renameFile($oldName, $newName);
231 
232         return $this;
233     }
234 
235 
236     /**
237      * Deletes a category image file.
238      *
239      * @param FilenameStringType $filename Category image file name.
240      *
241      * @return CategoryWriteServiceInterface Same instance for chained method calls.
242      */
243     public function deleteCategoryImageFile(FilenameStringType $filename)
244     {
245         $this->categoryImageStorage->deleteFile($filename);
246 
247         return $this;
248     }
249 
250 
251     /**
252      * Deletes a category icon file.
253      *
254      * @param FilenameStringType $filename Category icon file name.
255      *
256      * @return CategoryWriteServiceInterface Same instance for chained method calls.
257      */
258     public function deleteCategoryIconFile(FilenameStringType $filename)
259     {
260         $this->categoryIconStorage->deleteFile($filename);
261 
262         return $this;
263     }
264 
265 
266     /**
267      * Activates a specific category and its subcategories if desired.
268      *
269      * @param IdType   $categoryId           Category ID of the category to activate.
270      * @param BoolType $includeSubcategories Shall the subcategories be activated also?
271      *
272      * @return CategoryWriteServiceInterface Same instance for chained method calls.
273      */
274     public function activateCategory(IdType $categoryId, BoolType $includeSubcategories)
275     {
276         $storedCategory = $this->categoryRepo->getCategoryById($categoryId);
277         $storedCategory->setActive(new BoolType(true));
278         $this->categoryRepo->store($storedCategory);
279         
280         if($includeSubcategories->asBool())
281         {
282             foreach($this->categoryRepo->getCategoryIdsByParentId($categoryId)->getArray() as $subCategoryId)
283             {
284                 $this->activateCategory($subCategoryId, $includeSubcategories);
285             }
286         }
287         
288         return $this;
289     }
290 
291 
292     /**
293      * Deactivates a specific category and its subcategories if desired.
294      *
295      * @param IdType   $categoryId           Category ID of the category to deactivate.
296      * @param BoolType $includeSubcategories Shall the subcategories be deactivated also?
297      *
298      * @return CategoryWriteServiceInterface Same instance for chained method calls.
299      */
300     public function deactivateCategory(IdType $categoryId, BoolType $includeSubcategories)
301     {
302         $storedCategory = $this->categoryRepo->getCategoryById($categoryId);
303         $storedCategory->setActive(new BoolType(false));
304         $this->categoryRepo->store($storedCategory);
305         
306         if($includeSubcategories->asBool())
307         {
308             foreach($this->categoryRepo->getCategoryIdsByParentId($categoryId)->getArray() as $subCategoryId)
309             {
310                 $this->deactivateCategory($subCategoryId, $includeSubcategories);
311             }
312         }
313         
314         return $this;
315     }
316     
317     
318     /**
319      * Sets the customer status permissions.
320      *
321      * The customer status permissions decides if the category is visible for a specific customer group. The
322      * permissions can be applied for subcategories also if desired.
323      *
324      * @param IdType   $categoryId                      Category ID.
325      * @param IdType   $customerStatusId                Customer status ID.
326      * @param BoolType $permitted                       Grant permission?
327      * @param BoolType $includeSubcategoriesAndProducts Grant permission including subcategories?
328      *
329      * @return CategoryWriteServiceInterface Same instance for chained method calls.
330      */
331     public function setCustomerStatusPermission(IdType $categoryId,
332                                                 IdType $customerStatusId,
333                                                 BoolType $permitted,
334                                                 BoolType $includeSubcategoriesAndProducts)
335     {
336         $storedCategory         = $this->categoryRepo->getCategoryById($categoryId);
337         $storedCategorySettings = $storedCategory->getSettings();
338         $storedCategorySettings->setPermittedCustomerStatus($customerStatusId, $permitted);
339         $this->categoryRepo->store($storedCategory);
340         
341         if($includeSubcategoriesAndProducts->asBool())
342         {
343             $this->productPermissionSetter->setProductsPermissionByCategoryId($categoryId, $customerStatusId,
344                                                                               $permitted);
345             
346             foreach($this->categoryRepo->getCategoryIdsByParentId($categoryId)->getArray() as $subCategoryId)
347             {
348                 $this->setCustomerStatusPermission($subCategoryId, $customerStatusId, $permitted,
349                                                    $includeSubcategoriesAndProducts);
350             }
351         }
352         
353         return $this;
354     }
355 }
356 
API documentation generated by ApiGen