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    OrderRepository.inc.php 2016-01-18
  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 MainFactory::load_class('OrderRepositoryInterface');
 14 
 15 /**
 16  * Class OrderRepository
 17  *
 18  * @category   System
 19  * @package    Order
 20  * @subpackage Repositories
 21  */
 22 class OrderRepository implements OrderRepositoryInterface
 23 {
 24     /**
 25      * Order factory.
 26      * @var OrderFactoryInterface
 27      */
 28     protected $orderFactory;
 29     
 30     /**
 31      * Addon value service.
 32      * @var AddonValueServiceInterface
 33      */
 34     protected $addonValueService;
 35     
 36     /**
 37      * Order repository writer.
 38      * @var OrderRepositoryWriterInterface
 39      */
 40     protected $writer;
 41     
 42     /**
 43      * Order repository reader.
 44      * @var OrderRepositoryReaderInterface
 45      */
 46     protected $reader;
 47     
 48     /**
 49      * Order repository deleter.
 50      * @var OrderRepositoryDeleterInterface
 51      */
 52     protected $deleter;
 53     
 54     /**
 55      * Order item repository.
 56      * @var OrderItemRepositoryInterface
 57      */
 58     protected $orderItemRepository;
 59     
 60     /**
 61      * Order total repository.
 62      * @var OrderTotalRepositoryInterface
 63      */
 64     protected $orderTotalRepository;
 65     
 66     /**
 67      * Order status history reader.
 68      * @var OrderStatusHistoryStorage
 69      */
 70     protected $orderStatusHistoryReader;
 71     
 72     
 73     /**
 74      * OrderRepository constructor.
 75      *
 76      * @param OrderFactoryInterface             $orderFactory          Factory to create order objects.
 77      * @param OrderRepositoryWriterInterface    $writer                Order repository writer.
 78      * @param OrderRepositoryReaderInterface    $reader                Order repository reader.
 79      * @param OrderRepositoryDeleterInterface   $deleter               Order repository deleter.
 80      * @param OrderItemRepositoryInterface      $orderItemRepository   Repository for order items.
 81      * @param OrderTotalRepositoryInterface     $orderTotalRepository  Repository for order totals.
 82      * @param OrderStatusHistoryReaderInterface $historyReader         Reader for order status history items.
 83      * @param AddonValueServiceInterface        $addonValueService     AddonValueService to handle the
 84      *                                                                 order addon values.
 85      */
 86     public function __construct(OrderFactoryInterface $orderFactory,
 87                                 OrderRepositoryWriterInterface $writer,
 88                                 OrderRepositoryReaderInterface $reader,
 89                                 OrderRepositoryDeleterInterface $deleter,
 90                                 OrderItemRepositoryInterface $orderItemRepository,
 91                                 OrderTotalRepositoryInterface $orderTotalRepository,
 92                                 OrderStatusHistoryReaderInterface $historyReader,
 93                                 AddonValueServiceInterface $addonValueService)
 94     {
 95         $this->orderFactory             = $orderFactory;
 96         $this->writer                   = $writer;
 97         $this->reader                   = $reader;
 98         $this->deleter                  = $deleter;
 99         $this->orderItemRepository      = $orderItemRepository;
100         $this->orderTotalRepository     = $orderTotalRepository;
101         $this->orderStatusHistoryReader = $historyReader;
102         $this->addonValueService        = $addonValueService;
103     }
104     
105     
106     /**
107      * Creates a new order with no values in the database and returns it containing just the ID.
108      *
109      * @return GXEngineOrder Crated order.
110      */
111     public function createNew()
112     {
113         $order   = $this->orderFactory->createOrder();
114         $orderId = $this->writer->insert($order);
115         $order->setOrderId(new IdType($orderId));
116         $order->setOrderStatusHistoryReader($this->orderStatusHistoryReader);
117         
118         return $order;
119     }
120     
121     
122     /**
123      * Saves an Order to the database.
124      *
125      * @param OrderInterface $order Stored order.
126      *
127      * @return OrderRepository Same instance for method chaining.
128      */
129     public function store(OrderInterface $order)
130     {
131         $order->setLastModifiedDateTime(new DateTime());
132         
133         $orderId    = $order->getOrderId();
134         $orderIdObj = new IdType($orderId);
135         
136         $this->addonValueService->storeAddonValues($order);
137         
138         $this->writer->update($order);
139         
140         $orderItemCollection = $order->getOrderItems();
141         $orderItemArray      = $orderItemCollection->getArray();
142         foreach($orderItemArray as $orderItem)
143         {
144             if($orderItem instanceof StoredOrderItemInterface)
145             {
146                 $this->orderItemRepository->store($orderItem);
147             }
148             else
149             {
150                 $this->orderItemRepository->addToOrder($orderIdObj, $orderItem);
151             }
152         }
153         
154         $orderTotalCollection = $order->getOrderTotals();
155         $orderTotalArray      = $orderTotalCollection->getArray();
156         foreach($orderTotalArray as $orderTotal)
157         {
158             if($orderTotal instanceof StoredOrderTotal)
159             {
160                 $this->orderTotalRepository->store($orderTotal);
161             }
162             else
163             {
164                 $this->orderTotalRepository->addToOrder($orderIdObj, $orderTotal);
165             }
166         }
167         
168         return $this;
169     }
170     
171     
172     /**
173      * Returns an order by given ID.
174      *
175      * @param IdType $orderId Order ID.
176      *
177      * @return GXEngineOrder Fetched order.
178      */
179     public function getById(IdType $orderId)
180     {
181         $order = $this->reader->getById($orderId);
182         $order->setOrderStatusHistoryReader($this->orderStatusHistoryReader);
183         
184         $this->addonValueService->loadAddonValues($order);
185 
186         $orderItemCollection = $this->orderItemRepository->getItemsByOrderId($orderId);
187         $order->setOrderItems($orderItemCollection);
188 
189         $orderTotalCollection = $this->orderTotalRepository->getTotalsByOrderId($orderId);
190         $order->setOrderTotals($orderTotalCollection);
191 
192         return $order;
193     }
194 
195 
196     /**
197      * Deletes an order by the ID.
198      *
199      * @param IdType $orderId Order ID.
200      *
201      * @return OrderRepository Same instance for method chaining.
202      */
203     public function deleteById(IdType $orderId)
204     {
205         $order = $this->reader->getById($orderId);
206         
207         $this->addonValueService->deleteAddonValues($order);
208         
209         $this->orderTotalRepository->deleteTotalsByOrderId($orderId);
210         $this->orderItemRepository->deleteItemsByOrderId($orderId);
211         $this->deleter->deleteById($orderId);
212 
213         return $this;
214     }
215 }
API documentation generated by ApiGen