/** * {@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; }
/** * {@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; }
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()); }