/** * @expectedException TypeError */ public function testAddDocumentOnlyAcceptsDocumentEntity() { $category = new Category(); $category->addDocument('hello world'); }
/** * Hydrate the documents of a category * * @param CobwebInfo\Cobra5Sdk\Entity\Category $category * @return CobwebInfo\Cobra5Sdk\Entity\Category */ protected function hydrateDocuments(Category $category) { if ($category->hasChildren()) { foreach ($category->children() as $child) { $documents = $this->getDocumentsForCategory($child); if ($documents) { foreach ($documents as $document) { $child->addDocument($document); } } } return $category; } $documents = $this->getDocumentsForCategory($category); if ($documents) { foreach ($documents as $document) { $category->addDocument($document); } } return $category; }