Ejemplo n.º 1
0
 /**
  * Constructs a template object, initializing the source data object and the template access path
  *
  * @param $object object
  * @param $template_file string full path to template file
  * @param $feature_name string feature name
  */
 public function __construct($object = null, $template_file = null, $feature_name = null)
 {
     $this->functions = $this->newFunctions();
     if (isset($feature_name)) {
         $this->feature = $feature_name;
         if (!isset($template_file)) {
             $template_file = Engine::getTemplateFile(get_class($object), [$feature_name]);
         }
     }
     if (isset($object)) {
         array_unshift($this->var_names, 'root');
         array_unshift($this->objects, $object);
     }
     if (isset($template_file)) {
         $this->path = substr($template_file, 0, strrpos($template_file, SL));
         $this->content = file_get_contents($template_file);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $parameters   array
  * @param $form         array
  * @param $files        array
  * @param $class_name   string
  * @param $feature_name string
  * @return string
  */
 public function run($parameters, $form, $files, $class_name, $feature_name)
 {
     $feature_names = isset($parameters[Feature::FEATURE]) && $parameters[Feature::FEATURE] !== $feature_name ? [$parameters[Feature::FEATURE], $feature_name] : [$feature_name];
     $template_file = Engine::getTemplateFile($class_name, $feature_names, isset($parameters[Template::TEMPLATE]) ? $parameters[Template::TEMPLATE] : null);
     return self::executeTemplate($template_file, $parameters, $feature_name);
 }