コード例 #1
0
 /**
  * Renders the TypoScript object in the given TypoScript setup path.
  *
  * @param string $typoscriptObjectPath the TypoScript setup path of the TypoScript object to render
  * @param mixed $data the data to be used for rendering the cObject. Can be an object, array or string. If this argument is not set, child nodes will be used
  * @param string $currentValueKey
  * @return string the content of the rendered TypoScript object
  * @author Bastian Waidelich <*****@*****.**>
  * @author Niels Pardon <*****@*****.**>
  */
 public function render($typoscriptObjectPath, $data = NULL, $currentValueKey = NULL)
 {
     if ($data === NULL) {
         $data = $this->renderChildren();
     }
     $currentValue = NULL;
     if (is_object($data)) {
         $data = Tx_Extbase_Reflection_ObjectAccess::getAccessibleProperties($data);
     } elseif (is_string($data)) {
         $currentValue = $data;
         $data = array($data);
     }
     $this->contentObject->start($data);
     if ($currentValue !== NULL) {
         $this->contentObject->setCurrentVal($currentValue);
     } elseif ($currentValueKey !== NULL && isset($data[$currentValueKey])) {
         $this->contentObject->setCurrentVal($data[$currentValueKey]);
     }
     $pathSegments = t3lib_div::trimExplode('.', $typoscriptObjectPath);
     $lastSegment = array_pop($pathSegments);
     $setup = $this->typoScriptSetup;
     foreach ($pathSegments as $segment) {
         if (!array_key_exists($segment . '.', $setup)) {
             throw new Tx_Fluid_Core_ViewHelper_Exception('TypoScript object path "' . htmlspecialchars($typoscriptObjectPath) . '" does not exist', 1253191023);
         }
         $setup = $setup[$segment . '.'];
     }
     return $this->contentObject->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']);
 }
コード例 #2
0
 /**
  * Evaluate this node and return the correct object.
  *
  * Handles each part (denoted by .) in $this->objectPath in the following order:
  * - call appropriate getter
  * - call public property, if exists
  * - fail
  *
  * The first part of the object path has to be a variable in the
  * TemplateVariableContainer.
  *
  * @return object The evaluated object, can be any object type.
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  * @todo Depending on the context, either fail or not!!!
  */
 public function evaluate()
 {
     $objectPathParts = explode('.', $this->objectPath);
     $variableName = array_shift($objectPathParts);
     if (!$this->renderingContext->getTemplateVariableContainer()->exists($variableName)) {
         return NULL;
     }
     $currentObject = $this->renderingContext->getTemplateVariableContainer()->get($variableName);
     if (count($objectPathParts) > 0) {
         return Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($currentObject, implode('.', $objectPathParts));
     } else {
         return $currentObject;
     }
 }
コード例 #3
0
ファイル: Page.php プロジェクト: rafu1987/t3bootstrap-project
 /**
  * Set properties of an object/array in cobj->LOAD_REGISTER which can then
  * be used to be loaded via TS with register:name
  *
  * @param string $properties comma separated list of properties
  * @param mixed $object object or array to get the properties
  * @param string $prefix optional prefix
  * @return void
  */
 public static function setRegisterProperties($properties, $object, $prefix = 'news')
 {
     if (!empty($properties) && !is_null($object)) {
         $cObj = t3lib_div::makeInstance('tslib_cObj');
         $items = t3lib_div::trimExplode(',', $properties, TRUE);
         $register = array();
         foreach ($items as $item) {
             $key = $prefix . ucfirst($item);
             try {
                 $register[$key] = Tx_Extbase_Reflection_ObjectAccess::getProperty($object, $item);
             } catch (Exception $e) {
                 t3lib_div::devLog($e->getMessage(), 'news', t3lib_div::SYSLOG_SEVERITY_WARNING);
             }
         }
         $cObj->LOAD_REGISTER($register, '');
     }
 }
