/** * Load the property value to be used for validation. * * In case the object is a doctrine proxy, we need to load the real instance first. * * @param object $object * @param string $propertyName * @return mixed */ protected function getPropertyValue($object, $propertyName) { // TODO: add support for lazy loading proxies, if needed if (ObjectAccess::isPropertyGettable($object, $propertyName)) { return ObjectAccess::getProperty($object, $propertyName); } else { return ObjectAccess::getProperty($object, $propertyName, TRUE); } }
/** * @test */ public function isPropertyGettableWorksOnStdClass() { $stdClassObject = new \stdClass(); $stdClassObject->property = 'foo'; $this->assertTrue(\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertyGettable($stdClassObject, 'property')); $this->assertFalse(\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertyGettable($stdClassObject, 'undefinedProperty')); }
/** * Determine the storage page ID for a given NEW record * * This does the following: * - If the domain object has an accessible property 'pid' (i.e. through a getPid() method), that is used to store the record. * - If there is a TypoScript configuration "classes.CLASSNAME.newRecordStoragePid", that is used to store new records. * - If there is no such TypoScript configuration, it uses the first value of The "storagePid" taken for reading records. * * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object * @return int the storage Page ID where the object should be stored */ protected function determineStoragePageIdForNewRecord(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object = null) { $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if ($object !== null) { if (\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertyGettable($object, 'pid')) { $pid = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($object, 'pid'); if (isset($pid)) { return (int) $pid; } } $className = get_class($object); if (isset($frameworkConfiguration['persistence']['classes'][$className]) && !empty($frameworkConfiguration['persistence']['classes'][$className]['newRecordStoragePid'])) { return (int) $frameworkConfiguration['persistence']['classes'][$className]['newRecordStoragePid']; } } $storagePidList = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $frameworkConfiguration['persistence']['storagePid']); return (int) $storagePidList[0]; }