Esempio n. 1
0
 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);
 }
 /**
  * @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);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function exists(Closure $p)
 {
     $this->initialize();
     return $this->coll->exists($p);
 }
 /**
  * {@inheritdoc}
  */
 public function exists(\Closure $p)
 {
     return $this->inner->exists($p);
 }