コード例 #1
0
 /**
  * Checks if the passed value is valid.
  *
  * @param string $value The value that should be validated
  * @param IsAvailable|Constraint $constraint The constraint for the validation
  */
 public function validate($value, Constraint $constraint)
 {
     $available = $this->repository->getAvailability($value);
     if (!$available) {
         $this->context->buildViolation($constraint->message)->addViolation();
     }
 }
コード例 #2
0
 public function onProductSave(ProductSavedEvent $event)
 {
     $product = $event->getProduct();
     $this->repository->saveAvailability($product->getId()->getValue(), $product->isAvailable());
     if ($this->persister->handlesObject($product)) {
         $this->persister->insertOne($product);
     }
 }
コード例 #3
0
ファイル: ProductUrlCollector.php プロジェクト: igaponov/shop
 /**
  * @inheritDoc
  */
 public function collect() : \Iterator
 {
     $generator = function () {
         foreach ($this->repository->findAllIds() as $id) {
             foreach ($this->locales as $locale) {
                 (yield $this->router->generate('product', ['id' => $id, '_locale' => $locale], RouterInterface::ABSOLUTE_URL));
             }
         }
     };
     return $generator();
 }
コード例 #4
0
 /**
  * Do the initialization logic
  *
  * @return void
  */
 protected function doInitialize()
 {
     $collection = $this->collection;
     $ids = $collection->getKeys();
     $products = $this->repository->findByIds($ids);
     $this->collection = new ArrayCollection();
     foreach ($products as $product) {
         $lineItem = LineItemView::create($product, $collection->get($product->getId()));
         $this->collection->set($product->getId(), $lineItem);
     }
 }
コード例 #5
0
 /**
  * @inheritDoc
  */
 public function findAllIds()
 {
     return $this->repository->findAllIds();
 }
コード例 #6
0
ファイル: ProductService.php プロジェクト: igaponov/shop
 public function getProductAvailabilityById(GetProductAvailabilityByIdQuery $query)
 {
     $result = $this->viewRepository->getAvailability($query->getId());
     $query->setResult($result);
 }