Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: implements IteratorAggregat\IteratorAggregate, implements Puli\Repository\Api\ResourceCollection
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function buildCollection(array $documents)
 {
     $collection = new ArrayResourceCollection();
     if (empty($documents)) {
         return $collection;
     }
     $uow = $this->getManager()->getUnitOfWork();
     foreach ($documents as $document) {
         $childPath = $uow->getDocumentId($document);
         $path = $this->unresolvePath($childPath);
         $resource = new PhpcrOdmResource($path, $document);
         $resource->attachTo($this);
         $collection->add($resource);
     }
     return $collection;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function buildCollection(array $nodes)
 {
     $collection = new ArrayResourceCollection();
     if (!$nodes) {
         return $collection;
     }
     foreach ($nodes as $node) {
         $path = $this->unresolvePath($node->getPath());
         $resource = new PhpcrResource($path, $node);
         $resource->attachTo($this);
         $collection->add($resource);
     }
     return $collection;
 }
 public function testIsEmpty()
 {
     $collection = new ArrayResourceCollection();
     $this->assertTrue($collection->isEmpty());
     $collection->add($this->getMock('Puli\\Repository\\Api\\Resource\\BodyResource'));
     $this->assertFalse($collection->isEmpty());
     $collection->remove(0);
     $this->assertTrue($collection->isEmpty());
 }