public function __construct($tpl = '', Bundle $assetsHandler = null) { parent::__construct($tpl, $assetsHandler); if (!class_exists('\\Twig_Autoloader')) { throw new \Exception("Missing Vendor: Twig Template Engine library is not installed on project!\n" . "You can solve this adding the missing vendor to composer.json and executing 'composer.phar update'"); } require_once 'twig/twig/lib/Twig/Autoloader.php'; \Twig_Autoloader::register(); }
public function assign($name, $value = null) { parent::assign($name, $value); if (is_string($name)) { return $this->smarty->assign($name, $value); } if (is_array($name)) { return $this->assignFromArray($name); } throw new \InvalidArgumentException("Invalid data type for key, '" . gettype($name) . "' given."); }
public function __construct($tpl = '') { parent::__construct($tpl); require_once "crodas/Haanga/lib/Haanga.php"; }
public function __construct($tpl = '') { parent::__construct($tpl); }
/** * This method handle a Meta-UI * * @param array $data data for view object * @param \Alchemy\Annotation\Annotation $annotation Annotation object containing the information of @ServeUi annotation * @param \Alchemy\Mvc\View $targetView A existent view object (is was defined previously) * @param \Alchemy\Component\Http\Request $request Request object containing the current request * @return \Alchemy\Mvc\ViewInterface */ protected function handleMetaUi(array $data, $annotation, $targetView, Request $request = null) { // check if a @ServeUi definition exists on action's annotations if (empty($annotation)) { return $targetView; // @serveUi annotation not found, just return to break ui handling } // prepare annotation object $annotation->prepare(); // getting configuration $metaPath = $this->config->get('app.meta_dir'); $elementName = $annotation->name; $metaFile = $annotation->metaFile; $attributes = $annotation->attributes; $layout = $annotation->layout; // setting uiEngine Object // if any layout wasn't specified on action's annotation if (empty($layout)) { // read defaults bundles from configuration for desktop & mobile platform if ($request->isMobile()) { if ($request->isIpad()) { // for ipad device $layout = $this->config->get('layout.mobile'); } else { $layout = $this->config->get('layout.mobile'); } } else { $layout = $this->config->get('layout.default'); } } //var_dump($layout); die; //$this->uiEngine->setBundleExtensionDir(); $this->uiEngine->setTargetBundle($layout); $this->uiEngine->setMetaFile($metaPath . DS . $annotation->metaFile); // tell to uiEngine object build the ui requested $elementData = array(); if (array_key_exists($elementName, $data) && is_array($data[$elementName])) { $elementData = $data[$elementName]; } $element = $this->uiEngine->build($elementData, $attributes); //$element->setAttribute($attributes); if (!empty($annotation->id)) { $element->setId($annotation->id); } $elementType = $element->getXtype(); $elementId = $element->getId(); $elementCollection = new \StdClass(); $elementCollection->{$elementId} = $element; $targetView->assign($elementType, $elementCollection); $template = empty($targetView) ? $element->getXtype() . '_page' : $element->getXtype(); //var_dump($template, file_exists($template), $this->config->get('templating.default_engine')); try { // creating a new view object $view = $this->createView($template, $data); $view->assign($element->getXtype(), $element); // if the target view was not defined before return the new view object created. if (empty($targetView)) { return $view; } // a target view exists, just set the generated ui to target view $targetView->setUiElement($element->getId(), $view->getOutput()); $elementObject = new \StdClass(); $elementObject->{$elementId} = $element; $targetView->set($element->getXtype(), $elementObject); } catch (\Exception $e) { // skip exception for template not found if ($e->getCode() !== 404) { throw $e; } } return $targetView; }