Exemple #1
0
 /**
  * Resolves and creates the documents menu from the parsed menu.yml
  *
  * @param array       $items The array converted from yaml
  * @param string $parentId
  * @return \Codex\Codex\Menus\Menu
  */
 protected function resolveDocumentsMenu($items, $parentId = 'root')
 {
     /**
      * @var Menus\Menu $menu
      */
     $menu = $this->factory->getMenus()->add('project_sidebar_menu');
     foreach ($items as $item) {
         $link = '#';
         if (array_key_exists('document', $item)) {
             // remove .md extension if present
             $path = Str::endsWith($item['document'], '.md', false) ? Str::remove($item['document'], '.md') : $item['document'];
             $link = $this->factory->url($this, $this->ref, $path);
         } elseif (array_key_exists('href', $item)) {
             $link = $item['href'];
         }
         $id = md5($item['name'] . $link);
         $node = $menu->add($id, $item['name'], $parentId);
         $node->setAttribute('href', $link);
         $node->setAttribute('id', $id);
         if (isset($item['icon'])) {
             $node->setMeta('icon', $item['icon']);
         }
         if (isset($item['children'])) {
             $this->resolveDocumentsMenu($item['children'], $id);
         }
     }
     return $menu;
 }
Exemple #2
0
 /**
  * @param  \Codex\Codex\Project                   $project
  * @param  Filesystem                             $files
  * @param  \Illuminate\Contracts\Cache\Repository $cache
  * @param  string                                 $path
  * @return void
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function __construct(Project $project, Filesystem $files, Cache $cache, $path)
 {
     $this->cache = $cache;
     $this->files = $files;
     $this->path = $path;
     $this->project = $project;
     Factory::run('menu:ready', [$this]);
     $this->raw = $files->get($path);
     $this->menu = $this->parse($this->raw);
     Factory::run('menu:done', [$this]);
 }
Exemple #3
0
 /**
  * Get the url to this document
  *
  * @return string
  */
 public function url()
 {
     return $this->factory->url($this->project, $this->project->getRef(), $this->pathName);
 }