コード例 #1
0
 /**
  * @test
  */
 public function renderUsesTheNodeArgumentIfSet()
 {
     $this->templateVariables = array('someProperty' => 'somePropertyValue');
     $this->tagBuilder->expects($this->once())->method('render');
     $this->injectDependenciesIntoViewHelper($this->editableViewHelper);
     $this->editableViewHelper->render('someProperty', 'div', $this->mockNode);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function render($property, $tag = 'div', NodeInterface $node = NULL)
 {
     if ($node === NULL) {
         $node = $this->getNodeFromTypoScriptContext();
     }
     $propertyConfiguration = $node->getNodeType()->getProperties();
     $properties = ObjectAccess::getPropertyPath($node, 'properties');
     $dynamicPropertyPrefix = $this->settings['propertyPrefix'];
     // Add dynamic properties to context which are missing
     $addedProperties = array();
     foreach ($propertyConfiguration as $propertyName => $propertyConfig) {
         if (strpos($propertyName, $dynamicPropertyPrefix) === 0 && !$this->templateVariableContainer->exists($propertyName)) {
             $value = array_key_exists($propertyName, $properties) ? $properties[$propertyName] : $propertyConfig['defaultValue'];
             $this->templateVariableContainer->add($propertyName, $value);
             $addedProperties[] = $propertyName;
         }
     }
     $output = parent::render($property, $tag, $node);
     // Remove dynamic properties again
     foreach ($addedProperties as $propertyName) {
         $this->templateVariableContainer->remove($propertyName);
     }
     return $output;
 }