Some updates:
[core.git] / framework / main / classes / template / class_
1 <?php
2 // Own namespace
3 namespace CoreFramework\Template\Engine\;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
7
8 /**
9  * A ??? template engine class
10  *
11  * @author              Roland Haeder <webmaster@ship-simu.org>
12  * @version             0.0.0
13 <<<<<<< HEAD:framework/main/classes/template/class_
14  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
15 =======
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
20  *
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.
25  *
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.
30  *
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/>.
33  */
34 class ???TemplateEngine extends BaseTemplateEngine implements CompileableTemplate {
35         /**
36          * Protected constructor
37          *
38          * @return      void
39          */
40         protected function __construct () {
41                 // Call parent constructor
42                 parent::__construct(__CLASS__);
43         }
44
45         /**
46          * Creates an instance of the class TemplateEngine and prepares it for usage
47          *
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
55          *                                                                                      read-protected
56          */
57         public final static function create???TemplateEngine (ManageableApplication $applicationInstance) {
58                 // Get a new instance
59                 $templateInstance = new ???TemplateEngine();
60
61                 // Determine base path
62                 $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . DIRECTORY_SEPARATOR;
63
64                 // Is the base path valid?
65                 if (empty($templateBasePath)) {
66                         // Base path is empty
67                         throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
68                 } elseif (!is_string($templateBasePath)) {
69                         // Is not a string
70                         throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
71                 } elseif (!is_dir($templateBasePath)) {
72                         // Is not a path
73                         throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
74                 } elseif (!is_readable($templateBasePath)) {
75                         // Is not readable
76                         throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
77                 }
78
79                 // Set the base path
80                 $templateInstance->setTemplateBasePath($templateBasePath);
81
82                 // Set template extensions
83                 $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
84                 $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
85
86                 // Absolute output path for compiled templates
87                 $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
88
89                 // Return the prepared instance
90                 return $templateInstance;
91         }
92
93 }