本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::exists方法的具体用法?PHP ArrayCollection::exists怎么用?PHP ArrayCollection::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\ArrayCollection
的用法示例。
在下文中一共展示了ArrayCollection::exists方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sameValueAs
/**
* @param Itinerary $other
* @return bool
*/
public function sameValueAs(Itinerary $other) : bool
{
//We use doctrine's ArrayCollection only to ease comparison
//If Legs would be stored in an ArrayCollection hole the time
//Itinerary itself would not be immutable,
//cause a client could call $itinerary->legs()->add($anotherLeg);
//Keeping ValueObjects immutable is a rule of thumb
$myLegs = new ArrayCollection($this->legs());
$otherLegs = new ArrayCollection($other->legs());
if ($myLegs->count() !== $otherLegs->count()) {
return false;
}
return $myLegs->forAll(function ($index, Leg $leg) use($otherLegs) {
return $otherLegs->exists(function ($otherIndex, Leg $otherLeg) use($leg) {
return $otherLeg->sameValueAs($leg);
});
});
}
开发者ID:RossJHagan,项目名称:php-ddd-cargo-sample,代码行数:22,代码来源:Itinerary.php示例2: exists
public function exists(Closure $p)
{
if (null === $this->entries) {
$this->__load___();
}
return $this->entries->exists($p);
}
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:7,代码来源:AggregateEntryCollection.php示例3: contextHasTransportable
/**
* @param TransportableInterface $transportable
* @return bool
*/
protected function contextHasTransportable(TransportableInterface $transportable)
{
return $this->context->exists(function ($k, $v) use($transportable) {
/** @var TransportableInterface $v */
return $transportable === $v;
});
}
开发者ID:umber-io,项目名称:rei,代码行数:11,代码来源:ArrayTransformer.php示例4: canAddUser
/**
* @param User $user
*
* @return bool
*/
protected function canAddUser(User $user)
{
$foundUser = $this->taUsers->exists(function ($key, $element) use($user) {
return $user->getUsername() == $element->getUsername();
});
return $foundUser == false;
}
开发者ID:TumTum,项目名称:TrolleyAgenda,代码行数:12,代码来源:Day.php示例5: isActivated
/**
* {@inheritdoc}
*/
public function isActivated()
{
return $this->activations->exists(function ($id, Activation $activation) {
return $activation->isCompleted();
});
}
开发者ID:digbang,项目名称:security,代码行数:9,代码来源:DefaultUser.php示例6: testExists
public function testExists()
{
$elements = array(1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0);
$collection = new ArrayCollection($elements);
$this->assertTrue($collection->exists(function ($key, $element) {
return $key == 'A' && $element == 'a';
}), "Element exists");
$this->assertFalse($collection->exists(function ($key, $element) {
return $key == 'non-existent' && $element == 'non-existent';
}), "Element not exists");
}
开发者ID:tccLaravel,项目名称:test4,代码行数:11,代码来源:ArrayCollectionTest.php示例7: isPreviouslyLoginFailed
/**
* Checks if the auth failed previously.
*
* @param string $diff
* @param bool $ignoreLastAttempts
* @param DateTimeComparison $comparison
*
* @return bool
*/
private function isPreviouslyLoginFailed(string $diff, DateTimeComparison $comparison, bool $ignoreLastAttempts = false) : bool
{
return $this->failedAuthentications->exists(function (int $index, AuthenticationAttempt $failedAttempt) use($diff, $ignoreLastAttempts, $comparison) {
$ipRange = $failedAttempt->getLastFailedAttemptTimesInRange();
return $comparison($diff, $failedAttempt->getIp() && $ignoreLastAttempts ? end($ipRange) : $failedAttempt->getLatestFailedAttemptTime());
});
}
开发者ID:sententiaregum,项目名称:sententiaregum,代码行数:16,代码来源:User.php示例8: exists
/** {@inheritDoc} */
public function exists(Closure $p)
{
$this->initialize();
return $this->collection->exists($p);
}
开发者ID:nikophil,项目名称:cmf-tests,代码行数:6,代码来源:PersistentCollection.php示例9: inRole
/**
* {@inheritdoc}
*/
public function inRole($role)
{
return $this->roles->exists(function ($key, Role $myRole) use($role) {
return $myRole->is($role);
});
}
开发者ID:digbang,项目名称:security,代码行数:9,代码来源:RoleableTrait.php示例10: exists
/**
* Tests for the existence of an element that satisfies the given predicate.
*
* @param Closure $p The predicate.
*
* @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise.
*/
public function exists(Closure $p)
{
return $this->collection->exists($p);
}
开发者ID:Rybbow,项目名称:x-blog,代码行数:11,代码来源:ImmutableCollection.php示例11: saveTagging
/**
* Saves tags for the given taggable resource
*
* @param Taggable $resource Taggable resource
* @param bool $flush Whether to flush the changes (default true)
*/
public function saveTagging(Taggable $resource, $flush = true)
{
$oldTags = $this->getTagging($resource, $this->getUser()->getId());
$newTags = $resource->getTags();
if (isset($newTags['all'], $newTags['owner'])) {
$newOwnerTags = new ArrayCollection($newTags['owner']);
$newAllTags = new ArrayCollection($newTags['all']);
$manager = $this;
$tagsToAdd = $newOwnerTags->filter(function ($tag) use($oldTags, $manager) {
return !$oldTags->exists($manager->compareCallback($tag));
});
$tagsToDelete = $oldTags->filter(function ($tag) use($newOwnerTags, $manager) {
return !$newOwnerTags->exists($manager->compareCallback($tag));
});
if (!$tagsToDelete->isEmpty() && $this->securityFacade->isGranted(self::ACL_RESOURCE_ASSIGN_ID_KEY)) {
$this->deleteTaggingByParams($tagsToDelete, ClassUtils::getClass($resource), $resource->getTaggableId(), $this->getUser()->getId());
}
// process if current user allowed to remove other's tag links
if ($this->securityFacade->isGranted(self::ACL_RESOURCE_REMOVE_ID_KEY)) {
// get 'not mine' taggings
$oldTags = $this->getTagging($resource, $this->getUser()->getId(), true);
$tagsToDelete = $oldTags->filter(function ($tag) use($newAllTags, $manager) {
return !$newAllTags->exists($manager->compareCallback($tag));
});
if (!$tagsToDelete->isEmpty()) {
$this->deleteTaggingByParams($tagsToDelete, ClassUtils::getClass($resource), $resource->getTaggableId());
}
}
foreach ($tagsToAdd as $tag) {
if (!$this->securityFacade->isGranted(self::ACL_RESOURCE_ASSIGN_ID_KEY) || !$this->securityFacade->isGranted(self::ACL_RESOURCE_CREATE_ID_KEY) && !$tag->getId()) {
// skip tags that have not ID because user not granted to create tags
continue;
}
$this->em->persist($tag);
$alias = $this->mapper->getEntityConfig(ClassUtils::getClass($resource));
$tagging = $this->createTagging($tag, $resource)->setAlias($alias['alias']);
$this->em->persist($tagging);
}
if (!$tagsToAdd->isEmpty() && $flush) {
$this->em->flush();
}
}
}
开发者ID:northdakota,项目名称:platform,代码行数:49,代码来源:TagManager.php示例12: exists
function exists(\Closure $p)
{
return $this->fields->exists($p);
}
开发者ID:tomaszhanc,项目名称:form-field-bundle,代码行数:4,代码来源:FieldCollection.php示例13: saveTagging
/**
* Saves tags for the given taggable resource
*
* @param Taggable $resource Taggable resource
* @param bool $flush Whether to flush the changes (default true)
* @param Organization $organization Current one if not specified
*/
public function saveTagging(Taggable $resource, $flush = true, Organization $organization = null)
{
$createdBy = $this->getUser() ? $this->getUser()->getId() : null;
$oldTags = $this->getTagging($resource, $createdBy, false, $organization);
$newTags = $resource->getTags();
if (isset($newTags['all'], $newTags['owner'])) {
$newOwnerTags = new ArrayCollection($newTags['owner']);
$newAllTags = new ArrayCollection($newTags['all']);
$manager = $this;
$tagsToAdd = $newOwnerTags->filter(function ($tag) use($oldTags, $manager) {
return !$oldTags->exists($manager->compareCallback($tag));
});
$tagsToDelete = $oldTags->filter(function ($tag) use($newOwnerTags, $manager) {
return !$newOwnerTags->exists($manager->compareCallback($tag));
});
if (!$tagsToDelete->isEmpty() && $this->securityFacade->isGranted(self::ACL_RESOURCE_ASSIGN_ID_KEY)) {
$this->deleteTaggingByParams($tagsToDelete, ClassUtils::getClass($resource), $resource->getTaggableId(), $this->getUser()->getId());
}
// process if current user allowed to remove other's tag links
if (!$this->getUser() || $this->securityFacade->isGranted(self::ACL_RESOURCE_REMOVE_ID_KEY)) {
// get 'not mine' taggings
$oldTags = $this->getTagging($resource, $createdBy, true, $organization);
$tagsToDelete = $oldTags->filter(function ($tag) use($newAllTags, $manager) {
return !$newAllTags->exists($manager->compareCallback($tag));
});
if (!$tagsToDelete->isEmpty()) {
$this->deleteTaggingByParams($tagsToDelete, ClassUtils::getClass($resource), $resource->getTaggableId());
}
}
$this->persistTags($resource, $tagsToAdd);
if (!$tagsToAdd->isEmpty() && $flush) {
$this->em->flush();
}
}
}
开发者ID:antrampa,项目名称:platform,代码行数:42,代码来源:TagManager.php本文标签属性:
示例:示例英语
代码:代码零九
PHP:php是什么
ArrayCollection:ArrayCollection
exists:exists和in的区别