コード例 #4
0
 /**
  * Gets a property path from a given object or array.
  *
  * If propertyPath is "bla.blubb", then we first call getProperty($object, 'bla'),
  * and on the resulting object we call getProperty(..., 'blubb').
  *
  * For arrays the keys are checked likewise.
  *
  * @param mixed $subject An object or array
  * @param string $propertyPath
  * @return mixed Value of the property
  */
 protected function getPropertyPath($subject, $propertyPath, Tx_Fluid_Core_Rendering_RenderingContextInterface $renderingContext)
 {
     $propertyPathSegments = explode('.', $propertyPath);
     foreach ($propertyPathSegments as $pathSegment) {
         if (is_object($subject) && Tx_Extbase_Reflection_ObjectAccess::isPropertyGettable($subject, $pathSegment)) {
             $subject = Tx_Extbase_Reflection_ObjectAccess::getProperty($subject, $pathSegment);
         } elseif ((is_array($subject) || $subject instanceof ArrayAccess) && isset($subject[$pathSegment])) {
             $subject = $subject[$pathSegment];
         } else {
             return NULL;
         }
         if ($subject instanceof Tx_Fluid_Core_Parser_SyntaxTree_RenderingContextAwareInterface) {
             $subject->setRenderingContext($renderingContext);
         }
     }
     return $subject;
 }
コード例 #5
0
 /**
  * @param string $term
  * @return string
  */
 public function autocompleteAction($term)
 {
     $searchProperty = $this->widgetConfiguration['searchProperty'];
     $query = $this->widgetConfiguration['objects']->getQuery();
     $constraint = $query->getConstraint();
     if ($constraint !== NULL) {
         $query->matching($query->logicalAnd($constraint, $query->like($searchProperty, '%' . $term . '%', FALSE)));
     } else {
         $query->matching($query->like($searchProperty, '%' . $term . '%', FALSE));
     }
     $results = $query->execute();
     $output = array();
     foreach ($results as $singleResult) {
         $val = Tx_Extbase_Reflection_ObjectAccess::getProperty($singleResult, $searchProperty);
         $output[] = array('id' => $val, 'label' => $val, 'value' => $val);
     }
     return json_encode($output);
 }
コード例 #6
0
ファイル: GetViewHelper.php プロジェクト: nyxos/vhs
 /**
  * Get the variable in $name.
  *
  * @param string $name
  * @return mixed
  */
 public function render($name)
 {
     if (strpos($name, '.') === FALSE) {
         if ($this->templateVariableContainer->exists($name) === TRUE) {
             return $this->templateVariableContainer->get($name);
         }
     } else {
         $segments = explode('.', $name);
         $templateVariableRootName = array_shift($segments);
         if ($this->templateVariableContainer->exists($templateVariableRootName)) {
             $templateVariableRoot = $this->templateVariableContainer->get($templateVariableRootName);
             try {
                 return Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($templateVariableRoot, implode('.', $segments));
             } catch (Exception $e) {
                 return NULL;
             }
         }
     }
     return NULL;
 }
