2 namespace TYPO3\CMS\Extbase\Persistence;
78 public function add($object)
80 if (!$object instanceof $this->objectType) {
81 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The object given to add() was not of the type (' . $this->objectType .
') this repository manages.', 1248363335);
83 $this->persistenceManager->add($object);
94 public function remove($object)
96 if (!$object instanceof $this->objectType) {
97 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The object given to remove() was not of the type (' . $this->objectType .
') this repository manages.', 1248363336);
99 $this->persistenceManager->remove($object);
113 if (!$modifiedObject instanceof $this->objectType) {
114 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The modified object given to update() was not of the type (' . $this->objectType .
') this repository manages.', 1249479625);
116 $this->persistenceManager->update($modifiedObject);
150 foreach ($this->
findAll() as $object) {
151 $this->
remove($object);
176 return $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType);
216 $query = $this->persistenceManager->createQueryForType($this->objectType);
217 if ($this->defaultOrderings !== array()) {
218 $query->setOrderings($this->defaultOrderings);
220 if ($this->defaultQuerySettings !== null) {
221 $query->setQuerySettings(clone $this->defaultQuerySettings);
235 public function __call($methodName, $arguments)
237 if (substr($methodName, 0, 6) ===
'findBy' && strlen($methodName) > 7) {
238 $propertyName = lcfirst(substr($methodName, 6));
240 $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute();
242 }
elseif (substr($methodName, 0, 9) ===
'findOneBy' && strlen($methodName) > 10) {
243 $propertyName = lcfirst(substr($methodName, 9));
246 $result = $query->matching($query->equals($propertyName, $arguments[0]))->setLimit(1)->execute();
248 return $result->getFirst();
249 }
elseif (is_array($result)) {
250 return isset($result[0]) ? $result[0] : null;
252 }
elseif (substr($methodName, 0, 7) ===
'countBy' && strlen($methodName) > 8) {
253 $propertyName = lcfirst(substr($methodName, 7));
255 $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute()->count();
258 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException(
'The method "' . $methodName .
'" is not supported by the repository.', 1233180480);
268 return get_class($this);