/**
  * @param array $typoScript
  * @param string $globalThemeName
  * @param array $expected
  *
  * @test
  * @dataProvider propertiesAreUpdatedFromTypoScriptDataProvider
  */
 public function propertiesAreUpdatedFromTypoScript(array $typoScript, $globalThemeName, array $expected)
 {
     $this->typoScriptRepositoryProphecy->getModelConfigurationByScope('FORM', 'themeName')->willReturn($globalThemeName);
     $this->subject->setTypoScript($typoScript);
     $this->assertEquals($expected['prefix'], $this->subject->getPrefix());
     $this->assertEquals($expected['contentElementRendering'], $this->subject->getContentElementRendering());
 }
Exemplo n.º 2
0
 /**
  * Remove a validation rule by key
  *
  * @param string $key
  * @return void
  */
 public function removeRule($key = '')
 {
     unset($this->rules[$this->configuration->getPrefix()][$key]);
 }
Exemplo n.º 3
0
 /**
  * Render TypoScript values
  * There are different variants. It is possible that the TypoScript
  * which we want to render looks like this:
  *
  * array(
  *   'message' => 'TEXT',
  *   'message.' => array(
  *     'value' => 'blah'
  *   )
  * )
  *
  * or in "short syntax" (the wizard writes some syntax partly)
  *
  * array(
  *   'message.' => array(
  *     'value' => 'blah'
  *   )
  * )
  *
  * or it is simply a string.
  *
  * Furthermore we have 2 modes:
  * - contentelement rendering is allowed
  * - or contentelement rendering is not allowed
  *
  * This method will take care of all scenarios and provide some
  * fallbacks.
  * Call this method always in the following way:
  *
  * renderItem(
  *   $typoscript['itemToRender.'],
  *   $typoscript['itemToRender'],
  *   $optionalDefaultMessage
  * )
  *
  * You dont have to handle if is $typoscript['itemToRender.'] is
  * set or not. This function determines this.
  * This allows us to get the value of a TypoScript construct
  * without knowing about "short syntax", only a string, a cObject,
  * if cObject rendering is allowed and so on.
  *
  * If contentelement rendering is allowed:
  *   If $type and $configuration are set
  *   render as an cObject.
  *
  *   If $type is set but $configuration is empty
  *   only return the value of $type.
  *
  *   If $type is empty and $configuration is an array ("short syntax")
  *   render the $configuration as content type TEXT.
  *
  *   If $type is empty and $configuration is a string
  *   render the value of $configuration like
  *   10 = TEXT 10.value = $configuration.
  *
  *   If $type is empty and $configuration is empty
  *   return the $defaultMessage.
  *
  * If contentelement rendering is not allowed:
  *   If $type is set but $configuration is empty
  *   only return the value of $type.
  *
  *   If $type is set and $configuration['value'] isset
  *   return the value of $configuration['value'].
  * 
  *   If $type is set and $configuration['value'] is not set
  *   return the value of $defaultMessage.
  * 
  *   If $type is empty and $configuration['value'] isset
  *   return the value of $configuration['value'].
  * 
  *   If $type is empty and $configuration['value'] is not set
  *   return the value of $defaultMessage.
  *
  * @param mixed $configuration a string or a TypoScript array
  * @param NULL|string $type cObject type or simply a string value
  * @param string $defaultMessage
  * @return string
  */
 public function renderItem($configuration, $type = null, $defaultMessage = '')
 {
     if ($this->configuration->getContentElementRendering()) {
         $renderedMessage = null;
         if ($type !== null) {
             if (is_array($configuration)) {
                 /* Direct cObject rendering */
                 $value = $configuration;
             } else {
                 /* got only a string, no rendering required */
                 $renderedMessage = $type;
             }
         } else {
             if ($configuration !== null) {
                 /* Render the "short syntax"
                  * The wizard write things like label.value
                  * The previous version of EXT:form interpreted this
                  * as a TEXT content object, so we do the same
                  *  */
                 $type = 'TEXT';
                 if (is_array($configuration)) {
                     $value = $configuration;
                 } else {
                     $value['value'] = $configuration;
                 }
             } else {
                 /* return the default message
                  * If $type === NULL and $configuration === NULL
                  * return the default message (if set).
                  * */
                 $renderedMessage = $defaultMessage;
             }
         }
         if ($renderedMessage === null) {
             $renderedMessage = $GLOBALS['TSFE']->cObj->cObjGetSingle($type, $value);
         }
     } else {
         if ($type !== null) {
             if ($configuration !== null) {
                 /* the wizard write things like label.value = some text
                  * so we need the handle that, even content object rendering
                  * is not allowed.
                  *  */
                 if (isset($configuration['value'])) {
                     $renderedMessage = $configuration['value'];
                 } else {
                     $renderedMessage = $defaultMessage;
                 }
             } else {
                 // string, no rendering required
                 $renderedMessage = $type;
             }
         } else {
             $renderedMessage = $defaultMessage;
             if (is_array($configuration) && isset($configuration['value'])) {
                 $renderedMessage = $configuration['value'];
             }
         }
     }
     return $renderedMessage;
 }
Exemplo n.º 4
0
 /**
  * Skip the processing of foreign forms.
  * If there is more than one form on a page
  * we have to be sure that only the submitted form will be
  * processed. On data submission, the extbase action "confirmation" or
  * "process" is called. The detection which form is submitted
  * is done by the form prefix. All forms which do not have any
  * submitted data are skipped and forwarded to the show action.
  *
  * @return void
  */
 protected function skipForeignFormProcessing()
 {
     if (!$this->request->hasArgument($this->configuration->getPrefix()) && !$this->sessionUtility->getSessionData()) {
         $this->forward('show');
     }
 }