コード例 #1
0
 /**
  * Create a tree of a single branch
  *
  * @param array $branches
  * @return CobwebInfo\Cobra5Sdk\Entity\Entity
  */
 public function branch($id, array $branches = [])
 {
     $datastore = $this->cobra5->getStore($id);
     $datastore = $this->hydrateRoots($datastore);
     if (in_array('categories', $branches)) {
         $datastore = $this->hydrateParents($datastore);
         foreach ($datastore->categories() as $category) {
             $category = $this->hydrateChildren($category);
         }
     }
     if (in_array('documents', $branches)) {
         foreach ($datastore->categories() as $category) {
             $category = $this->hydrateDocuments($category);
         }
     }
     return $datastore;
 }
コード例 #2
0
 /**
  * Create a tree of a single branch
  *
  * @param array $branches
  * @return CobwebInfo\Cobra5Sdk\Entity\Entity
  */
 public function branch($id, array $branches = [])
 {
     $response = $this->cobra5->getCategory($id);
     if ($response instanceof Category) {
         $response = $this->hydrateChildren($response);
         if (in_array('documents', $branches)) {
             $response = $this->hydrateDocuments($response);
         }
         return $response;
     }
     if ($response instanceof Collection) {
         foreach ($response as $category) {
             $category = $this->hydrateChildren($category);
         }
         if (in_array('documents', $branches)) {
             foreach ($response as $category) {
                 $category = $this->hydrateDocuments($category);
             }
         }
         return $response;
     }
 }