public function formatComponentTemplateFiles(Component $component, $renderMode = ITemplateLocator::DEFAULT_COMPONENT_RENDER_MODE)
 {
     $hash = $component->getPresenter()->getName() . '|' . $component->getReflection()->getShortName() . '|' . $renderMode;
     if (NULL === $this->componentFilesCache[$hash]) {
         $templateLocator = $this->templateLocator;
         $onlyExistingFiles = $this->onlyExistingFiles;
         return $this->componentFilesCache->save($hash, function () use($component, $renderMode, $templateLocator, $onlyExistingFiles) {
             $list = $templateLocator->formatComponentTemplateFiles($component, $renderMode);
             if ($onlyExistingFiles) {
                 $list = array_filter($list, 'is_file');
             }
             return $list;
         });
     }
     return $this->componentFilesCache[$hash];
 }
 public function formatComponentTemplateFiles(Component $component, $renderMode = ITemplateLocator::DEFAULT_COMPONENT_RENDER_MODE)
 {
     $presenter = $component->getPresenter();
     $name = $presenter->getName();
     $_presenter = substr($name, strrpos(':' . $name, ':'));
     $componentShortName = $component->getReflection()->getShortName();
     $variants = $this->getComponentVariants($componentShortName, $renderMode);
     $dir = dirname($presenter->getReflection()->getFileName());
     $dir = is_dir("{$dir}/templates") ? $dir : dirname($dir);
     $this->appendPrefixed($list, "{$dir}/templates/{$_presenter}/components", $variants);
     do {
         $this->appendPrefixed($list, "{$dir}/templates/components", $variants);
         $dir = dirname($dir);
     } while ($dir && ($name = substr($name, 0, strrpos($name, ':'))));
     $dir = dirname($component->getReflection()->getFileName());
     $this->appendPrefixed($list, "{$dir}/templates", $variants);
     $this->appendPrefixed($list, "{$dir}", $variants);
     return $list;
 }
 /**
  * Note: Component class name suffix Component is stripped.
  *
  * Presenter templates are added per module
  *  <directory>/[Name[Module]/][presenters/][<Presenter>/]templates/components/<Name>/<view>.(latte|phtml)
  *  <directory>/[Name[Module]/][presenters/][<Presenter>/]templates/components/<Name>.<view>.(latte|phtml)
  *  <directory>/[Name[Module]/][presenters/][<Presenter>/]templates/components/<Name>/default.(latte|phtml)
  *  <directory>/[Name[Module]/][presenters/][<Presenter>/]templates/components/<Name>.default.(latte|phtml)
  *  <directory>/[Name[Module]/][presenters/][<Presenter>/]templates/components/<Name>.(latte|phtml)
  *
  * Last component directory is added
  *  <component directory>/[templates/]<Name>/<view>.(latte|phtml)
  *  <component directory>/[templates/]<Name>.<view>.(latte|phtml)
  *  <component directory>/[templates/]<Name>/default.(latte|phtml)
  *  <component directory>/[templates/]<Name>.default.(latte|phtml)
  *  <component directory>/[templates/]<Name>.(latte|phtml)
  *
  * @inherit
  */
 public function formatComponentTemplateFiles(Component $component, $renderMode = ITemplateLocator::DEFAULT_COMPONENT_RENDER_MODE)
 {
     $presenter = $component->getPresenter();
     /** @var \Nette\Application\UI\Presenter $presenter */
     $name = $presenter->getName();
     $_presenter = substr($name, strrpos(':' . $name, ':'));
     $componentShortName = $component->getReflection()->getShortName();
     if (substr($componentShortName, -9) === 'Component') {
         $componentShortName = substr($componentShortName, 0, -9);
     }
     $variants = $this->getComponentVariants($componentShortName, $renderMode);
     $directories = $this->getAdjustedDirectories($presenter, $moduleDepth);
     $list = array();
     foreach ($directories as $dir) {
         $this->appendPrefixed($list, "{$dir}/presenters/templates/{$_presenter}/components", $variants);
         $this->appendPrefixed($list, "{$dir}/templates/{$_presenter}/components", $variants);
         $this->appendPrefixed($list, "{$dir}/presenters/templates/components", $variants);
         $this->appendPrefixed($list, "{$dir}/templates/components", $variants);
     }
     do {
         foreach ($directories as $dir) {
             $this->appendPrefixed($list, "{$dir}/templates/components", $variants);
             if (basename($dir) === 'presenters') {
                 $this->appendPrefixed($list, dirname($dir) . '/templates/components', $variants);
             }
         }
     } while ($moduleDepth-- && ($directories = array_map('dirname', $directories)));
     $dir = dirname($component->getReflection()->getFileName());
     $this->appendPrefixed($list, "{$dir}/templates", $variants);
     $this->appendPrefixed($list, "{$dir}", $variants);
     return $list;
 }