FOF30\Factory\BasicFactory::viewFinder PHP Méthode

viewFinder() public méthode

The default configuration is: Look for .php, .blade.php files; default layout "default"; no default subtemplate; look only for the specified view; do NOT fall back to the default layout or subtemplate; look for templates ONLY in site or admin, depending on where we're running from
public viewFinder ( View $view, array $config = [] ) : mixed
$view FOF30\View\View The view this view template finder will be attached to
$config array Configuration variables for the object
Résultat mixed
    public function viewFinder(View $view, array $config = array())
    {
        // Initialise the configuration with the default values
        $defaultConfig = array('extensions' => array('.php', '.blade.php'), 'defaultLayout' => 'default', 'defaultTpl' => '', 'strictView' => true, 'strictTpl' => true, 'strictLayout' => true, 'sidePrefix' => 'auto');
        $config = array_merge($defaultConfig, $config);
        // Apply fof.xml overrides
        $appConfig = $this->container->appConfig;
        $key = "views." . ucfirst($view->getName()) . ".config";
        $fofXmlConfig = array('extensions' => $appConfig->get("{$key}.templateExtensions", $config['extensions']), 'strictView' => $appConfig->get("{$key}.templateStrictView", $config['strictView']), 'strictTpl' => $appConfig->get("{$key}.templateStrictTpl", $config['strictTpl']), 'strictLayout' => $appConfig->get("{$key}.templateStrictLayout", $config['strictLayout']), 'sidePrefix' => $appConfig->get("{$key}.templateLocation", $config['sidePrefix']));
        $config = array_merge($config, $fofXmlConfig);
        // Create the new view template finder object
        return new ViewTemplateFinder($view, $config);
    }

Usage Example

Exemple #1
0
 /**
  * Creates a view template finder object for a specific View.
  *
  * The default configuration is:
  * Look for .php, .blade.php files; default layout "default"; no default subtemplate;
  * look for both pluralised and singular views; fall back to the default layout without subtemplate;
  * look for templates in both site and admin
  *
  * @param   View  $view   The view this view template finder will be attached to
  * @param   array $config Configuration variables for the object
  *
  * @return  mixed
  */
 public function viewFinder(View $view, array $config = array())
 {
     // Initialise the configuration with the default values
     $defaultConfig = array('extensions' => array('.php', '.blade.php'), 'defaultLayout' => 'default', 'defaultTpl' => '', 'strictView' => false, 'strictTpl' => false, 'strictLayout' => false, 'sidePrefix' => 'any');
     $config = array_merge($defaultConfig, $config);
     return parent::viewFinder($view, $config);
 }
All Usage Examples Of FOF30\Factory\BasicFactory::viewFinder