コード例 #7
0
ファイル: Mapper.php プロジェクト: NaveedWebdeveloper/Test
 /**
  * Maps the given properties to the target object WITHOUT VALIDATING THE RESULT.
  * If the properties could be set, this method returns TRUE, otherwise FALSE.
  * Returning TRUE does not mean that the target object is valid and secure!
  *
  * Only use this method if you're sure that you don't need validation!
  *
  * @param array $propertyNames Names of the properties to map.
  * @param mixed $source Source containing the properties to map to the target object. Must either be an array, ArrayObject or any other object.
  * @param object $target The target object
  * @param array $optionalPropertyNames Names of optional properties. If a property is specified here and it doesn't exist in the source, no error is issued.
  * @return boolean TRUE if the properties could be mapped, otherwise FALSE
  * @see mapAndValidate()
  * @api
  */
 public function map(array $propertyNames, $source, $target, $optionalPropertyNames = array())
 {
     if (!is_object($source) && !is_array($source)) {
         throw new Tx_Extbase_Property_Exception_InvalidSource('The source object must be a valid object or array, ' . gettype($target) . ' given.', 1187807099);
     }
     if (is_string($target) && strpos($target, '_') !== FALSE) {
         return $this->transformToObject($source, $target, '--none--');
     }
     if (!is_object($target) && !is_array($target)) {
         throw new Tx_Extbase_Property_Exception_InvalidTarget('The target object must be a valid object or array, ' . gettype($target) . ' given.', 1187807099);
     }
     $this->mappingResults = new Tx_Extbase_Property_MappingResults();
     if (is_object($target)) {
         $targetClassSchema = $this->reflectionService->getClassSchema(get_class($target));
     } else {
         $targetClassSchema = NULL;
     }
     foreach ($propertyNames as $propertyName) {
         $propertyValue = NULL;
         if (is_array($source) || $source instanceof ArrayAccess) {
             if (isset($source[$propertyName])) {
                 $propertyValue = $source[$propertyName];
             }
         } else {
             $propertyValue = Tx_Extbase_Reflection_ObjectAccess::getProperty($source, $propertyName);
         }
         if ($propertyValue === NULL && !in_array($propertyName, $optionalPropertyNames)) {
             $this->mappingResults->addError(new Tx_Extbase_Error_Error("Required property '{$propertyName}' does not exist.", 1236785359), $propertyName);
         } else {
             if ($targetClassSchema !== NULL && $targetClassSchema->hasProperty($propertyName)) {
                 $propertyMetaData = $targetClassSchema->getProperty($propertyName);
                 if (in_array($propertyMetaData['type'], array('array', 'ArrayObject', 'Tx_Extbase_Persistence_ObjectStorage')) && (strpos($propertyMetaData['elementType'], '_') !== FALSE || $propertyValue === '')) {
                     $objects = array();
                     if (is_array($propertyValue)) {
                         foreach ($propertyValue as $value) {
                             $objects[] = $this->transformToObject($value, $propertyMetaData['elementType'], $propertyName);
                         }
                     }
                     // make sure we hand out what is expected
                     if ($propertyMetaData['type'] === 'ArrayObject') {
                         $propertyValue = new ArrayObject($objects);
                     } elseif ($propertyMetaData['type'] === 'Tx_Extbase_Persistence_ObjectStorage') {
                         $propertyValue = new Tx_Extbase_Persistence_ObjectStorage();
                         foreach ($objects as $object) {
                             $propertyValue->attach($object);
                         }
                     } else {
                         $propertyValue = $objects;
                     }
                 } elseif ($propertyMetaData['type'] === 'DateTime' || strpos($propertyMetaData['type'], '_') !== FALSE) {
                     $propertyValue = $this->transformToObject($propertyValue, $propertyMetaData['type'], $propertyName);
                     if ($propertyValue === NULL) {
                         continue;
                     }
                 }
             } elseif ($targetClassSchema !== NULL) {
                 $this->mappingResults->addError(new Tx_Extbase_Error_Error("Property '{$propertyName}' does not exist in target class schema.", 1251813614), $propertyName);
             }
             if (is_array($target)) {
                 $target[$propertyName] = $propertyValue;
             } elseif (Tx_Extbase_Reflection_ObjectAccess::setProperty($target, $propertyName, $propertyValue) === FALSE) {
                 $this->mappingResults->addError(new Tx_Extbase_Error_Error("Property '{$propertyName}' could not be set.", 1236783102), $propertyName);
             }
         }
     }
     return !$this->mappingResults->hasErrors();
 }
コード例 #8
0
 /**
  * Get the current property of the object bound to this form.
  *
  * @return mixed Value
  * @author Bastian Waidelich <*****@*****.**>
  */
 protected function getPropertyValue()
 {
     $formObject = $this->viewHelperVariableContainer->get('Tx_Fluid_ViewHelpers_FormViewHelper', 'formObject');
     $propertyName = $this->arguments['property'];
     if (is_array($formObject)) {
         return isset($formObject[$propertyName]) ? $formObject[$propertyName] : NULL;
     }
     return Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($formObject, $propertyName);
 }
コード例 #9
0
 /**
  * @test
  */
 public function getPropertyPathReturnsNullForNonExistingPropertyPath()
 {
     $alternativeObject = new Tx_Extbase_Tests_Unit_Reflection_Fixture_DummyClassWithGettersAndSetters();
     $alternativeObject->setProperty(new stdClass());
     $this->dummyObject->setProperty2($alternativeObject);
     $this->assertNull(Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($this->dummyObject, 'property2.property.not.existing'));
 }
