本文整理匯總了PHP中Doctrine\Common\Collections\Collection::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::exists方法的具體用法?PHP Collection::exists怎麽用?PHP Collection::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::exists方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testExists
public function testExists()
{
$this->_coll->add("one");
$this->_coll->add("two");
$exists = $this->_coll->exists(function ($k, $e) {
return $e == "one";
});
$this->assertTrue($exists);
$exists = $this->_coll->exists(function ($k, $e) {
return $e == "other";
});
$this->assertFalse($exists);
}
示例2: persist
/**
* @param EntityManager $em The entity manager
*/
public function persist(EntityManager $em)
{
foreach ($this->mediaSet->filter(function (PageMedia $item) {
return (bool) $item->getMedia();
}) as $item) {
$em->persist($item);
}
foreach ($this->toDelete as $item) {
$callback = function ($key, PageMedia $element) use($item) {
/** @noinspection PhpExpressionResultUnusedInspection */
$key;
return $element->getType() === $item->getType() && $element->getMedia();
};
if (false === $this->mediaSet->exists($callback)) {
$em->remove($item);
}
}
}
示例3: exists
/**
* {@inheritdoc}
*/
public function exists(Closure $p)
{
$this->initialize();
return $this->coll->exists($p);
}
示例4: exists
/**
* {@inheritdoc}
*/
public function exists(\Closure $p)
{
return $this->inner->exists($p);
}