/** * {@inheritDoc} */ public function getChildren() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getChildren', array()); return parent::getChildren(); }
/** * Converts the album properties into tree node properties. * If the album has sub-albums, the children iterate recursive. * * @param Shopware\Models\Media\Album $album * @return array */ private function getAlbumNodeProperties(\Shopware\Models\Media\Album $album) { /** @var $repository \Shopware\Models\Media\Repository */ $repository = Shopware()->Models()->Media(); $query = $repository->getAlbumMediaQuery($album->getId()); //returns the total count of the query $totalResult = \DoctrineExtensions\Paginate\Paginate::count($query); $node = array( 'id' => $album->getId(), 'text' => $album->getName(), 'position' => $album->getPosition(), 'mediaCount' => $totalResult, 'parentId' => $album->getParentId() ); //to get fresh album settings from new albums too $settingsQuery = $repository->getAlbumWithSettingsQuery($album->getId()); $albumData = $settingsQuery->getOneOrNullResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY); $settings = $albumData["settings"]; if (!empty($settings) && $settings !== null) { $node["iconCls"] = $settings["icon"]; $node["createThumbnails"] = $settings["createThumbnails"]; $thumbnails = explode(";",$settings["thumbnailSize"]); $node["thumbnailSize"] = array(); $count = count($thumbnails); //convert the thumbnail to an array width the index and value for ($i = 0; $i <= $count; $i++) { if ($thumbnails[$i] === '' || $thumbnails[$i] === null) { continue; } $node["thumbnailSize"][] = array('id' => $i,'index' => $i, 'value' => $thumbnails[$i]); } } //has sub-albums, then iterate and add the media count to the parent album. if (count($album->getChildren()) > 0) { $node['data'] = $this->toTree($album->getChildren(), $node); $node['leaf'] = false; } else { $node['leaf'] = true; } return $node; }