Ejemplo n.º 1
0
 /**
  * Returns if access is available for any given permissions.
  *
  * @param  array|string $permissions
  *
  * @return bool
  */
 public function hasAnyAccess($permissions)
 {
     if ($this->permissions->isEmpty()) {
         $this->mergePermissions($this->userPermissions, $this->rolePermissions);
     }
     if (func_num_args() > 1) {
         $permissions = func_get_args();
     }
     foreach ((array) $permissions as $permissionName) {
         if ($this->allows($permissionName)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * @return \Doctrine\Common\Collections\Collection
  */
 public function getTransformations()
 {
     if ($this->transformations->isEmpty()) {
         $this->initialize();
     }
     return $this->transformations;
 }
 public function testClear()
 {
     $this->_coll[] = 'one';
     $this->_coll[] = 'two';
     $this->_coll->clear();
     $this->assertEquals($this->_coll->isEmpty(), true);
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function getImage()
 {
     if ($this->images->isEmpty()) {
         return null;
     }
     return $this->images->first();
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function getImage()
 {
     if ($this->images->isEmpty()) {
         return $this->getProduct()->getImage();
     }
     return $this->images->first();
 }
Ejemplo n.º 6
0
 /**
  * Returns the total number of entries from all the feeds.
  *
  * @return int
  */
 public function getCountTotalEntries()
 {
     if ($this->feeds->isEmpty()) {
         return 0;
     }
     /** @var FeedEntryRepository $feedEntryRepository */
     $feedEntryRepository = $this->em->getRepository('Phraseanet:FeedEntry');
     return $feedEntryRepository->countByFeeds($this->feeds->getKeys());
 }
Ejemplo n.º 7
0
 function it_doesnt_apply_any_taxes_if_zone_is_missing(OrderInterface $order, Collection $collection, $taxationSettings)
 {
     $collection->isEmpty()->willReturn(false);
     $order->getItems()->willReturn($collection);
     $order->removeTaxAdjustments()->shouldBeCalled();
     $order->getShippingAddress()->willReturn(null);
     $taxationSettings->has('default_tax_zone')->willReturn(false);
     $order->addAdjustment(Argument::any())->shouldNotBeCalled();
     $this->applyTaxes($order);
 }
Ejemplo n.º 8
0
 /**
  * Set tags
  *
  * @param Collection $tags Tags
  *
  * @return Product self Object
  */
 public function setTags(Collection $tags)
 {
     $this->tags->clear();
     if (!$tags->isEmpty()) {
         foreach ($tags as $tag) {
             $this->addTag($tag);
         }
     }
     return $this;
 }
Ejemplo n.º 9
0
 /**
  * @param AntiMattr\Common\Product\VariationInterface
  *
  * @return bool
  */
 public function isVariationUnique(VariationInterface $variation)
 {
     if ($this->variations->isEmpty()) {
         return true;
     }
     return $this->variations->forAll(function ($key, $element) use($variation) {
         if ($variation->getUniqueIdentifier() === $element->getUniqueIdentifier() && $variation !== $element) {
             return false;
         }
         return true;
     });
 }
Ejemplo n.º 10
0
 /**
  * A Variation is uniquely identified by the combination of Variation::options
  *
  * @return string
  */
 public function getUniqueIdentifier()
 {
     if ($this->options->isEmpty()) {
         return;
     }
     $keys = array();
     foreach ($this->options as $option) {
         $keys[] = $option->getUniqueIdentifier();
     }
     sort($keys);
     return implode("_", $keys);
 }
Ejemplo n.º 11
0
 /**
  * Gets the last updated shipment of the order
  *
  * @return false|ShipmentInterface
  */
 public function getLastShipment()
 {
     if ($this->shipments->isEmpty()) {
         return false;
     }
     $last = $this->shipments->first();
     foreach ($this->shipments as $shipment) {
         if ($shipment->getUpdatedAt() > $last->getUpdatedAt()) {
             $last = $shipment;
         }
     }
     return $last;
 }
Ejemplo n.º 12
0
 /**
  * @param ConsumerContainer $consumerContainer
  * @param AMQPMessage $message
  *
  * @throws ConsumerContainerException
  * @return mixed|null
  */
 private function invoke(ConsumerContainer $consumerContainer, AMQPMessage $message)
 {
     $payload = $this->serializer->deserialize($message->body, $consumerContainer->getMessageClass(), 'json');
     try {
         $result = $consumerContainer->invoke($payload);
     } catch (Exception $e) {
         $containerException = new ConsumerContainerException($consumerContainer, $message, $payload, $e);
         if ($this->errorHandlers->isEmpty()) {
             throw $containerException;
         }
         $this->errorHandlers->map(function (ErrorHandlerInterface $handler) use($containerException) {
             $handler->handle($containerException);
         });
         return null;
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function isEmpty()
 {
     return $this->coll->isEmpty() && $this->count() === 0;
 }
Ejemplo n.º 14
0
 /**
  * Checks whether the collection is empty (contains no elements).
  *
  * @return boolean TRUE if the collection is empty, FALSE otherwise.
  */
 function isEmpty()
 {
     $this->initialize();
     return $this->collection->isEmpty();
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function isEmpty()
 {
     return $this->items->isEmpty();
 }
 /**
  * hasGroups
  *
  * Check if the user has any associated groups.
  *
  * @return boolean
  */
 public function hasGroups()
 {
     return $this->groups->isEmpty() ? false : true;
 }
Ejemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 public function hasOptions()
 {
     return !$this->options->isEmpty();
 }
Ejemplo n.º 18
0
 /**
  * {@inheritdoc}
  */
 public function hasShipments()
 {
     return !$this->shipments->isEmpty();
 }
Ejemplo n.º 19
0
 /**
  * {@inheritdoc}
  */
 public function hasTerms()
 {
     return !$this->terms->isEmpty();
 }
Ejemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function hasChildren()
 {
     return !$this->children->isEmpty();
 }
Ejemplo n.º 21
0
 /**
  * {@inheritdoc}
  */
 public function isEmpty()
 {
     return parent::isEmpty() && $this->types->isEmpty() && !$this->primary;
 }
Ejemplo n.º 22
0
 public function testCanRemoveNullValuesByKey()
 {
     $this->_coll->add(null);
     $this->_coll->remove(0);
     $this->assertTrue($this->_coll->isEmpty());
 }
Ejemplo n.º 23
0
 /**
  * {@inheritdoc}
  */
 public function getOAuthAccount($provider)
 {
     if ($this->oauthAccounts->isEmpty()) {
         return null;
     }
     $filtered = $this->oauthAccounts->filter(function (UserOAuthInterface $oauth) use($provider) {
         return $provider === $oauth->getProvider();
     });
     if ($filtered->isEmpty()) {
         return null;
     }
     return $filtered->current();
 }
Ejemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 public function hasProvinces()
 {
     return !$this->provinces->isEmpty();
 }
Ejemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 public function hasImages()
 {
     return !$this->images->isEmpty();
 }
Ejemplo n.º 26
0
 /**
  * Tells if this product has variants.
  *
  * @return bool Product has variants
  */
 public function hasVariants()
 {
     return !$this->variants->isEmpty();
 }
 /**
  * {@inheritdoc}
  */
 public function isEmpty()
 {
     $this->initialize();
     return $this->coll->isEmpty();
 }
Ejemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 public function hasMembers()
 {
     return !$this->members->isEmpty();
 }
Ejemplo n.º 29
0
 /**
  * Sets this variant option values.
  *
  * @param Collection $options
  *
  * @return $this Self object
  */
 public function setOptions(Collection $options)
 {
     /*
      * We want to be able to assign an empty
      * ArrayCollection to variant options
      *
      * When the collection is not empty, each
      * option in the collection will be added
      * separately since it needs to update the
      * parent product attribute list
      */
     if ($options->isEmpty()) {
         $this->options = $options;
     } else {
         $this->options->clear();
     }
     /**
      * @var ValueInterface $option
      */
     foreach ($options as $option) {
         /*
          * We need to update the parent product attribute collection
          */
         $this->addOption($option);
     }
     return $this;
 }
Ejemplo n.º 30
0
 /**
  * {@inheritdoc}
  */
 public function hasActions()
 {
     return !$this->actions->isEmpty();
 }