Project

General

Profile

Task #68157 » patch_overload_querySettings_by_initializeAction.diff

Manuel Selbach, 2015-07-15 13:03

View differences:

src/project_root/libraries/typo3/typo3_src-6.2.14/typo3/sysext/extbase/Classes/Property/TypeConverter/PersistentObjectConverter.php
*/
protected $persistenceManager;
const IGNORE_ENABLE_FIELDS = 'IGNORE_ENABLE_FIELDS';
const RESPECT_STORAGE_PAGE = 'RESPECT_STORAGE_PAGE';
const RESPECT_SYS_LANGUAGE = 'RESPECT_SYS_LANGUAGE';
const ENABLE_FIELDS_TO_BE_IGNORED = 'ENABLE_FIELDS_TO_BE_IGNORED';
const INCLUDE_DELETED = 'INCLUDE_DELETED';
const SYS_LANGUAGE_UID = 'SYS_LANGUAGE_UID';
const STORAGE_PAGE_IDS = 'STORAGE_PAGE_IDS';
/**
* @var bool
*/
protected $ignoreEnableFields = false;
/**
* @var bool
*/
protected $respectStoragePage = true;
/**
* @var bool
*/
protected $respectSysLanguage = true;
/**
* @var array
*/
protected $enableFieldsToBeIgnored = array();
/**
* @var bool
*/
protected $includeDeleted = false;
/**
* @var int
*/
protected $sysLanguageUid = 0;
/**
* @var array
*/
protected $storagePageIds = array();
/**
* @var \TYPO3\CMS\Extbase\Persistence\Generic\Session
* @inject
*/
protected $persistenceSession;
/**
* We can only convert if the $targetType is either tagged with entity or value object.
*
......
* @throws \TYPO3\CMS\Extbase\Property\Exception\InvalidTargetException
*/
public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = NULL) {
$this->setConfiguration($configuration);
if (is_array($source)) {
if (
class_exists($targetType)
......
return $object;
}
/**
* set configuration to overload query settings
* e.g. get hidden records
*
* @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
* @return null
*/
protected function setConfiguration(\TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration = null)
{
if($configuration == null){
return null;
}
$ignoreEnableFields = $configuration->getConfigurationValue(get_class($this), self::IGNORE_ENABLE_FIELDS);
if(isset($ignoreEnableFields)){
$this->ignoreEnableFields = $ignoreEnableFields;
}
$respectStoragePage = $configuration->getConfigurationValue(get_class($this), self::RESPECT_STORAGE_PAGE);
if(isset($respectStoragePage)){
$this->respectStoragePage = $respectStoragePage;
}
$respectSysLanguage = $configuration->getConfigurationValue(get_class($this), self::RESPECT_SYS_LANGUAGE);
if(isset($respectSysLanguage)){
$this->respectSysLanguage = $respectSysLanguage;
}
$enableFieldsToBeIgnored = $configuration->getConfigurationValue(get_class($this), self::ENABLE_FIELDS_TO_BE_IGNORED);
if(isset($enableFieldsToBeIgnored)){
$this->enableFieldsToBeIgnored = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $enableFieldsToBeIgnored);
}
$includeDeleted = $configuration->getConfigurationValue(get_class($this), self::INCLUDE_DELETED);
if(isset($includeDeleted)){
$this->includeDeleted = $includeDeleted;
}
$sysLanguageUid = $configuration->getConfigurationValue(get_class($this), self::SYS_LANGUAGE_UID);
if(isset($sysLanguageUid)){
$this->sysLanguageUid = $sysLanguageUid;
}
$storagePageIds = $configuration->getConfigurationValue(get_class($this), self::STORAGE_PAGE_IDS);
if(isset($storagePageIds)){
$this->storagePageIds = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $storagePageIds);;
}
}
/**
* Handle the case if $source is an array.
*
......
*/
protected function fetchObjectFromPersistence($identity, $targetType) {
if (ctype_digit((string)$identity)) {
$object = $this->persistenceManager->getObjectByIdentifier($identity, $targetType);
if ($this->persistenceSession->hasIdentifier($identity, $targetType)) {
return $this->persistenceSession->getObjectByIdentifier($identity, $targetType);
} else {
$query = $this->persistenceManager->createQueryForType($targetType);
$querySettings = $query->getQuerySettings();
$querySettings->setIgnoreEnableFields($this->ignoreEnableFields);
$querySettings->setRespectStoragePage($this->respectStoragePage);
$querySettings->setRespectSysLanguage($this->respectSysLanguage);
$querySettings->setEnableFieldsToBeIgnored($this->enableFieldsToBeIgnored);
$querySettings->setIncludeDeleted($this->includeDeleted);
$querySettings->setLanguageUid($this->sysLanguageUid);
$querySettings->setStoragePageIds($this->storagePageIds);
$query->setQuerySettings($querySettings);
$constraints = $query->equals('uid', $identity);
$object = $query->matching($constraints)->execute()->getFirst();
return $object;
}
} else {
throw new \TYPO3\CMS\Extbase\Property\Exception\InvalidSourceException('The identity property "' . $identity . '" is no UID.', 1297931020);
}
(1-1/4)