Example #1
0
 /**
  * Parse this node.
  * Set passed arguments and any optional arguments not passed to their
  * defaults, then render the children of the return definition.
  *
  * @param Context $pcontext the context in which this node is parsed
  * @return array the parsed node
  */
 public function parse($pcontext)
 {
     $return = $this;
     $context = new Context($pcontext);
     $children = [];
     foreach ($context->getContent() as $child) {
         $child->parent = $this->parent;
         $ctx = new Context($pcontext->parent);
         $ctx->variables = $pcontext->variables;
         $children = array_merge($children, $child->parse($ctx));
     }
     return $children;
 }
 /**
  * @brief Make the module compatible 1.4/1.5
  */
 private function _initContext()
 {
     /* Backward compatibility */
     require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
     $this->context->smarty->assign('base_dir', __PS_BASE_URI__);
     $this->dParams['base_dir'] = __PS_BASE_URI__;
     if (class_exists('Context') && function_exists('getContent')) {
         $this->context = Context::getContent();
     } else {
         global $smarty, $cookie;
         $this->context = new StdClass();
         $this->context->smarty = $smarty;
         $this->context->cookie = $cookie;
         $this->context->shop = new StdClass();
         $this->context->shop->id = 1;
         $this->context->shop->id_group_shop = 1;
     }
     $this->_loadConfiguration();
 }
Example #3
0
 public function testSettingEmptyContentIfParamMatchesName()
 {
     $context = new Context('test');
     $content = array();
     $context->setContent('test', $content);
     $actual = $context->getContent('test');
     $this->assertEquals(array(), $actual);
 }
Example #4
0
 /**
  * Replace content in the syntax {content}
  * @param array $matches Given from preg_replace_callback
  * @return string The content needed for replacing
  */
 private function _replaceContent($matches)
 {
     $name = $matches[1];
     return $this->_context->getContent($name);
 }