/** * 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; }
/** * @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); }
/** * {@inheritdoc} */ public function getImage() { if ($this->images->isEmpty()) { return null; } return $this->images->first(); }
/** * {@inheritdoc} */ public function getImage() { if ($this->images->isEmpty()) { return $this->getProduct()->getImage(); } return $this->images->first(); }
/** * 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()); }
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); }
/** * 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; }
/** * @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; }); }
/** * 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); }
/** * 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; }
/** * @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; }
/** * 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(); }
/** * {@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; }
/** * {@inheritdoc} */ public function hasOptions() { return !$this->options->isEmpty(); }
/** * {@inheritdoc} */ public function hasShipments() { return !$this->shipments->isEmpty(); }
/** * {@inheritdoc} */ public function hasTerms() { return !$this->terms->isEmpty(); }
/** * {@inheritdoc} */ public function hasChildren() { return !$this->children->isEmpty(); }
/** * {@inheritdoc} */ public function isEmpty() { return parent::isEmpty() && $this->types->isEmpty() && !$this->primary; }
public function testCanRemoveNullValuesByKey() { $this->_coll->add(null); $this->_coll->remove(0); $this->assertTrue($this->_coll->isEmpty()); }
/** * {@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(); }
/** * {@inheritdoc} */ public function hasProvinces() { return !$this->provinces->isEmpty(); }
/** * {@inheritdoc} */ public function hasImages() { return !$this->images->isEmpty(); }
/** * 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(); }
/** * {@inheritdoc} */ public function hasMembers() { return !$this->members->isEmpty(); }
/** * 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; }
/** * {@inheritdoc} */ public function hasActions() { return !$this->actions->isEmpty(); }