コード例 #1
0
 /**
  * @param ContainerInterface|Container $pimple A container instance
  *
  * @throws InvalidSettingsException
  *
  * @return Engine
  */
 public function register(Container $pimple)
 {
     $settings = $pimple->get('settings')['renderer'];
     if (is_null($settings)) {
         throw new InvalidSettingsException('Please configure the renderer settings with valid `template_path` and `template_ext` values.');
     }
     $engine = new PlatesRenderer($settings['template_path'], $settings['template_ext']);
     $engine->getEngine()->loadExtension(new PlatesSlimRouterExtension($pimple->get('router')));
     $pimple['renderer'] = $engine;
 }
コード例 #2
0
 private function resolvePageViewPath($path)
 {
     // Do not allow access to view files beginning with an underscore in the filename
     foreach ($path as $item) {
         if (substr($item, 0, 1) === '_') {
             return;
         }
     }
     unset($item);
     $platesEngine = $this->platesRenderer->getEngine();
     // Check if path is a directory and if it is, check for an index view file
     $filesystemPath = $platesEngine->getDirectory() . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $path);
     if (file_exists($filesystemPath) && is_dir($filesystemPath) && $platesEngine->exists('pages/' . implode('/', $path) . '/index')) {
         return 'pages/' . implode('/', $path) . '/index';
     }
     // Else simply check to see if the view exists
     if ($platesEngine->exists('pages/' . implode('/', $path))) {
         return 'pages/' . implode('/', $path);
     }
 }