/** * Override template engine by loading plugin templates * * @param string $path * * @return void */ public function setupOverrideForPath($path, $lvl = null, $basedir = true) { $template = new Template(['basedir' => $basedir && $basedir === true ? $this->dir() : $basedir, 'useLayoutBasedir' => $basedir === false ? false : true]); $url = $template->getUrl(); $url = $lvl !== null ? implode('/', array_splice($url, 0, $lvl + 1)) : implode('/', $url); if (!is_array($path)) { $path = [$path]; } foreach ($path as $p) { if ($url == $p) { include_once APP_DIR . 'index.php'; include_once $this->dir() . 'index.php'; $template->loadFromURL(false, $basedir && $basedir === true ? true : false); define('CW_OVERRIDE_TEMPLATE', true); break; } } }