コード例 #10
0
ファイル: FileService.php プロジェクト: pylixm/tool
 /**
  * Gets files uploaded through field name $name
  *
  * @param Tx_Extbase_DomainObject_DomainObjectInterface $domainObject
  * @param string $propertyName Index name of the files in $_FILES
  * @param string $objectType Optional class name to use for uploaded file resources
  * @return Tx_Tool_Resource_FileResourceObjectStorage
  * @api
  */
 public function getUploadedFiles(Tx_Extbase_DomainObject_DomainObjectInterface &$domainObject, $propertyName, $objectType = NULL)
 {
     if ($objectType === NULL) {
         $objectType = 'Tx_Tool_Resource_FileResource';
     }
     $namespace = $this->domainService->getPluginNamespace($domainObject);
     $fileObjectStorage = $this->objectManager->create('Tx_Tool_Resource_FileResourceObjectStorage');
     $postFiles = Tx_Extbase_Reflection_ObjectAccess::getProperty($_FILES[$namespace]['tmp_name'], $propertyName);
     if (is_array($postFiles) === FALSE) {
         $filename = $postFiles;
         $targetFilename = Tx_Extbase_Reflection_ObjectAccess::getProperty($_FILES[$namespace]['name'], $propertyName);
         if ($targetFilename && $targetFilename != '') {
             $object = $this->objectManager->create($objectType, $filename);
             $object->setTargetFilename($targetFilename);
             $fileObjectStorage->attach($object);
             return $fileObjectStorage;
         }
     }
     $numFiles = count($postFiles);
     for ($i = 0; $i < $numFiles; $i++) {
         $filename = Tx_Extbase_Reflection_ObjectAccess::getProperty($_FILES[$namespace]['tmp_name'], $propertyName . '.' . $i);
         $targetFilename = Tx_Extbase_Reflection_ObjectAccess::getProperty($_FILES[$namespace]['name'], $propertyName . '.' . $i);
         if ($targetFilename && $targetFilename != '') {
             if (is_file($filename)) {
                 $object = $this->objectManager->get($objectType, $filename);
                 $object->setTargetFilename($targetFilename);
                 $fileObjectStorage->attach($object);
             }
         }
     }
     return $fileObjectStorage;
 }
