Example #1
0
 private function getTagValue(Tag $tag, Context $context)
 {
     switch ($tag->getName()) {
         case 'include':
             $filename = $context->getTheme()->getBasePath() . '/code/' . $tag->getAttribute('name');
             $value = file_get_contents($filename);
             $value = $this->processTags($value, $context);
             break;
         case 'block':
             $content = $context->getContentByBlockName($tag->getAttribute('name'));
             if (!$content) {
                 throw new RuntimeException("Can't find content by name: " . $tag->getAttribute('name'));
             }
             $block = $context->getTheme()->getBlockByName($tag->getAttribute('name'));
             if (!$block) {
                 throw new RuntimeException("Can't find block by name: " . $tag->getAttribute('name'));
             }
             $value = $this->renderContent($block, $content, $context);
             break;
         default:
             throw new RuntimeException("Unknown tag: " . $tag->getName());
             break;
     }
     return $value;
 }