/** * @param ServiceLocator $serviceLocator * @throws ServiceNotFoundException */ public function boot(ServiceLocator $serviceLocator) { if (!$serviceLocator->has(Services::KERNEL_TRANSACTION_FACTORY)) { throw new ServiceNotFoundException(sprintf('Service with id "%s" is missing in service locator.', Services::KERNEL_TRANSACTION_FACTORY)); } $serviceLocator->get(Services::KERNEL_COMMAND_EXTENSION_REGISTRY)->register(new TransactionExtension($serviceLocator->get(Services::KERNEL_TRANSACTION_FACTORY)), -1024); }
/** * @param ServiceLocator $serviceLocator */ protected function registerCommandExtensions(ServiceLocator $serviceLocator) { $serviceLocator->get(Services::KERNEL_COMMAND_EXTENSION_REGISTRY)->register(new MetadataExtension()); }
/** * @param Command $command * @param ServiceLocator $serviceLocator */ public function post(Command $command, ServiceLocator $serviceLocator) { /* @var CreateProduct $command */ $serviceLocator->get(Services::KERNEL_METADATA_ACCESS_REGISTRY)->getMAO(InventoryMetadata::TYPE_NAME)->save(new Metadata(MetadataId::generate(), InventoryMetadata::TYPE_NAME, [InventoryMetadata::FIELD_SKU => $command->sku(), InventoryMetadata::FIELD_VISIBLE => false])); }
/** * @param ServiceLocator $serviceLocator */ protected function mapCommands(ServiceLocator $serviceLocator) { $serviceLocator->get(Services::KERNEL_COMMAND_HANDLER_MAP)->register(CreateCart::class, $serviceLocator->get(CustomerServices::CUSTOMER_CREATE_CART_HANDLER)); $serviceLocator->get(Services::KERNEL_COMMAND_HANDLER_MAP)->register(AddToCart::class, $serviceLocator->get(CustomerServices::CUSTOMER_ADD_TO_CART_HANDLER)); $serviceLocator->get(Services::KERNEL_COMMAND_HANDLER_MAP)->register(RemoveFromCart::class, $serviceLocator->get(CustomerServices::CUSTOMER_REMOVE_FROM_CART_HANDLER)); }