77 public function add($object)
79 if (!$object instanceof $this->objectType) {
80 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The object given to add() was not of the type (' . $this->objectType .
') this repository manages.', 1248363335);
82 $this->persistenceManager->add($object);
92 public function remove($object)
94 if (!$object instanceof $this->objectType) {
95 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The object given to remove() was not of the type (' . $this->objectType .
') this repository manages.', 1248363336);
97 $this->persistenceManager->remove($object);
110 if (!$modifiedObject instanceof $this->objectType) {
111 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);
113 $this->persistenceManager->update($modifiedObject);
146 foreach ($this->
findAll() as $object) {
147 $this->
remove($object);
172 return $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType);
210 $query = $this->persistenceManager->createQueryForType($this->objectType);
211 if ($this->defaultOrderings !== []) {
212 $query->setOrderings($this->defaultOrderings);
214 if ($this->defaultQuerySettings !== null) {
215 $query->setQuerySettings(clone $this->defaultQuerySettings);
229 public function __call($methodName, $arguments)
231 if (substr($methodName, 0, 6) ===
'findBy' && strlen($methodName) > 7) {
232 $propertyName = lcfirst(substr($methodName, 6));
234 $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute();
237 if (substr($methodName, 0, 9) ===
'findOneBy' && strlen($methodName) > 10) {
238 $propertyName = lcfirst(substr($methodName, 9));
241 $result = $query->matching($query->equals($propertyName, $arguments[0]))->setLimit(1)->execute();
243 return $result->getFirst();
245 if (is_array($result)) {
246 return isset($result[0]) ? $result[0] : null;
248 } elseif (substr($methodName, 0, 7) ===
'countBy' && strlen($methodName) > 8) {
249 $propertyName = lcfirst(substr($methodName, 7));
251 $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute()->count();
254 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException(
'The method "' . $methodName .
'" is not supported by the repository.', 1233180480);
264 return get_class($this);
static translateRepositoryNameToModelName($repositoryName)
__construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
__call($methodName, $arguments)
injectPersistenceManager(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager)
setDefaultOrderings(array $defaultOrderings)
setDefaultQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $defaultQuerySettings)
findByIdentifier($identifier)