コード例 #11
0
    /**
     * Prefill string for fields
     *
     * @param 	object 		$field Field Object
     * @param 	int 		$cycle Cycle Number (1,2,3...) - if filled it's a checkbox or radiobutton
     * @param 	string 		$overwrite Value (Overwrites everything)
     * @return 	string		Prefill field with this string
     */
    public function render($field, $cycle = 0) {
		// config
		$value = '';
		$marker = $field->getMarker();
		$uid = $field->getUid();

		// Default fieldtypes (input, textarea, hidden, select)
		if ($cycle == 0) {

			// if GET/POST with marker (&tx_powermail_pi1[marker]=value)
			if (isset($this->piVars[$marker])) {
				$value = $this->piVars[$marker];
			}

			// if GET/POST with new uid (&tx_powermail_pi1[field][123]=value)
			elseif (isset($this->piVars['field'][$uid])) {
				$value = $this->piVars['field'][$uid];
			}

			// if GET/POST with old uid (&tx_powermail_pi1[uid123]=value (downgrade to powermail < 2)
			elseif (isset($this->piVars['uid' . $uid])) {
				$value = $this->piVars['uid' . $uid];
			}

			// if field should be filled with FE_User values
			elseif ($field->getFeuserValue()) {
				if (intval($GLOBALS['TSFE']->fe_user->user['uid']) !== 0) { // if fe_user is logged in
					$value = $GLOBALS['TSFE']->fe_user->user[$field->getFeuserValue()];
				}
			}

			// if prefill value (from flexform)
			elseif ($field->getPrefillValue()) {
				$value = $field->getPrefillValue();
			}

			// if prefill value (from typoscript)
			elseif ($this->settings['prefill.'][$marker]) {
				if (isset($this->settings['prefill.'][$marker . '.']) && is_array($this->settings['prefill.'][$marker . '.'])) { // Parse cObject
					$data =  Tx_Extbase_Reflection_ObjectAccess::getGettableProperties($field); // make array from object
					$this->cObj->start($data); // push to ts
					$value = $this->cObj->cObjGetSingle($this->settings['prefill.'][$marker], $this->settings['prefill.'][$marker . '.']); // parse
				} else { // Use String only
					$value = $this->settings['prefill.'][$marker];
				}

			}

			return $value;



		// Check, Radio
		} else {
			$selected = 0;
			$index = $cycle - 1;
			$options = $field->getSettings();

			// if GET/POST with marker (&tx_powermail_pi1[marker]=value)
			if (isset($this->piVars[$marker])) {
				if ($this->piVars[$marker] == $options[$index]['value'] || $this->piVars[$marker] == $options[$index]['label']) {
					$selected = 1;
				}
			}

			// if GET/POST with new uid (&tx_powermail_pi1[field][123]=value)
			elseif (isset($this->piVars['field'][$uid])) {
				if (is_array($this->piVars['field'][$uid])) {
					foreach ($this->piVars['field'][$uid] as $key => $value) {
						if ($this->piVars['field'][$uid][$key] == $options[$index]['value'] || $this->piVars['field'][$uid][$key] == $options[$index]['label']) {
							$selected = 1;
						}
					}
				} else {
					if ($this->piVars['field'][$uid] == $options[$index]['value'] || $this->piVars['field'][$uid] == $options[$index]['label']) {
						$selected = 1;
					}
				}
			}

			// if GET/POST with old uid (&tx_powermail_pi1[uid123]=value (downgrade to powermail < 2)
			elseif (isset($this->piVars['uid' . $uid])) {
				if ($this->piVars['uid' . $uid] == $options[$index]['value'] || $this->piVars['uid' . $uid] == $options[$index]['label']) {
					$selected = 1;
				}
			}

			// if field should be filled with FE_User values
			elseif ($field->getFeuserValue() && intval($GLOBALS['TSFE']->fe_user->user['uid']) !== 0) {
				if ($GLOBALS['TSFE']->fe_user->user[$field->getFeuserValue()] == $options[$index]['value'] || $GLOBALS['TSFE']->fe_user->user[$field->getFeuserValue()] == $options[$index]['label']) { // if fe_user is logged in
					$selected = 1;
				}
			}

			// if prefill value (from flexform)
			elseif ($options[$index]['selected']) {
				$selected = 1;
			}

			// if prefill value (from typoscript)
			elseif ($this->settings['prefill.'][$marker]) {
				if (isset($this->settings['prefill.'][$marker . '.']) && is_array($this->settings['prefill.'][$marker . '.'])) { // Parse cObject
					$data =  Tx_Extbase_Reflection_ObjectAccess::getGettableProperties($field); // make array from object
					$this->cObj->start($data); // push to ts
					if (
						$this->cObj->cObjGetSingle($this->settings['prefill.'][$marker], $this->settings['prefill.'][$marker . '.']) == $options[$index]['value'] ||
						$this->cObj->cObjGetSingle($this->settings['prefill.'][$marker], $this->settings['prefill.'][$marker . '.']) == $options[$index]['label']
					) {
						$selected = 1;
					}
				} else { // Use String only
					if ($this->settings['prefill.'][$marker] == $options[$index]['value'] || $this->settings['prefill.'][$marker] == $options[$index]['label']) {
						$selected = 1;
					}
				}

			}

			return $selected;
		}

    }
コード例 #12
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]), ...), ...)
  * @author Bastian Waidelich <*****@*****.**>
  */
 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 = Tx_Extbase_Reflection_ObjectAccess::getProperty($value, $groupBy);
         } else {
             throw new Tx_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;
 }
