public function __construct($view, \Admin\Core\Helper $helper, \TYPO3\FLOW3\Object\ObjectManagerInterface $objectManager)
 {
     $this->helper = $helper;
     $this->view = $view;
     $this->objectManager = $objectManager;
     $partial = $this->getName();
     $replacements = array("@partial" => $partial, "@package" => $this->helper->getPackageByClassName(get_class($this)), "@being" => \Admin\Core\Helper::getShortName(\Admin\Core\API::get("being")), "@action" => $partial);
     $template = $this->helper->getPathByPatternFallbacks("DashboardWidgets", $replacements);
     $this->view->setTemplatePathAndFilename($template);
     $this->initializeWidget();
 }
Ejemplo n.º 2
0
 public function setTemplate($action)
 {
     $replacements = array("@action" => ucfirst($action), "@variant" => "Default", "@package" => "Admin");
     if (!empty($this->being)) {
         if (class_exists($this->being, false)) {
             $replacements["@package"] = $this->helper->getPackageByClassName($this->being) ? $this->helper->getPackageByClassName($this->being) : "Admin";
             $replacements["@being"] = \Admin\Core\Helper::getShortName($this->being);
             $being = $this->helper->getBeing($this->being);
             $replacements["@variant"] = $being->variant->getVariant($action);
         }
     }
     if ($this->request->hasArgument("variant")) {
         $replacements["@variant"] = $this->request->getArgument("variant");
     }
     $cache = $this->cacheManager->getCache('Admin_TemplateCache');
     $identifier = str_replace(".", "_", implode("-", $replacements));
     $noTemplate = false;
     if (!$cache->has($identifier)) {
         try {
             $template = $this->helper->getPathByPatternFallbacks("Views", $replacements);
         } catch (\Exception $e) {
             $noTemplate = true;
         }
         if (!$noTemplate) {
             $cache->set($identifier, $template);
         }
     } else {
         $template = $cache->get($identifier);
     }
     if (!$noTemplate) {
         $this->view->setTemplatePathAndFilename($template);
         if ($this->request->hasArgument("being")) {
             $meta["being"]["identifier"] = $this->request->getArgument("being");
             $meta["being"]["name"] = $this->request->getArgument("being");
             \Admin\Core\API::set("package", $replacements["@package"]);
         }
     }
 }