コード例 #1
0
 /**
  * Get all sources
  * @param CategoryInterface $category
  *
  * @return array
  */
 public function getAllSources(CategoryInterface $category = null)
 {
     $sources = [];
     if ($this->isValid()) {
         $categories = $category === null ? $this->categoryManager->getTrees() : $category->getChildren();
         foreach ($categories as $category) {
             $sources[] = ['id' => $category->getCode(), 'text' => sprintf('%s (%s)', $category->getLabel(), $category->getCode())];
             $sources = array_merge($sources, $this->getAllSources($category));
         }
     }
     return $sources;
 }