setExtensions() публичный Метод

Set the list of view template extensions
public setExtensions ( array $extensions ) : void
$extensions array
Результат void
Пример #1
0
 /**
  * Constructor.
  *
  * The $config array can contain the following overrides:
  * name           string  The name of the view (defaults to the view class name)
  * template_path  string  The path of the layout directory
  * layout         string  The layout for displaying the view
  * viewFinder     ViewTemplateFinder  The object used to locate view templates in the filesystem
  * viewEngineMap  array   Maps view template extensions to view engine classes
  *
  * @param   Container $container  The container we belong to
  * @param   array     $config     The configuration overrides for the view
  *
  * @return  View
  */
 public function __construct(Container $container, array $config = array())
 {
     $this->container = $container;
     $this->config = $config;
     // Get the view name
     if (isset($this->config['name'])) {
         $this->name = $this->config['name'];
     }
     $this->name = $this->getName();
     // Set the default template search path
     if (array_key_exists('template_path', $this->config)) {
         // User-defined dirs
         $this->setTemplatePath($this->config['template_path']);
     } else {
         $this->setTemplatePath($this->container->thisPath . '/View/' . ucfirst($this->name) . '/tmpl');
     }
     // Set the layout
     if (array_key_exists('layout', $this->config)) {
         $this->setLayout($this->config['layout']);
     }
     // Apply the viewEngineMap
     if (isset($config['viewEngineMap'])) {
         if (!is_array($config['viewEngineMap'])) {
             $temp = explode(',', $config['viewEngineMap']);
             $config['viewEngineMap'] = array();
             foreach ($temp as $assignment) {
                 $parts = explode('=>', $assignment, 2);
                 if (count($parts) != 2) {
                     continue;
                 }
                 $parts = array_map(function ($x) {
                     return trim($x);
                 }, $parts);
                 $config['viewEngineMap'][$parts[0]] = $parts[1];
             }
         }
         $this->viewEngineMap = array_merge($this->viewEngineMap, $config['viewEngineMap']);
     }
     // Set the ViewFinder
     $this->viewFinder = $this->container->factory->viewFinder($this);
     if (isset($config['viewFinder']) && !empty($config['viewFinder']) && is_object($config['viewFinder']) && $config['viewFinder'] instanceof ViewTemplateFinder) {
         $this->viewFinder = $config['viewFinder'];
     }
     // Apply the registered view template extensions to the view finder
     $this->viewFinder->setExtensions(array_keys($this->viewEngineMap));
     // Apply the base URL
     $this->baseurl = $this->container->platform->URIbase();
 }