/** * Read template file into content string and return it * * @return string */ public function content($parsePHP = true) { if (!$this->_templateContent) { $this->exists(true); $vfile = $this->path() . $this->fileName(); // Include() and parse PHP code if ($parsePHP) { ob_start(); // Use closure to get isolated scope $view = $this; $vars = $this->vars(); $render = function ($templateFile) use($view, $vars) { extract($vars); require $templateFile; return ob_get_clean(); }; $templateContent = $render($vfile); } else { // Just get raw file contents $templateContent = file_get_contents($vfile); } $templateContent = trim($templateContent); // Wrap template content in layout if ($this->layout()) { // Ensure layout doesn't get rendered recursively self::$_config['auto_layout'] = false; // New template for layout $layout = new self($this->layout()); // Set layout path if specified if (isset(self::$_config['path_layouts'])) { $layout->path(self::$_config['path_layouts']); } // Pass all locally set variables to layout $layout->set($this->_vars); // Set main yield content block $layout->set('yield', $templateContent); // Get content $templateContent = $layout->content($parsePHP); } $this->_templateContent = $templateContent; } return $this->_templateContent; }
protected static function directorysStatic($name = "") { $self = new self(); if ($self->isDir($name)) { $files = array(); $r = scandir($self->path($name)); foreach ($r as $key => $value) { if (is_dir($self->storagePath . "/" . $value)) { $files[] = $value; } } return $files; } else { throw new \InvalidArgumentException("There is no directory calls {$name}"); } }