Ejemplo n.º 1
0
 /**
  * Get the option value for an object
  *
  * @param mixed $valueElement
  * @return string
  */
 protected function getOptionValueScalar($valueElement)
 {
     if (is_object($valueElement)) {
         if ($this->hasArgument('optionValueField')) {
             return \TYPO3\Fluid\Reflection\ObjectAccess::getPropertyPath($valueElement, $this->arguments['optionValueField']);
         } else {
             if ($this->persistenceManager->getBackend()->getIdentifierByObject($valueElement) !== NULL) {
                 return $this->persistenceManager->getBackend()->getIdentifierByObject($valueElement);
             } else {
                 return (string) $valueElement;
             }
         }
     } else {
         return $valueElement;
     }
 }
Ejemplo n.º 2
0
 /**
  * Groups the given array by the specified groupBy property.
  *
  * @param array $elements The array / traversable object to be grouped
  * @param string $groupBy Group by this property
  * @return array The grouped array in the form array('keys' => array('key1' => [key1value], 'key2' => [key2value], ...), 'values' => array('key1' => array([key1value] => [element1]), ...), ...)
  */
 protected function groupElements(array $elements, $groupBy)
 {
     $groups = array('keys' => array(), 'values' => array());
     foreach ($elements as $key => $value) {
         if (is_array($value)) {
             $currentGroupIndex = isset($value[$groupBy]) ? $value[$groupBy] : NULL;
         } elseif (is_object($value)) {
             $currentGroupIndex = \TYPO3\Fluid\Reflection\ObjectAccess::getPropertyPath($value, $groupBy);
         } else {
             throw new \TYPO3\Fluid\Core\ViewHelper\Exception('GroupedForViewHelper only supports multi-dimensional arrays and objects', 1253120365);
         }
         $currentGroupKeyValue = $currentGroupIndex;
         if (is_object($currentGroupIndex)) {
             $currentGroupIndex = spl_object_hash($currentGroupIndex);
         }
         $groups['keys'][$currentGroupIndex] = $currentGroupKeyValue;
         $groups['values'][$currentGroupIndex][$key] = $value;
     }
     return $groups;
 }
Ejemplo n.º 3
0
 /**
  * Get the current property of the object bound to this form.
  *
  * @return mixed Value
  */
 protected function getPropertyValue()
 {
     $formObject = $this->viewHelperVariableContainer->get('TYPO3\\Fluid\\ViewHelpers\\FormViewHelper', 'formObject');
     $propertyName = $this->arguments['property'];
     if (is_array($formObject)) {
         return isset($formObject[$propertyName]) ? $formObject[$propertyName] : NULL;
     }
     return \TYPO3\Fluid\Reflection\ObjectAccess::getPropertyPath($formObject, $propertyName);
 }