コード例 #13
0
ファイル: EventController.php プロジェクト: woehrlag/Intranet
 /**
  * action beCopy
  *
  * @param Tx_WoehrlSeminare_Domain_Model_Event $event
  * @ignorevalidation $event
  * @return void
  */
 public function beCopyAction($event)
 {
     $availableProperties = Tx_Extbase_Reflection_ObjectAccess::getGettablePropertyNames($event);
     $newEvent = $this->objectManager->create('Tx_WoehrlSeminare_Domain_Model_Event');
     foreach ($availableProperties as $propertyName) {
         if (Tx_Extbase_Reflection_ObjectAccess::isPropertySettable($newEvent, $propertyName) && !in_array($propertyName, array('uid', 'pid', 'subscribers', 'cancelled', 'subEndDateTime', 'subEndDateInfoSent', 'categories', 'discipline'))) {
             $propertyValue = Tx_Extbase_Reflection_ObjectAccess::getProperty($event, $propertyName);
             Tx_Extbase_Reflection_ObjectAccess::setProperty($newEvent, $propertyName, $propertyValue);
         }
     }
     foreach ($event->getCategories() as $cat) {
         $newEvent->addCategory($cat);
     }
     foreach ($event->getDiscipline() as $discipline) {
         $newEvent->addDiscipline($discipline);
     }
     if ($event->getGeniusBar()) {
         $newEvent->setTitle('Wissensbar ' . $newEvent->getContact()->getName());
     } else {
         $newEvent->setTitle($newEvent->getTitle());
     }
     $newEvent->setHidden(TRUE);
     $this->eventRepository->add($newEvent);
     $this->flashMessageContainer->add('Die Veranstaltung ' . $newEvent->getTitle() . ' wurde kopiert.');
     $this->redirect('beList');
 }
コード例 #14
0
ファイル: SortViewHelper.php プロジェクト: nyxos/vhs
 /**
  * Gets the value to use as sorting value from $object
  *
  * @param mixed $object
  * @return mixed
  */
 protected function getSortValue($object)
 {
     $field = $this->arguments['sortBy'];
     $value = Tx_Extbase_Reflection_ObjectAccess::getProperty($object, $field);
     if ($value instanceof DateTime) {
         $value = $value->format('U');
     } elseif ($value instanceof Tx_Extbase_Persistence_ObjectStorage) {
         $value = $value->count();
     } elseif (is_array($value)) {
         $value = count($value);
     }
     return $value;
 }
コード例 #15
0
 /**
  * Checks if the specified property of the given object is valid.
  *
  * If at least one error occurred, the result is FALSE.
  *
  * @param object $object The object containing the property to validate
  * @param string $propertyName Name of the property to validate
  * @return boolean TRUE if the property value is valid, FALSE if an error occured
  * @api
  */
 public function isPropertyValid($object, $propertyName)
 {
     if (!is_object($object)) {
         throw new InvalidArgumentException('Object expected, ' . gettype($object) . ' given.', 1241099149);
     }
     if (!isset($this->propertyValidators[$propertyName])) {
         return TRUE;
     }
     $result = TRUE;
     foreach ($this->propertyValidators[$propertyName] as $validator) {
         if ($validator->isValid(Tx_Extbase_Reflection_ObjectAccess::getProperty($object, $propertyName)) === FALSE) {
             $this->addErrorsForProperty($validator->getErrors(), $propertyName);
             $result = FALSE;
         }
     }
     return $result;
 }
コード例 #16
0
 /**
  * Returns the settings at path $path, which is separated by ".",
  * e.g. "pages.uid".
  * "pages.uid" would return $this->settings['pages']['uid'].
  *
  * If the path is invalid or no entry is found, false is returned.
  *
  * @param string $path
  * @return mixed
  */
 public function getByPath($path)
 {
     return Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($this->getSettings(), $path);
 }
コード例 #17
0
 /**
  * action reinitialize
  *
  * @param Tx_Contentstage_Domain_Model_Review $review
  * @return void
  */
 public function reinitializeAction(Tx_Contentstage_Domain_Model_Review $review)
 {
     $this->checkPermission();
     $changed = $review->calculateState($this->activeBackendUser, true);
     $review->setCreated(new DateTime());
     $review->setCreator($this->activeBackendUser);
     $this->reviewRepository->update($review);
     foreach ($review->getReviewed() as $reviewed) {
         $reviewed->reset();
         $this->reviewedRepository->update($reviewed);
     }
     $this->log->log($this->translate('info.review.reinitialized'), Tx_CabagExtbase_Utility_Logging::OK, Tx_Extbase_Reflection_ObjectAccess::getGettableProperties($review));
     if ($changed) {
         $this->sendReviewMailAndLog('changed', $review);
     }
     $this->redirect('compare', 'Content');
 }
