[!!!] [~TASK] Extbase (Domain): The directory structure of the Domain has changed accordting to changes in FLOW3 (see above). Please Change your class names!
[FEATURE] Extbase (Domain): Implemented FrontendUserGroup (no comma separated lists yet, only on usergroup possible)
[+BUGFIX] Extbase (Persistence): Fixed wrong tablenames in *_mm tables. Thanks to Christian Mueller who provided a patch. Resolves #3974.
[+BUGFIX] Extbase (Persistence): Fixed Query::lessThan, Query::lessThanOrEqual, Query::greaterThan. Resolves #3960.
[~FEATURE] Extbase (Persistence): Support for mm_opposite_field. Related to #3947.
[-API] Extbase (DomainModel): Removed getIdentifier() from AbstractDomainObject.
[-TASK] Extbase (Persistence): Removed unused DataMapperInterface.
[+API] Extbase (Persistence): Re-added possibility to set "useStoragePageId" in $queryFactory->create($className, $useStoragePageId).
[~TASK] Extbase: Messed up with the QuerySettings ;-) Will be fixed later.
/**
* @var Tx_Extbase_Domain_Model_FrontendUserGroup
*/
-// protected $usergroup;
+ protected $usergroup;
/**
* @var string
/**
* @var string
*/
-// protected $subgroup;
+ protected $subgroup;
/**
* Constructs a new Frontend User Group
+++ /dev/null
-<?php
-/***************************************************************
- * Copyright notice
- *
- * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-/**
- * A Frontend User repository
- *
- * @package Extbase
- * @subpackage Domain
- * @version $Id: $
- */
-class Tx_Extbase_Domain_Model_FrontendUserRepository extends Tx_Extbase_Persistence_Repository {
-
-}
-?>
\ No newline at end of file
--- /dev/null
+<?php
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * A Frontend User repository
+ *
+ * @package Extbase
+ * @subpackage Domain
+ * @version $Id: $
+ */
+class Tx_Extbase_Domain_Repository_FrontendUserRepository extends Tx_Extbase_Persistence_Repository {
+
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * A Frontend User repository
+ *
+ * @package Extbase
+ * @subpackage Domain
+ * @version $Id: $
+ */
+class Tx_Extbase_Domain_Repository_FrontendUserRepository extends Tx_Extbase_Persistence_Repository {
+
+}
+?>
\ No newline at end of file
return ($this->uid === NULL ? NULL : (int)$this->uid);
}
- /**
- * Getter for the identifier
- *
- * @return int the uid or NULL if none set yet.
- */
- final public function getIdentifier() {
- return ($this->uid === NULL ? NULL : (int)$this->uid);
- }
-
/**
* Reconstitutes a property. Only for internal use.
*
* @return mixed Either the object matching the uid or, if none or more than one object was found, FALSE
*/
protected function findObjectByUid($uid) {
- $query = $this->queryFactory->create($this->dataType);
- $result = current($query->matching($query->withUid($uid))->execute());
- // TODO Check if the object is an Aggregate Root (this can be quite difficult because we have no Repository registration
- if (is_object($result)) {
- $this->persistenceManager->getSession()->registerReconstitutedObject($result);
- return $result;
- } else {
- return FALSE;
- }
+ $query = $this->queryFactory->create($this->dataType, FALSE);
+ $result = $query->matching($query->withUid($uid))->execute();
+ $object = NULL;
+ if (count($result) > 0) {
+ $object = current($result);
+ // TODO Check if the object is an Aggregate Root (this can be quite difficult because we have no Repository registration
+ $this->persistenceManager->getSession()->registerReconstitutedObject($object);
+ }
+ return $object;
}
/**
$row = array(
$columnMap->getParentKeyFieldName() => (int)$parentObject->getUid(),
$columnMap->getChildKeyFieldName() => (int)$relatedObject->getUid(),
- 'tablenames' => $dataMap->getTableName(),
+ 'tablenames' => $columnMap->getChildTableName(),
'sorting' => 9999 // TODO sorting of mm table items
);
$res = $this->storageBackend->addRow(
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * A data mapper interface.
- *
- * @package Extbase
- * @subpackage extbase
- * @version $ID:$
- */
-// SK: Is this interface used anywhere? I guess not.
-interface Tx_Extbase_Persistence_DataMapperInterface {
-
- /**
- * Sets the aggregate root objects. The aggregate root objects are a starting point to traverse the
- * object graph.
- *
- * @param Tx_Extbase_Persistence_ObjectStorage $objects The objects to be registered
- * @return void
- */
- public function setAggregateRootObjects(Tx_Extbase_Persistence_ObjectStorage $objects);
-
- /**
- * Sets the deleted objects.
- *
- * @param Tx_Extbase_Persistence_ObjectStorage $objects The objects to be deleted
- * @return void
- */
- public function setDeletedObjects(Tx_Extbase_Persistence_ObjectStorage $objects);
-
- /**
- * Persists all objects traversing the object graph.
- *
- * @return void
- */
- public function persistObjects();
-
- /**
- * Processes all deleted objects.
- *
- * @return void
- */
- public function processDeletedObjects();
-
-}
-?>
\ No newline at end of file
$objectStorage = new Tx_Extbase_Persistence_ObjectStorage();
// TODO This if statement should be further encapsulated to follow the DRY principle (see Data Mapper)
if ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_ONE) {
- $query = $this->queryFactory->create($columnMap->getChildClassName());
+ $query = $this->queryFactory->create($columnMap->getChildClassName(), FALSE);
$result = current($query->matching($query->withUid($row[$columnMap->getColumnName()]))->execute());
} elseif ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
$objectStorage = new Tx_Extbase_Persistence_ObjectStorage();
- $query = $this->queryFactory->create($columnMap->getChildClassName());
- $objects = $query->matching($query->equals($columnMap->getParentKeyFieldName(), $this->parentObject->getUid()))->execute();
+ $query = $this->queryFactory->create($columnMap->getChildClassName(), FALSE);
+ $parentKeyFieldName = $columnMap->getParentKeyFieldName();
+ if (isset($parentKeyFieldName)) {
+ $objects = $query->matching($query->equals($columnMap->getParentKeyFieldName(), $this->parentObject->getUid()))->execute();
+ } else {
+ $propertyValue = $row[$propertyName];
+ $objects = $query->matching($query->withUid((int)$propertyValue))->execute();
+ }
foreach ($objects as $object) {
$objectStorage->attach($object);
}
$right = $this->QOMFactory->selector($childTableName);
$joinCondition = $this->QOMFactory->equiJoinCondition($relationTableName, $columnMap->getChildKeyFieldName(), $childTableName, 'uid');
$source = $this->QOMFactory->join(
- $left,
- $right,
- Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER,
- $joinCondition
- );
- $query = $this->queryFactory->create($columnMap->getChildClassName());
+ $left,
+ $right,
+ Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER,
+ $joinCondition
+ );
+ $query = $this->queryFactory->create($columnMap->getChildClassName(), FALSE);
$query->setSource($source);
- $objects = $query->matching($query->equals($columnMap->getChildKeyFieldName(), $this->parentObject->getUid()))->execute();
+ $objects = $query->matching($query->equals($columnMap->getParentKeyFieldName(), $this->parentObject->getUid()))->execute();
foreach ($objects as $object) {
$objectStorage->attach($object);
}
} else {
$propertyName = t3lib_div::underscoredToLowerCamelCase($columnName);
}
+ if (isset($mapping[$columnName]['foreignClass']) && !isset($columnConfiguration['config']['foreign_class'])) {
+ $columnConfiguration['config']['foreign_class'] = $mapping[$columnName]['foreignClass'];
+ }
$columnMap = new Tx_Extbase_Persistence_Mapper_ColumnMap($columnName, $propertyName);
$this->setPropertyType($columnMap, $columnConfiguration);
// TODO Check support for IRRE
} elseif (in_array('double2', $evalConfiguration)) {
$columnMap->setPropertyType(Tx_Extbase_Persistence_PropertyType::DOUBLE);
} else {
- if (isset($columnConfiguration['config']['foreign_table']) && isset($columnConfiguration['config']['foreign_class'])) {
+ if (isset($columnConfiguration['config']['foreign_table'])) {
if ($columnConfiguration['config']['loadingStrategy'] === 'proxy') {
$columnMap->setLoadingStrategy(Tx_Extbase_Persistence_Mapper_ColumnMap::STRATEGY_PROXY);
} else {
$columnMap->setChildTableName($columnConfiguration['config']['foreign_table']);
$columnMap->setRelationTableName($columnConfiguration['config']['MM']);
// TODO We currently do not support multi table relationships
- if ($columnConfiguration['config']['MM_opposite_field']) { // in case of a reverse relation
+ if ($columnConfiguration['config']['MM_opposite_field']) {
$columnMap->setParentKeyFieldName('uid_foreign');
$columnMap->setChildKeyFieldName('uid_local');
$columnMap->setChildSortByFieldName('sorting_foreign');
<?php
/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
+ * Copyright notice
+ *
+ * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
/**
* A mapper to map database tables configured in $TCA on domain objects.
*/
public function __construct() {
$this->queryFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory');
- $GLOBALS['TSFE']->includeTCA(); // TODO Move this to an appropriate position
}
/**
case Tx_Extbase_Persistence_PropertyType::LONG;
case Tx_Extbase_Persistence_PropertyType::DOUBLE;
case Tx_Extbase_Persistence_PropertyType::BOOLEAN;
- if (isset($row[$columnName])) {
- $rawPropertyValue = $row[$columnName];
- $propertyValue = $dataMap->convertFieldValueToPropertyValue($propertyType, $rawPropertyValue);
- }
+ if (isset($row[$columnName])) {
+ $rawPropertyValue = $row[$columnName];
+ $propertyValue = $dataMap->convertFieldValueToPropertyValue($propertyType, $rawPropertyValue);
+ }
break;
case (Tx_Extbase_Persistence_PropertyType::REFERENCE):
if (!is_null($row[$columnName])) {
} else {
$propertyValue = NULL;
}
- break;
+ break;
// FIXME we have an object to handle... -> exception
default:
// SK: We should throw an exception as this point as there was an undefined propertyType we can not handle.
$propertyValue = $this->mapSingleRow($className, $property);
}
}
- break;
+ break;
}
$object->_setProperty($propertyName, $propertyValue);
*/
protected function mapRelatedObjects(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, Tx_Extbase_Persistence_RowInterface $row, Tx_Extbase_Persistence_Mapper_ColumnMap $columnMap) {
$dataMap = $this->getDataMap(get_class($parentObject));
- $columnMap = $dataMap->getColumnMap($propertyName);
+ $columnMap = $dataMap->getColumnMap($propertyName);
if ($columnMap->getLoadingStrategy() === Tx_Extbase_Persistence_Mapper_ColumnMap::STRATEGY_PROXY) {
// TODO Remove dependency to the loading strategy implementation
$result = t3lib_div::makeInstance('Tx_Extbase_Persistence_LazyLoadingProxy', $parentObject, $propertyName, $dataMap);
} else {
if ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_ONE) {
- $query = $this->queryFactory->create($columnMap->getChildClassName());
+ $query = $this->queryFactory->create($columnMap->getChildClassName(), FALSE);
$result = current($query->matching($query->withUid($row[$columnMap->getColumnName()]))->execute());
} elseif ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
$objectStorage = new Tx_Extbase_Persistence_ObjectStorage();
- $query = $this->queryFactory->create($columnMap->getChildClassName());
- $objects = $query->matching($query->equals($columnMap->getParentKeyFieldName(), $parentObject->getUid()))->execute();
+ $query = $this->queryFactory->create($columnMap->getChildClassName(), FALSE);
+ $parentKeyFieldName = $columnMap->getParentKeyFieldName();
+ if (isset($parentKeyFieldName)) {
+ $objects = $query->matching($query->equals($columnMap->getParentKeyFieldName(), $parentObject->getUid()))->execute();
+ } else {
+ $propertyValue = $row[$propertyName];
+ $objects = $query->matching($query->withUid((int)$propertyValue))->execute();
+ }
foreach ($objects as $object) {
$objectStorage->attach($object);
}
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER,
$joinCondition
);
- $query = $this->queryFactory->create($columnMap->getChildClassName());
+ $query = $this->queryFactory->create($columnMap->getChildClassName(), FALSE);
$query->setSource($source);
$objects = $query->matching($query->equals($columnMap->getParentKeyFieldName(), $parentObject->getUid()))->execute();
foreach ($objects as $object) {
* @return Tx_Extbase_Persistence_Mapper_DataMap The data map
*/
public function getDataMap($className) {
- global $TCA;
if (empty($this->dataMaps[$className])) {
// FIXME This is a costy for table name aliases -> implement a DataMapBuilder (knowing the aliases defined in $TCA)
$mapping = array();
foreach (class_parents($className) as $parentClassName) {
if (isset($extbaseSettings['classes'][$parentClassName]) && !empty($extbaseSettings['classes'][$parentClassName]['mapping']['tableName'])) {
$tableName = $extbaseSettings['classes'][$parentClassName]['mapping']['tableName'];
- $mapping = $extbaseSettings['classes'][$parentClassName]['mapping']['columns'];
break;
}
// TODO throw Exception
}
}
-
+ if (is_array($extbaseSettings['classes'][$parentClassName]['mapping']['columns'])) {
+ $mapping = $extbaseSettings['classes'][$parentClassName]['mapping']['columns'];
+ }
+
$dataMap = new Tx_Extbase_Persistence_Mapper_DataMap($className, $tableName, $mapping);
$this->dataMaps[$className] = $dataMap;
}
/**
* Backend specific query settings
- * @var Tx_Extbase_Persistence_Storage_BackendSpecificQuerySettingsInterface
+ * @var Tx_Extbase_Persistence_Storage_QuerySettingsInterface
*/
- protected $backendSpecificQuerySettings;
+ protected $querySettings;
/**
* Constructs this QueryObjectModel instance
* @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint (null if none)
* @param array $orderings
* @param array $columns
- * @param Tx_Extbase_Persistence_Storage_BackendSpecificQuerySettingsInterface $backendSpecificQuerySettings Storage backend specific query settings (or NULL)
+ * @param Tx_Extbase_Persistence_Storage_QuerySettingsInterface $querySettings Storage backend specific query settings (or NULL)
*/
- public function __construct(Tx_Extbase_Persistence_QOM_SourceInterface $selectorOrSource, $constraint, array $orderings, array $columns, $backendSpecificQuerySettings) {
+ public function __construct(Tx_Extbase_Persistence_QOM_SourceInterface $selectorOrSource, $constraint, array $orderings, array $columns, $querySettings) {
$this->source = $selectorOrSource;
$this->constraint = $constraint;
$this->orderings = $orderings;
$this->columns = $columns;
- $this->backendSpecificQuerySettings = $backendSpecificQuerySettings;
+ $this->querySettings = $querySettings;
if ($this->constraint !== NULL) {
$this->constraint->collectBoundVariableNames($this->boundVariables);
*
* @return Tx_Extbase_Persistence_Storage_BackendSpecificQuerySettingsInterface Backend specific query settings
*/
- public function getBackendSpecificQuerySettings() {
- return $this->backendSpecificQuerySettings;
+ public function getQuerySettings() {
+ return $this->querySettings;
}
/**
/**
* Backend specific query settings
*
- * @return Tx_Extbase_Persistence_Storage_BackendSpecificQuerySettingsInterface Backend specific query settings
+ * @return Tx_Extbase_Persistence_Storage_QuerySettingsInterface Backend specific query settings
*/
- public function getBackendSpecificQuerySettings();
+ public function getQuerySettings();
/**
* Binds the given value to the variable named $varName.
*/
public function __construct($className) {
$this->className = $className;
- $this->backendSpecificQuerySettings = t3lib_div::makeInstance('Tx_Extbase_Persistence_Storage_Typo3DbSpecificQuerySettings');
+ $this->typo3QuerySettings = t3lib_div::makeInstance('Tx_Extbase_Persistence_Storage_Typo3QuerySettings');
}
/**
$this->constraint,
$this->orderings,
$this->columns, // TODO implement selection of columns
- $this->backendSpecificQuerySettings
+ $this->typo3QuerySettings
);
if ($this->limit !== NULL) {
$query->setLimit($this->limit);
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
*/
public function withUid($uid) {
- if ($this->source === NULL) {
- $this->source = $this->QOMFactory->selector($this->dataMapper->convertClassNameToSelectorName($this->className));
- }
- $sourceSelectorName = $this->source->getSelectorName();
$uniqueVariableName = $this->getUniqueVariableName('uid');
$this->operands[$uniqueVariableName] = $uid;
return $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue('uid', $sourceSelectorName),
+ $this->QOMFactory->propertyValue('uid', $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
*/
public function equals($propertyName, $operand, $caseSensitive = TRUE) {
$uniqueVariableName = uniqid($propertyName);
- if ($this->source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
- $sourceSelectorName = $this->getSource()->getSelectorName();
- }
- // TODO $sourceSelectorName might not be initialized
-
if (is_object($operand) && !($operand instanceof DateTime)) {
// FIXME This branch of if-then-else is not fully backported and non functional by now
$operand = $this->persistenceManager->getBackend()->getUidByObject($operand);
} else {
if ($caseSensitive) {
$comparison = $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
} else {
$comparison = $this->QOMFactory->comparison(
$this->QOMFactory->lowerCase(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName)
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName())
),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
$this->QOMFactory->bindVariable($uniqueVariableName)
*/
public function like($propertyName, $operand) {
$uniqueVariableName = uniqid($propertyName);
- if ($this->source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
- $sourceSelectorName = $this->getSource()->getSelectorName();
- }
- // TODO $sourceSelectorName might not be initialized
-
$this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
*/
public function lessThan($propertyName, $operand) {
- $sourceSelectorName = $this->source->getSelectorName();
$uniqueVariableName = uniqid($propertyName);
$this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
*/
public function lessThanOrEqual($propertyName, $operand) {
- $sourceSelectorName = $this->source->getSelectorName();
+ if ($this->source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
+ $sourceSelectorName = $this->getSource()->getSelectorName();
+ }
$uniqueVariableName = uniqid($propertyName);
$this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
*/
public function greaterThan($propertyName, $operand) {
- $sourceSelectorName = $this->source->getSelectorName();
$uniqueVariableName = uniqid($propertyName);
$this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
* @return Tx_Extbase_Persistence_QOM_ComparisonInterface
*/
public function greaterThanOrEqual($propertyName, $operand) {
- $sourceSelectorName = $this->source->getSelectorName();
$uniqueVariableName = uniqid($propertyName);
$this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
- $this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
+ $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO,
$this->QOMFactory->bindVariable($uniqueVariableName)
);
/**
* (non-PHPdoc)
- * @see Classes/Persistence/Tx_Extbase_Persistence_Typo3QueryInterface#useStoragePage($useStoragePage)
+ * @see Classes/Persistence/Tx_Extbase_Persistence_QuerySettingsInterface#useStoragePageId($useStoragePageId)
*/
- public function useStoragePage($useStoragePage) {
- $this->backendSpecificQuerySettings->useStoragePage($useStoragePage);
+ public function useStoragePageId($useStoragePageId) {
+ $this->typo3QuerySettings->useStoragePageId($useStoragePageId);
return this;
}
* @see Classes/Persistence/Tx_Extbase_Persistence_Typo3QueryInterface#useEnableFields($useEnableFields)
*/
public function useEnableFields($useEnableFields) {
- $this->backendSpecificQuerySettings->useEnableFields($useEnableFields);
+ $this->typo3QuerySettings->useEnableFields($useEnableFields);
return this;
}
+
+ /**
+ * Returns the selectorn name or null, if the source is not a selector
+ * // TODO This has to be checked at another place
+ * @return string The selector name
+ */
+ protected function getSelectorName() {
+ if ($this->source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
+ return $this->source()->getSelectorName();
+ } else {
+ return '';
+ }
+
+ }
}
?>
* @param boolean $useStoragePageId TRUE if queries should automatically be restricted to the current storage PID, FALSE otherwise.
* @return Tx_Extbase_Persistence_QueryInterface
*/
- public function create($className) {
+ public function create($className, $useStoragePageId) {
$persistenceManager = Tx_Extbase_Dispatcher::getPersistenceManager();
$dataMapper = t3lib_div::makeInstance('Tx_Extbase_Persistence_Mapper_DataMapper');
$query = t3lib_div::makeInstance('Tx_Extbase_Persistence_Query', $className);
$query->injectPersistenceManager($persistenceManager);
$query->injectDataMapper($dataMapper);
+ $query->useStoragePageId($useStoragePageId);
+
return $query;
}
}
* Creates a query object working on the given class name
*
* @param string $className The class name
+ * @param boolean $useStoragePageId If FALSE, will NOT add pid=... to the query. TRUE by default. Only change if you know what you are doing.
* @return Tx_Extbase_Persistence_QueryInterface
*/
- public function create($className);
+ public function create($className, $useStoragePageId);
}
?>
\ No newline at end of file
/**
* Use storage page
*
- * @param $useStoragePage if TRUE, should use storage PID. use FALSE to disable the storage Page ID checking
+ * @param $useStoragePageId if TRUE, should use storage PID. use FALSE to disable the storage Page ID checking
* @return void
*/
- public function useStoragePage($useStoragePage);
+ public function useStoragePageId($useStoragePageId);
/**
* Use enable fields
public function __construct() {
$this->persistenceManager = Tx_Extbase_Dispatcher::getPersistenceManager();
$this->queryFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory'); // singleton
+ $this->objectType = str_replace(array('_Repository_', 'Repository'), array('_Model_', ''), $this->getRepositoryClassName());
}
/**
public function findByUid($uid) {
if (!is_int($uid) || $uid < 0) throw new InvalidArgumentException('The uid must be a positive integer', 1245071889);
$query = $this->createQuery();
- $result = $query->matching($query->withUid($uid))
- ->setLimit(1)
- ->execute();
+ $result = $query->matching($query->withUid($uid))->execute();
$object = NULL;
if (count($result) > 0) {
$object = current($result);
*
* @param boolean $useStoragePageId If FALSE, will NOT add pid=... to the query. TRUE by default. Only change if you know what you are doing.
* @return Tx_Extbase_Persistence_QueryInterface
+ * @api
*/
public function createQuery($useStoragePageId = TRUE) {
- $repositoryClassName = $this->getRepositoryClassName();
- if (substr($repositoryClassName, -10) === 'Repository' && substr($repositoryClassName, -11, 1) !== '_') {
- $type = substr($repositoryClassName, 0, -10);
- } else {
- throw new Tx_Extbase_Exception('The domain repository wasn\'t able to resolve the target class name.', 1237897039);
- }
- if (!in_array('Tx_Extbase_DomainObject_DomainObjectInterface', class_implements($type))) {
- throw new Tx_Extbase_Exception('The domain repository tried to manage objects which are not implementing the Tx_Extbase_DomainObject_DomainObjectInterface.', 1237897039);
- }
- return $this->queryFactory->create($type, $useStoragePageId);
+ return $this->queryFactory->create($this->objectType, $useStoragePageId = TRUE);
}
-
+
/**
* Dispatches magic methods (findBy[Property]())
*
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * Marker interface for backend specific query options
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id: BackendInterface.php 2120 2009-04-02 10:06:31Z k-fish $
- */
-interface Tx_Extbase_Persistence_Storage_BackendSpecificQuerySettingsInterface {
-
-}
-?>
\ No newline at end of file
--- /dev/null
+<?php
+/***************************************************************
+* Copyright notice
+*
+* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+* All rights reserved
+*
+* This class is a backport of the corresponding class of FLOW3.
+* All credits go to the v5 team.
+*
+* This script is part of the TYPO3 project. The TYPO3 project is
+* free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Marker interface for backend specific query options
+ *
+ * @package Extbase
+ * @subpackage Persistence
+ * @version $Id: BackendInterface.php 2120 2009-04-02 10:06:31Z k-fish $
+ */
+interface Tx_Extbase_Persistence_Storage_QuerySettingsInterface extends Tx_Extbase_Persistence_QuerySettingsInterface {
+
+}
+?>
\ No newline at end of file
$sql['fields'][] = $selectorName . '.*';
$sql['tables'][] = $selectorName;
$extbaseSettings = Tx_Extbase_Dispatcher::getSettings();
- if ($query->getBackendSpecificQuerySettings()->enableFieldsEnabled()) {
+ if ($query->getQuerySettings()->enableFieldsEnabled()) {
$this->addEnableFieldsStatement($selectorName, $sql);
}
- if ($query->getBackendSpecificQuerySettings()->storagePageEnabled()) {
+ if ($query->getQuerySettings()->storagePageEnabled()) {
$sql['enableFields'][] = $selectorName . '.pid=' . intval($extbaseSettings['storagePid']);
}
} elseif ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) {
+++ /dev/null
-<?php
-/***************************************************************
-* Copyright notice
-*
-* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-* All rights reserved
-*
-* This class is a backport of the corresponding class of FLOW3.
-* All credits go to the v5 team.
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-/**
- * TYPO3 DB specific query settings like use of a PID
- *
- * @package Extbase
- * @subpackage Persistence
- * @version $Id: BackendInterface.php 2120 2009-04-02 10:06:31Z k-fish $
- */
-class Tx_Extbase_Persistence_Storage_Typo3DbSpecificQuerySettings implements Tx_Extbase_Persistence_Storage_BackendSpecificQuerySettingsInterface {
-
- protected $useStoragePage = TRUE;
-
- protected $useEnableFields = TRUE;
-
- protected $storagePageId;
-
- public function useStoragePage($useStoragePage) {
- $this->useStoragePage = (boolean)$useStoragePage;
- }
-
- public function storagePageEnabled() {
- return $this->useStoragePage;
- }
-
- public function getStoragePageId() {
- return $this->storagePageId;
- }
- public function setStoragePageId($storagePageId) {
- $this->storagePageId = $storagePageId;
- }
- public function enableFieldsEnabled() {
- return $this->useEnableFields;
- }
- public function useEnableFields($useEnableFields) {
- $this->useEnableFields = $useEnableFields;
- }
-}
-?>
\ No newline at end of file
--- /dev/null
+<?php
+/***************************************************************
+* Copyright notice
+*
+* (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+* All rights reserved
+*
+* This class is a backport of the corresponding class of FLOW3.
+* All credits go to the v5 team.
+*
+* This script is part of the TYPO3 project. The TYPO3 project is
+* free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * TYPO3 DB specific query settings like use of a PID
+ *
+ * @package Extbase
+ * @subpackage Persistence
+ * @version $Id: BackendInterface.php 2120 2009-04-02 10:06:31Z k-fish $
+ */
+class Tx_Extbase_Persistence_Storage_Typo3QuerySettings implements Tx_Extbase_Persistence_Storage_QuerySettingsInterface {
+
+ protected $useStoragePageId = TRUE;
+
+ protected $useEnableFields = TRUE;
+
+ protected $storagePageId;
+
+ public function useStoragePageId($useStoragePageId) {
+ $this->useStoragePageId = (boolean)$useStoragePageId;
+ }
+
+ public function storagePageEnabled() {
+ return $this->useStoragePage;
+ }
+
+ public function getStoragePageId() {
+ return $this->storagePageId;
+ }
+ public function setStoragePageId($storagePageId) {
+ $this->storagePageId = $storagePageId;
+ }
+ public function enableFieldsEnabled() {
+ return $this->useEnableFields;
+ }
+ public function useEnableFields($useEnableFields) {
+ $this->useEnableFields = $useEnableFields;
+ }
+}
+?>
\ No newline at end of file
protected $options = array();
/**
- * @var SPLObjectStorage
+ * @var Tx_Extbase_Persistence_ObjectStorage
*/
protected $validators;
*
*/
public function __construct() {
- $this->validators = new SPLObjectStorage();
+ $this->validators = new Tx_Extbase_Persistence_ObjectStorage();
}
/**
mapping {
tableName = fe_users
columns {
+ usergroup.foreignClass = Tx_Extbase_Domain_Model_FrontendUserGroup
lockToDomain.mapOnProperty = lockToDomain
}
}
}
Tx_Extbase_Domain_Model_FrontendUserGroup {
mapping {
- tableName = fe_users
+ tableName = fe_groups
columns {
+ subgroup.foreignClass = Tx_Extbase_Domain_Model_FrontendUserGroup
lockToDomain.mapOnProperty = lockToDomain
}
}