3 namespace CoreFramework\Template\Engine\;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
9 * A ??? template engine class
11 * @author Roland Haeder <webmaster@ship-simu.org>
13 <<<<<<< HEAD:framework/main/classes/template/class_
14 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
17 >>>>>>> Some updates::inc/main/classes/template/class_
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.ship-simu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 class ???TemplateEngine extends BaseTemplateEngine implements CompileableTemplate {
36 * Protected constructor
40 protected function __construct () {
41 // Call parent constructor
42 parent::__construct(__CLASS__);
46 * Creates an instance of the class TemplateEngine and prepares it for usage
48 * @param $applicationInstance A manageable application
49 * @return $templateInstance An instance of TemplateEngine
50 * @throws BasePathIsEmptyException If the provided $templateBasePath is empty
51 * @throws InvalidBasePathStringException If $templateBasePath is no string
52 * @throws BasePathIsNoDirectoryException If $templateBasePath is no
53 * directory or not found
54 * @throws BasePathReadProtectedException If $templateBasePath is
57 public final static function create???TemplateEngine (ManageableApplication $applicationInstance) {
59 $templateInstance = new ???TemplateEngine();
61 // Determine base path
62 $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . DIRECTORY_SEPARATOR;
64 // Is the base path valid?
65 if (empty($templateBasePath)) {
67 throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
68 } elseif (!is_string($templateBasePath)) {
70 throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
71 } elseif (!is_dir($templateBasePath)) {
73 throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
74 } elseif (!is_readable($templateBasePath)) {
76 throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
80 $templateInstance->setTemplateBasePath($templateBasePath);
82 // Set template extensions
83 $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
84 $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
86 // Absolute output path for compiled templates
87 $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
89 // Return the prepared instance
90 return $templateInstance;