Continued:
[core.git] / framework / main / classes / template / menu / class_MenuTemplateEngine.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Template\Engine;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
7 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
9 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
10 use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
11 use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
12 use Org\Mxchange\CoreFramework\Parser\Parseable;
13 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
14 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
15 use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
16 use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
17
18 // Import SPL stuff
19 use \SplFileInfo;
20 use \UnexpectedValueException;
21
22 /**
23  * A Menu template engine class
24  *
25  * @author              Roland Haeder <webmaster@shipsimu.org>
26  * @version             0.0.0
27  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
28  * @license             GNU GPL 3.0 or any newer version
29  * @link                http://www.shipsimu.org
30  *
31  * This program is free software: you can redistribute it and/or modify
32  * it under the terms of the GNU General Public License as published by
33  * the Free Software Foundation, either version 3 of the License, or
34  * (at your option) any later version.
35  *
36  * This program is distributed in the hope that it will be useful,
37  * but WITHOUT ANY WARRANTY; without even the implied warranty of
38  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
39  * GNU General Public License for more details.
40  *
41  * You should have received a copy of the GNU General Public License
42  * along with this program. If not, see <http://www.gnu.org/licenses/>.
43  */
44 class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTemplate {
45         // Load traits
46         use StackableTrait;
47
48         /**
49          * Main nodes in the XML tree ('menu' is ignored)
50          */
51         private $mainNodes = [
52                 'block-list',
53         ];
54
55         /**
56          * Sub nodes in the XML tree
57          */
58         private $subNodes = [
59                 'entry-list',
60                 'entry',
61                 'entry-id',
62                 'entries-content',
63                 'block-header',
64                 'block-footer',
65                 'footer-id',
66                 'footer-class',
67                 'footer-text',
68                 'block',
69                 'title',
70                 'title-id',
71                 'title-class',
72                 'title-text',
73                 'design',
74                 'text',
75                 'advert',
76                 'anchor',
77                 'anchor-id',
78                 'anchor-text',
79                 'anchor-title',
80                 'anchor-href',
81         ];
82
83         /**
84          * Variables for a menu entry
85          */
86         private $menuEntryVariables = [
87                 // List entry
88                 'entry_id',
89                 // Anchor
90                 'anchor-id',
91                 'anchor-text',
92                 'anchor-title',
93                 'anchor-href',
94         ];
95
96         /**
97          * Variables for a menu block
98          */
99         private $menuBlockVariables = [
100                 // Title
101                 'title_id',
102                 'title_class',
103                 'title_text',
104                 // Content is taken from menuEntries
105                 // Footer
106                 'footer_id',
107                 'footer_class',
108                 'footer_text',
109         ];
110
111         /**
112          * Rendered menu entries
113          */
114         private $menuEntries = [];
115
116         /**
117          * Rendered menu blocks
118          */
119         private $menuBlocks = [];
120
121         /**
122          * Current main node
123          */
124         private $curr = [];
125
126         /**
127          * Content from dependency
128          */
129         private $dependencyContent = [];
130
131         /**
132          * Instance of a menu
133          */
134         private $menuInstance = NULL;
135
136         /**
137          * Protected constructor
138          *
139          * @return      void
140          */
141         private function __construct () {
142                 // Call parent constructor
143                 parent::__construct(__CLASS__);
144         }
145
146         /**
147          * Creates an instance of the class TemplateEngine and prepares it for usage
148          *
149          * @param       $menuInstance                   A RenderableMenu instance
150          * @return      $templateInstance               An instance of TemplateEngine
151          * @throws      UnexpectedValueException                If the found $templateBasePath is empty or not a string
152          * @throws      InvalidDirectoryException       If $templateBasePath is no directory or not found
153          * @throws      BasePathReadProtectedException  If $templateBasePath is
154          *                                                                                      read-protected
155          */
156         public static final function createMenuTemplateEngine (RenderableMenu $menuInstance) {
157                 // Get a new instance
158                 $templateInstance = new MenuTemplateEngine();
159
160                 // Get the application instance from registry
161                 $applicationInstance = ApplicationHelper::getSelfInstance();
162
163                 // Determine base path
164                 $templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
165
166                 // Is the base path valid?
167                 if (empty($templateBasePath)) {
168                         // Base path is empty
169                         throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
170                 } elseif (!is_dir($templateBasePath)) {
171                         // Is not a path
172                         throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
173                 } elseif (!is_readable($templateBasePath)) {
174                         // Is not readable
175                         throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
176                 }
177
178                 // Set the base path
179                 $templateInstance->setTemplateBasePath($templateBasePath);
180
181                 // Set template extensions
182                 $templateInstance->setRawTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('raw_template_extension'));
183                 $templateInstance->setCodeTemplateExtension(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('menu_template_extension'));
184
185                 // Absolute output path for compiled templates
186                 $templateInstance->setCompileOutputPath(sprintf('%s%s/',
187                         $templateBasePath,
188                         FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('compile_output_path')
189                 ));
190
191                 // Set the menu instance
192                 $templateInstance->setMenuInstance($menuInstance);
193
194                 // Init a variable stacker
195                 $stackInstance = ObjectFactory::createObjectByConfiguredName('menu_stacker_class');
196
197                 // Set it
198                 $templateInstance->setStackInstance($stackInstance);
199
200                 // Return the prepared instance
201                 return $templateInstance;
202         }
203
204         /**
205          * Setter for the menu instance
206          *
207          * @param       $menuInstance   A RenderableMenu instance
208          * @return      void
209          */
210         protected final function setMenuInstance (RenderableMenu $menuInstance) {
211                 $this->menuInstance = $menuInstance;
212         }
213
214         /**
215          * Getter for the menu instance
216          *
217          * @return      $menuInstance   A RenderableMenu instance
218          */
219         private final function getMenuInstance () {
220                 return $this->menuInstance;
221         }
222
223         /**
224          * Load a specified menu template into the engine
225          *
226          * @param       $template       The menu template we shall load which is
227          *                                              located in 'menu' by default
228          * @return      void
229          */
230         public function loadMenuTemplate (string $template) {
231                 // Set template type
232                 $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('menu_template_type'));
233
234                 // Load the special template
235                 $this->loadTemplate($template);
236         }
237
238         /**
239          * Getter for current main node
240          *
241          * @return      $currMainNode   Current main node
242          */
243         public final function getCurrMainNode () {
244                 return $this->curr['main_node'];
245         }
246
247         /**
248          * Setter for current main node
249          *
250          * @param       $element                Element name to set as current main node
251          * @return      $currMainNode   Current main node
252          */
253         private final function setCurrMainNode (string $element) {
254                 $this->curr['main_node'] = $element;
255         }
256
257         /**
258          * Getter for main node array
259          *
260          * @return      $mainNodes      Array with valid main node names
261          */
262         public final function getMainNodes () {
263                 return $this->mainNodes;
264         }
265
266         /**
267          * Getter for sub node array
268          *
269          * @return      $subNodes       Array with valid sub node names
270          */
271         public final function getSubNodes () {
272                 return $this->subNodes;
273         }
274
275         /**
276          * Handles the start element of an XML resource
277          *
278          * @param       $resource               XML parser resource (currently ignored)
279          * @param       $element                The element we shall handle
280          * @param       $attributes             All attributes
281          * @return      void
282          * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
283          */
284         public function startElement ($resource, string $element, array $attributes) {
285                 // Initial method name which will never be called...
286                 $methodName = 'initMenu';
287
288                 // Make the element name lower-case
289                 $element = strtolower($element);
290
291                 // Is the element a main node?
292                 //* DEBUG: */ echo "START: &gt;".$element."&lt;<br />\n";
293                 if (in_array($element, $this->getMainNodes())) {
294                         // Okay, main node found!
295                         $methodName = 'start' . StringUtils::convertToClassName($element);
296
297                         // Set it
298                         $this->setCurrMainNode($element);
299                 } elseif (in_array($element, $this->getSubNodes())) {
300                         // Sub node found
301                         $methodName = 'start' . StringUtils::convertToClassName($element);
302                 } elseif ($element != 'menu') {
303                         // Invalid node name found
304                         throw new InvalidXmlNodeException([$this, $element, $attributes], Parseable::EXCEPTION_XML_NODE_UNKNOWN);
305                 }
306
307                 // Call method
308                 //* DEBUG: */ echo "call: ".$methodName."<br />\n";
309                 call_user_func_array(array($this, $methodName), $attributes);
310         }
311
312         /**
313          * Ends the main or sub node by sending out the gathered data
314          *
315          * @param       $resource       An XML resource pointer (currently ignored)
316          * @param       $nodeName       Name of the node we want to finish
317          * @return      void
318          * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
319          */
320         public function finishElement ($resource, string $nodeName) {
321                 // Does this match with current main node?
322                 //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
323                 if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
324                         // Did not match!
325                         throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), Parseable::EXCEPTION_XML_NODE_MISMATCH);
326                 }
327
328                 // Construct method name
329                 $methodName = 'finish' . StringUtils::convertToClassName($nodeName);
330
331                 // Call the corresponding method
332                 //* DEBUG: */ echo "call: ".$methodName."<br />\n";
333                 call_user_func_array(array($this, $methodName), []);
334         }
335
336         /**
337          * Currently not used
338          *
339          * @param       $resource               XML parser resource (currently ignored)
340          * @param       $characters             Characters to handle
341          * @return      void
342          * @todo        Find something useful with this!
343          */
344         public function characterHandler ($resource, string $characters) {
345                 // Trim all spaces away
346                 $characters = trim($characters);
347
348                 // Is this string empty?
349                 if (empty($characters)) {
350                         // Then skip it silently
351                         return;
352                 }
353
354                 // Assign the found characters to variable and use the last entry from
355                 // stack as the name
356                 parent::assignVariable($this->getStackInstance()->getNamed('current_node'), $characters);
357         }
358
359         /**
360          * Handles the template dependency for given node
361          *
362          * @param       $node                                   The node we should load a dependency template
363          * @param       $templateDependency             A template to load to satisfy dependencies
364          * @return      void
365          */
366         private function handleTemplateDependency (string $node, string $templateDependency) {
367                 // Is the template dependency set?
368                 if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) {
369                         // Get a temporay menu template instance
370                         $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this->getMenuInstance()));
371
372                         // Then load it
373                         $templateInstance->loadMenuTemplate($templateDependency);
374
375                         // Parse the XML content
376                         $templateInstance->renderXmlContent();
377
378                         // Save the parsed raw content in our dependency array
379                         $this->dependencyContent[$node] = $templateInstance->getRawTemplateData();
380                 }
381         }
382
383         /**
384          * Intializes the menu
385          *
386          * @param       $templateDependency             A template to load to satisfy dependencies
387          * @return      void
388          * @todo        Add cache creation here
389          */
390         private function initMenu (string $templateDependency = '') {
391                 // Get web template engine
392                 $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(ApplicationHelper::getSelfInstance())));
393
394                 // Handle the dependency template
395                 $this->handleTemplateDependency('menu', $templateDependency);
396
397                 // Push the node name on the stacker
398                 $this->getStackInstance()->pushNamed('current_node', 'menu');
399         }
400
401         /**
402          * Starts the menu entries
403          *
404          * @param       $templateDependency             A template to load to satisfy dependencies
405          * @return      void
406          */
407         private function startEntryList () {
408                 // Push the node name on the stacker
409                 $this->getStackInstance()->pushNamed('current_node', 'entry-list');
410         }
411
412         /**
413          * Starts the menu block header
414          *
415          * @return      void
416          */
417         private function startBlockHeader () {
418                 // Push the node name on the stacker
419                 $this->getStackInstance()->pushNamed('current_node', 'block-header');
420         }
421
422         /**
423          * Starts the menu block footer
424          *
425          * @return      void
426          */
427         private function startBlockFooter () {
428                 // Push the node name on the stacker
429                 $this->getStackInstance()->pushNamed('current_node', 'block-footer');
430         }
431
432         /**
433          * Starts the menu property 'block-list'
434          *
435          * @return      void
436          */
437         private function startBlockList () {
438                 // Push the node name on the stacker
439                 $this->getStackInstance()->pushNamed('current_node', 'block-list');
440         }
441
442         /**
443          * Starts the menu property 'block'
444          *
445          * @return      void
446          */
447         private function startBlock () {
448                 // Push the node name on the stacker
449                 $this->getStackInstance()->pushNamed('current_node', 'block');
450         }
451
452         /**
453          * Starts the menu property 'title'
454          *
455          * @return      void
456          */
457         private function startTitle () {
458                 // Push the node name on the stacker
459                 $this->getStackInstance()->pushNamed('current_node', 'title');
460         }
461
462         /**
463          * Starts the menu property 'title-id'
464          *
465          * @return      void
466          */
467         private function startTitleId () {
468                 // Push the node name on the stacker
469                 $this->getStackInstance()->pushNamed('current_node', 'title-id');
470         }
471
472         /**
473          * Starts the menu property 'title-class'
474          *
475          * @return      void
476          */
477         private function startTitleClass () {
478                 // Push the node name on the stacker
479                 $this->getStackInstance()->pushNamed('current_node', 'title-class');
480         }
481
482         /**
483          * Starts the menu property 'title-text'
484          *
485          * @return      void
486          */
487         private function startTitleText () {
488                 // Push the node name on the stacker
489                 $this->getStackInstance()->pushNamed('current_node', 'title-text');
490         }
491
492         /**
493          * Starts the menu property 'entry'
494          *
495          * @return      void
496          */
497         private function startEntry () {
498                 // Push the node name on the stacker
499                 $this->getStackInstance()->pushNamed('current_node', 'entry');
500         }
501
502         /**
503          * Starts the menu property 'entry-id'
504          *
505          * @return      void
506          */
507         private function startEntryId () {
508                 // Push the node name on the stacker
509                 $this->getStackInstance()->pushNamed('current_node', 'entry-id');
510         }
511
512         /**
513          * Starts the menu property 'anchor'
514          *
515          * @return      void
516          */
517         private function startAnchor () {
518                 // Push the node name on the stacker
519                 $this->getStackInstance()->pushNamed('current_node', 'anchor');
520         }
521
522         /**
523          * Starts the menu property 'anchor-id'
524          *
525          * @return      void
526          */
527         private function startAnchorId () {
528                 // Push the node name on the stacker
529                 $this->getStackInstance()->pushNamed('current_node', 'anchor-id');
530         }
531
532         /**
533          * Starts the menu property 'anchor-text'
534          *
535          * @return      void
536          */
537         private function startAnchorText () {
538                 // Push the node name on the stacker
539                 $this->getStackInstance()->pushNamed('current_node', 'anchor-text');
540         }
541
542         /**
543          * Starts the menu property 'anchor-title'
544          *
545          * @return      void
546          */
547         private function startAnchorTitle () {
548                 // Push the node name on the stacker
549                 $this->getStackInstance()->pushNamed('current_node', 'anchor-title');
550         }
551
552         /**
553          * Starts the menu property 'anchor-href'
554          *
555          * @return      void
556          */
557         private function startAnchorHref () {
558                 // Push the node name on the stacker
559                 $this->getStackInstance()->pushNamed('current_node', 'anchor-href');
560         }
561
562         /**
563          * Starts the menu property 'footer-id'
564          *
565          * @return      void
566          */
567         private function startFooterId () {
568                 // Push the node name on the stacker
569                 $this->getStackInstance()->pushNamed('current_node', 'footer-id');
570         }
571
572         /**
573          * Starts the menu property 'footer-class'
574          *
575          * @return      void
576          */
577         private function startFooterClass () {
578                 // Push the node name on the stacker
579                 $this->getStackInstance()->pushNamed('current_node', 'footer-class');
580         }
581
582         /**
583          * Starts the menu property 'footer-text'
584          *
585          * @return      void
586          */
587         private function startFooterText () {
588                 // Push the node name on the stacker
589                 $this->getStackInstance()->pushNamed('current_node', 'footer-text');
590         }
591
592         /**
593          * Finishes the title node by added another template to the menu
594          *
595          * @return      void
596          */
597         private function finishTitle () {
598                 // Pop the last entry
599                 $this->getStackInstance()->popNamed('current_node');
600         }
601
602         /**
603          * Finishes the title-id node by
604          *
605          * @return      void
606          */
607         private function finishTitleId () {
608                 // Pop the last entry
609                 $this->getStackInstance()->popNamed('current_node');
610         }
611
612         /**
613          * Finishes the title-class node
614          *
615          * @return      void
616          */
617         private function finishTitleClass () {
618                 // Pop the last entry
619                 $this->getStackInstance()->popNamed('current_node');
620         }
621
622         /**
623          * Finishes the title-class node
624          *
625          * @return      void
626          */
627         private function finishTitleText () {
628                 // Pop the last entry
629                 $this->getStackInstance()->popNamed('current_node');
630         }
631
632         /**
633          * Finishes the footer-text node
634          *
635          * @return      void
636          */
637         private function finishFooterText () {
638                 // Pop the last entry
639                 $this->getStackInstance()->popNamed('current_node');
640         }
641
642         /**
643          * Finishes the footer-class node
644          *
645          * @return      void
646          */
647         private function finishFooterClass () {
648                 // Pop the last entry
649                 $this->getStackInstance()->popNamed('current_node');
650         }
651
652         /**
653          * Finishes the footer-id node
654          *
655          * @return      void
656          */
657         private function finishFooterId () {
658                 // Pop the last entry
659                 $this->getStackInstance()->popNamed('current_node');
660         }
661
662         /**
663          * Finishes the anchor-href node
664          *
665          * @return      void
666          */
667         private function finishAnchorHref () {
668                 // Pop the last entry
669                 $this->getStackInstance()->popNamed('current_node');
670         }
671
672         /**
673          * Finishes the anchor-title node
674          *
675          * @return      void
676          */
677         private function finishAnchorTitle () {
678                 // Pop the last entry
679                 $this->getStackInstance()->popNamed('current_node');
680         }
681
682         /**
683          * Finishes the anchor-text node
684          *
685          * @return      void
686          */
687         private function finishAnchorText () {
688                 // Pop the last entry
689                 $this->getStackInstance()->popNamed('current_node');
690         }
691
692         /**
693          * Finishes the anchor-id node
694          *
695          * @return      void
696          */
697         private function finishAnchorId () {
698                 // Pop the last entry
699                 $this->getStackInstance()->popNamed('current_node');
700         }
701
702         /**
703          * Finishes the anchor node
704          *
705          * @return      void
706          */
707         private function finishAnchor () {
708                 // Pop the last entry
709                 $this->getStackInstance()->popNamed('current_node');
710         }
711
712         /**
713          * Finishes the entry-id node
714          *
715          * @return      void
716          */
717         private function finishEntryId () {
718                 // Pop the last entry
719                 $this->getStackInstance()->popNamed('current_node');
720         }
721
722         /**
723          * Finishes the entry node
724          *
725          * @return      void
726          */
727         private function finishEntry () {
728                 // Pop the last entry
729                 $this->getStackInstance()->popNamed('current_node');
730
731                 // Render this menu entry
732                 $this->renderMenuEntry();
733         }
734
735         /**
736          * Finishes the block node
737          *
738          * @return      void
739          */
740         private function finishBlock () {
741                 // Pop the last entry
742                 $this->getStackInstance()->popNamed('current_node');
743
744                 // Render this menu block
745                 $this->renderMenuBlock();
746         }
747
748         /**
749          * Finishes the block-list node
750          *
751          * @return      void
752          */
753         private function finishBlockList () {
754                 // Pop the last entry
755                 $this->getStackInstance()->popNamed('current_node');
756         }
757
758         /**
759          * Finishes the menu entries
760          *
761          * @return      void
762          */
763         private function finishEntryList () {
764                 // Pop the last entry
765                 $this->getStackInstance()->popNamed('current_node');
766         }
767
768         /**
769          * Finishes the menu block header
770          *
771          * @return      void
772          */
773         private function finishBlockHeader () {
774                 // Pop the last entry
775                 $this->getStackInstance()->popNamed('current_node');
776         }
777
778         /**
779          * Finishes the menu block footer
780          *
781          * @return      void
782          */
783         private function finishBlockFooter () {
784                 // Pop the last entry
785                 $this->getStackInstance()->popNamed('current_node');
786         }
787
788         /**
789          * Finishes the menu
790          *
791          * @return      void
792          */
793         private function finishMenu () {
794                 // Pop the last entry
795                 $this->getStackInstance()->popNamed('current_node');
796         }
797
798         /**
799          * Renders this menu entry, as every block all variables got overwritten
800          * with data from next entry.
801          *
802          * @return      void
803          */
804         private function renderMenuEntry () {
805                 // Load menu entry template
806                 $this->getTemplateInstance()->loadCodeTemplate('menu_entry');
807
808                 // Copy all variables over to it
809                 foreach ($this->menuEntryVariables as $variableName) {
810                         // Copy variable
811                         $variableValue = $this->readVariable($variableName);
812
813                         // Is the key 'anchor-href'?
814                         if ($variableName == 'anchor-href') {
815                                 // Expand variable with URL then
816                                 $variableValue = '{?base_url?}/' . $variableValue;
817                         }
818
819                         // ... into the instance
820                         $this->getTemplateInstance()->assignVariable($variableName, $variableValue);
821                 }
822
823                 // Compile template + variables
824                 $this->getTemplateInstance()->compileTemplate();
825                 $this->getTemplateInstance()->compileVariables();
826
827                 // Remember it here
828                 $this->menuEntries[$this->readVariable('entry_id')] = $this->getTemplateInstance()->getRawTemplateData();
829         }
830
831         /**
832          * Renders this menu block, as next block all data is overwritten with
833          * next block.
834          *
835          * @return      void
836          */
837         private function renderMenuBlock () {
838                 // Init block content
839                 $blockContent = implode('', $this->menuEntries);
840
841                 // Load menu entry template
842                 $this->getTemplateInstance()->loadCodeTemplate('menu_block');
843
844                 // Copy all variables over to it
845                 foreach ($this->menuBlockVariables as $variableName) {
846                         // Copy variable
847                         $variableValue = $this->readVariable($variableName);
848
849                         // ... into the instance
850                         $this->getTemplateInstance()->assignVariable($variableName, $variableValue);
851                 }
852
853                 // Assign block content
854                 $this->getTemplateInstance()->assignVariable('block_content', $blockContent);
855
856                 // Compile template + variables
857                 $this->getTemplateInstance()->compileTemplate();
858                 $this->getTemplateInstance()->compileVariables();
859
860                 // Remember it here
861                 array_push($this->menuBlocks, $this->getTemplateInstance()->getRawTemplateData());
862
863                 // Reset rendered menu entries array
864                 $this->menuEntries = [];
865         }
866
867         /**
868          * "Getter" for menu content
869          *
870          * @return      $menuContent    Returned menu content
871          */
872         public function getMenuContent () {
873                 // Implode menuBlocks
874                 $menuContent = implode('', $this->menuBlocks);
875
876                 // Clean variable
877                 $this->menuBlocks = [];
878
879                 // And return it
880                 return $menuContent;
881         }
882
883         /**
884          * Getter for menu cache file instance
885          *
886          * @return      $fileInstance   Full-qualified file name of the menu cache
887          */
888         public function getMenuCacheFile () {
889                 // Get the application instance from registry
890                 $applicationInstance = ApplicationHelper::getSelfInstance();
891
892                 // Get the file instance ready
893                 $fileInstance = new SplFileInfo(sprintf('%s%smenus/_cache/%s.%s',
894                         FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path'),
895                         $applicationInstance->getAppShortName(),
896                         md5(
897                                 $this->getMenuInstance()->getMenuName() . ':' .
898                                 $this->__toString() . ':' .
899                                 $this->getMenuInstance()->__toString()
900                         ),
901                         $this->getMenuInstance()->getMenuType()
902                 ));
903
904                 // Return it
905                 return $fileInstance;
906         }
907
908 }