コード例 #18
0
ファイル: ImplodeViewHelper.php プロジェクト: romac/Powered
 protected function getObjectProperty($object)
 {
     $current = $object;
     reset($this->propertyPathParts);
     foreach ($this->propertyPathParts as $part) {
         $current = Tx_Extbase_Reflection_ObjectAccess::getProperty($current, $part);
     }
     return $current;
 }
コード例 #19
0
ファイル: MarshallService.php プロジェクト: pylixm/tool
 /**
  * Does $propertyName on $instance contain a data type which supports deflation?
  *
  * @param object $instance Instance of an object, DomainObject included
  * @param string $propertyName String name of property on DomainObject instance which is up for assertion
  * @return boolean
  * @throws RuntimeException
  */
 protected function assertSupportsDeflation($instance, $propertyName)
 {
     $className = get_class($instance);
     $gettableProperties = $this->reflectionService->getClassPropertyNames($className);
     if (FALSE === in_array($propertyName, $gettableProperties)) {
         return FALSE;
     }
     try {
         $value = Tx_Extbase_Reflection_ObjectAccess::getProperty($instance, $propertyName, TRUE);
     } catch (RuneimeException $error) {
         $getter = 'get' . ucfirst($propertyName);
         if (FALSE === method_exists($instance, $getter)) {
             return FALSE;
         }
         t3lib_div::sysLog('MarshallService encountered an error while attempting to retrieve the value of ' . $className . '::$' . $propertyName . ' - assuming safe deflation is possible', 'site', t3lib_div::SYSLOG_SEVERITY_NOTICE);
         return TRUE;
     }
     return FALSE === $value instanceof Closure;
 }
