Exemplo n.º 1
0
 /**
  * @param  \SplFileInfo[]   $templates
  * @param $resourcesPath
  * @param $moduleCode
  * @throws \Exception
  * @throws \SmartyException
  */
 protected function processModule($templates, $resourcesPath, $modulePath, $moduleCode)
 {
     foreach ($templates as $template) {
         $fileName = str_replace("__MODULE__", $moduleCode, $template->getFilename());
         $fileName = str_replace("FIX", "", $fileName);
         $relativePath = str_replace($resourcesPath, "", $template->getPath() . DS);
         $completeFilePath = $modulePath . $relativePath . DS . $fileName;
         $isFix = false !== strpos($template->getFilename(), "FIX");
         // Expect special rule for Module\Module
         $isModuleClass = $modulePath . $relativePath . DS . $moduleCode . ".php" === $completeFilePath;
         if ($isFix && !file_exists($completeFilePath) || !$isFix) {
             if ($isModuleClass && is_file($completeFilePath)) {
                 $caught = false;
                 try {
                     $reflection = new \ReflectionClass("{$moduleCode}\\{$moduleCode}");
                 } catch (\ReflectionException $e) {
                     $caught = true;
                     // The class is not valid
                 }
                 if (!$caught && $reflection->hasConstant("MESSAGE_DOMAIN")) {
                     continue;
                     // If the class already have the constant, don't override it
                 }
             }
             $fetchedTemplate = $this->parser->fetch($template->getRealPath());
             $this->writeFile($completeFilePath, $fetchedTemplate, true, true);
         }
     }
 }
Exemplo n.º 2
0
 protected function render($template, $data = [])
 {
     foreach ($data as $key => $value) {
         $this->smarty->assign($key, $value);
     }
     return $this->smarty->fetch(__DIR__ . DS . "fixtures" . DS . $template);
 }
Exemplo n.º 3
0
 protected function internalRender($resourceType, $resourceContent, array $data)
 {
     foreach ($data as $key => $value) {
         $this->smarty->assign($key, $value);
     }
     return $this->smarty->fetch(sprintf("%s:%s", $resourceType, $resourceContent));
 }
Exemplo n.º 4
0
 /**
  * @param  \TheliaStudio\Parser\Entity\Table $table
  * @param  \SplFileInfo[]                    $templates
  * @param $resourcesPath
  * @param $moduleCode
  * @throws \Exception
  * @throws \SmartyException
  */
 protected function processTemplate(Table $table, $templates, $resourcesPath, $moduleCode)
 {
     $this->parser->assign("table", $table);
     foreach ($templates as $template) {
         $fetchedTemplate = $this->parser->fetch($template->getRealPath());
         $fileName = str_replace("__TABLE__", str_replace("_", "-", $table->getRawTableName()), $template->getFilename());
         $relativePath = str_replace($resourcesPath, "", $template->getPath() . DS);
         $completeFilePath = THELIA_MODULE_DIR . $moduleCode . DS . $relativePath . DS . $fileName;
         $this->writeFile($completeFilePath, $fetchedTemplate, false, true);
     }
 }
Exemplo n.º 5
0
 /**
  * @param Table          $table
  * @param \SplFileInfo[] $templates
  * @param $resourcesPath
  * @param $moduleCode
  */
 protected function processPhp(Table $table, $templates, $resourcesPath, $moduleCode, $modulePath)
 {
     $this->parser->assign("table", $table);
     foreach ($templates as $template) {
         $fileName = str_replace("__TABLE__", $table->getTableName(), $template->getFilename());
         $fileName = str_replace("FIX", "", $fileName);
         $relativePath = str_replace($resourcesPath, "", $template->getPath() . DS);
         $completeFilePath = $modulePath . DS . $relativePath . DS . $fileName;
         $isFix = false !== strpos($template->getFilename(), "FIX");
         $isI18n = false !== strpos($template->getFilename(), "I18n");
         if (($isFix && !file_exists($completeFilePath) || !$isFix) && ($isI18n && $table->hasI18nBehavior() || !$isI18n)) {
             $fetchedTemplate = $this->parser->fetch($template->getRealPath());
             $this->writeFile($completeFilePath, $fetchedTemplate, true, true);
         }
     }
 }
Exemplo n.º 6
0
 protected function generateTemplates($resourcesPath, $modulePath, $moduleCode)
 {
     $templates = $this->findInPath($resourcesPath, "/__CONFIG_FORM__.*\\.html/");
     $previousLeft = $this->parser->left_delimiter;
     $previousRight = $this->parser->right_delimiter;
     $this->parser->left_delimiter = '[{';
     $this->parser->right_delimiter = '}]';
     /** @var \SplFileInfo $template */
     foreach ($templates as $template) {
         $fetchedTemplate = $this->parser->fetch($template->getRealPath());
         $relativePath = str_replace($resourcesPath, '', $template->getRealPath());
         $relativePath = str_replace("__CONFIG_FORM__", strtolower($moduleCode), $relativePath);
         $fullPath = $modulePath . $relativePath;
         $this->writeFile($fullPath, $fetchedTemplate, false, true);
     }
     $this->parser->left_delimiter = $previousLeft;
     $this->parser->right_delimiter = $previousRight;
 }
Exemplo n.º 7
0
 protected function render($template)
 {
     return $this->smarty->fetch(__DIR__ . DS . "fixtures" . DS . $template);
 }