Пример #1
0
 /**
  * {@inheritdoc}
  *
  * @event EventStore vanity.twig.generate.options
  */
 public function generateAPIReference($json_file)
 {
     $data = json_decode(file_get_contents($json_file), true);
     $path = $this->convertNamespaceToPath($data['full_name']);
     $wrote = array();
     $twig_options = array('json' => $data, 'vanity' => array('base_path' => GenerateUtils::getRelativeBasePath($data['full_name']), 'breadcrumbs' => GenerateUtils::getBreadcrumbs($data['full_name'], -1), 'config' => ConfigStore::get(), 'page_name' => $data['name'], 'page_title' => $data['full_name'], 'project' => ConfigStore::get('vanity.name'), 'project_with_version' => ConfigStore::get('vanity.name') . ' ' . ConfigStore::get('vanity.version'), 'assets' => array('apple_touch_icon' => file_exists(str_replace('%FORMAT%', self::$format_identifier, ConfigStore::get('generator.output')) . '/apple-touch-icon.png') ? GenerateUtils::getRelativeBasePath($data['full_name']) . '/apple-touch-icon.png' : null, 'favicon' => file_exists(str_replace('%FORMAT%', self::$format_identifier, ConfigStore::get('generator.output')) . '/favicon.ico') ? GenerateUtils::getRelativeBasePath($data['full_name']) . '/favicon.ico' : null, 'windows_pinned_site' => file_exists(str_replace('%FORMAT%', self::$format_identifier, ConfigStore::get('generator.output')) . '/windows-pinned-site.png') ? GenerateUtils::getRelativeBasePath($data['full_name']) . '/windows-pinned-site.png' : null), 'link' => array('base_dir' => GenerateUtils::getRelativeBasePath($data['full_name']), 'api_reference' => GenerateUtils::getRelativeBasePath($data['full_name']) . '/api-reference', 'user_guide' => GenerateUtils::getRelativeBasePath($data['full_name']) . '/user-guide'), 'message' => array('not_yet_implemented' => '<i class="icon-exclamation-sign"></i>&nbsp;<em>Not yet documented.</em>')));
     $this->triggerEvent('vanity.twig.generate.options', new EventStore(array('twig_options' => &$twig_options)));
     $this->filesystem->mkdir($path);
     // Classes/Interfaces/Traits
     if (file_exists($this->template_path . '/class.twig')) {
         file_put_contents($path . '/index.' . $this->extension, $this->twig->render('class.twig', $twig_options));
         $wrote[] = $path . '/index.' . $this->extension;
         self::$typeahead[] = $data['full_name'];
         // Methods
         if (file_exists($this->template_path . '/method.twig')) {
             if (isset($data['methods']) && isset($data['methods']['method'])) {
                 foreach ($data['methods']['method'] as $method) {
                     $method_name = $method['name'];
                     $twig_options['method'] = $method;
                     $twig_options['vanity']['base_path'] = GenerateUtils::getRelativeBasePath($data['full_name'] . "\\{$method_name}", -1);
                     $twig_options['vanity']['breadcrumbs'] = GenerateUtils::getBreadcrumbs($data['full_name'] . "\\{$method_name}()", -2);
                     file_put_contents($path . "/{$method_name}." . $this->extension, $this->twig->render('method.twig', $twig_options));
                     $wrote[] = $path . "/{$method_name}." . $this->extension;
                     self::$typeahead[] = $data['full_name'] . '::' . $method_name . '()';
                 }
             }
         }
     }
     return $wrote;
 }
Пример #2
0
 public function __invoke($fullName)
 {
     return GenerateUtils::namespaceAsPath($fullName);
 }