コード例 #20
0
 /**
  * Main action for administration
  *
  * @param Tx_News_Domain_Model_Dto_AdministrationDemand $demand
  * @dontvalidate  $demand
  * @return void
  */
 public function indexAction(Tx_News_Domain_Model_Dto_AdministrationDemand $demand = NULL)
 {
     if (is_null($demand)) {
         $demand = $this->objectManager->get('Tx_News_Domain_Model_Dto_AdministrationDemand');
         // Preselect by TsConfig (e.g. tx_news.module.preselect.topNewsRestriction = 1)
         $tsConfig = t3lib_BEfunc::getPagesTSconfig($this->pageUid);
         if (isset($tsConfig['tx_news.']['module.']['preselect.']) && is_array($tsConfig['tx_news.']['module.']['preselect.'])) {
             unset($tsConfig['tx_news.']['module.']['preselect.']['orderByAllowed']);
             foreach ($tsConfig['tx_news.']['module.']['preselect.'] as $propertyName => $propertyValue) {
                 Tx_Extbase_Reflection_ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
             }
         }
     }
     $demand = $this->createDemandObjectFromSettings($demand);
     $categories = $this->categoryRepository->findParentCategoriesByPid($this->pageUid);
     $idList = array();
     foreach ($categories as $c) {
         $idList[] = $c->getUid();
     }
     $this->view->assignMultiple(array('page' => $this->pageUid, 'demand' => $demand, 'news' => $this->newsRepository->findDemanded($demand, FALSE), 'categories' => $this->categoryRepository->findTree($idList), 'dateformat' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']));
 }
コード例 #21
0
 /**
  * Overwrites a given demand object by an propertyName =>  $propertyValue array
  *
  * @param Tx_News_Domain_Model_Dto_NewsDemand $demand
  * @param array $overwriteDemand
  * @return Tx_News_Domain_Model_Dto_NewsDemand
  */
 protected function overwriteDemandObject($demand, $overwriteDemand)
 {
     unset($overwriteDemand['orderByAllowed']);
     foreach ($overwriteDemand as $propertyName => $propertyValue) {
         Tx_Extbase_Reflection_ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
     }
     return $demand;
 }
コード例 #22
0
 /**
  * Traverses the given object structure in order to transform it into an
  * array structure.
  *
  * @param object $object Object to traverse
  * @param mixed $configuration Configuration for transforming the given object or NULL
  * @return array Object structure as an aray
  * @author Christopher Hlubek <*****@*****.**>
  * @author Dennis Ahrens <*****@*****.**>
  */
 protected function transformObject($object, $configuration)
 {
     // hand over DateTime as ISO formatted string
     if ($object instanceof DateTime) {
         return $object->format('c');
     }
     // load LayzyLoadingProxy instances
     if ($object instanceof Tx_Extbase_Persistence_LazyLoadingProxy) {
         $object = $object->_loadRealInstance();
     }
     $propertyNames = Tx_Extbase_Reflection_ObjectAccess::getGettablePropertyNames($object);
     $propertiesToRender = array();
     foreach ($propertyNames as $propertyName) {
         if (isset($configuration['_only']) && is_array($configuration['_only']) && !in_array($propertyName, $configuration['_only'])) {
             continue;
         }
         if (isset($configuration['_exclude']) && is_array($configuration['_exclude']) && in_array($propertyName, $configuration['_exclude'])) {
             continue;
         }
         $propertyValue = Tx_Extbase_Reflection_ObjectAccess::getProperty($object, $propertyName);
         if (!is_array($propertyValue) && !is_object($propertyValue)) {
             $propertiesToRender[$propertyName] = $propertyValue;
         } elseif (isset($configuration['_descend']) && array_key_exists($propertyName, $configuration['_descend'])) {
             $propertiesToRender[$propertyName] = $this->transformValue($propertyValue, $configuration['_descend'][$propertyName]);
         } else {
         }
     }
     if (isset($configuration['_exposeObjectIdentifier']) && $configuration['_exposeObjectIdentifier'] === TRUE) {
         // we don't use the IdentityMap like its done in FLOW3 because there are some cases objects are not registered there.
         // TODO: rethink this solution - it is really quick and dirty...
         $propertiesToRender['__identity'] = $object->getUid();
     }
     return $propertiesToRender;
 }
コード例 #23
0
 /**
  * Retrieves the selected value(s)
  *
  * @return mixed value string or an array of strings
  * @author Bastian Waidelich <*****@*****.**>
  */
 protected function getSelectedValue()
 {
     $value = $this->getValue();
     if (!$this->arguments->hasArgument('optionValueField')) {
         return $value;
     }
     if (!is_array($value) && !$value instanceof Iterator) {
         if (is_object($value)) {
             return Tx_Extbase_Reflection_ObjectAccess::getProperty($value, $this->arguments['optionValueField']);
         } else {
             return $value;
         }
     }
     $selectedValues = array();
     foreach ($value as $selectedValueElement) {
         if (is_object($selectedValueElement)) {
             $selectedValues[] = Tx_Extbase_Reflection_ObjectAccess::getProperty($selectedValueElement, $this->arguments['optionValueField']);
         } else {
             $selectedValues[] = $selectedValueElement;
         }
     }
     return $selectedValues;
 }
コード例 #24
0
ファイル: DomainService.php プロジェクト: pylixm/tool
 /**
  * Gets the TCA-defined uploadfolder for $object. If no propertyName, then
  * all all properties with uploadfolders are returned as keys along with
  * their respective upload folders as value
  * @param mixed $object
  * @param string $propertyName
  * @return mixed
  * @api
  */
 public function getUploadFolder($object, $propertyName = NULL)
 {
     if (is_object($object) === FALSE) {
         $className = $object;
         $object = $this->objectManager->get($className);
     }
     if ($propertyName === NULL) {
         $properties = Tx_Extbase_Reflection_ObjectAccess::getGettablePropertyNames($object);
         $folders = array();
         foreach ($properties as $propertyName) {
             $uploadFolder = $this->getUploadFolder($object, $propertyName);
             if (is_dir(PATH_site . $uploadFolder)) {
                 $folders[$propertyName] = $uploadFolder;
             }
         }
         return $folders;
     }
     $tableName = $this->getDatabaseTable($object);
     t3lib_div::loadTCA($tableName);
     $underscoredPropertyName = $this->convertCamelCaseToLowerCaseUnderscored($propertyName);
     $uploadFolder = $GLOBALS['TCA'][$tableName]['columns'][$underscoredPropertyName]['config']['uploadfolder'];
     return $uploadFolder;
 }