74 public function add($object)
76 if (!$object instanceof $this->objectType) {
77 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The object given to add() was not of the type (' . $this->objectType .
') this repository manages.', 1248363335);
79 $this->persistenceManager->add($object);
88 public function remove($object)
90 if (!$object instanceof $this->objectType) {
91 throw new \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException(
'The object given to remove() was not of the type (' . $this->objectType .
') this repository manages.', 1248363336);
93 $this->persistenceManager->remove($object);
103 public function update($modifiedObject)
105 if (!$modifiedObject instanceof $this->objectType) {
106 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);
108 $this->persistenceManager->update($modifiedObject);
137 foreach ($this->
findAll() as $object) {
138 $this->
remove($object);
161 return $this->persistenceManager->getObjectByIdentifier($identifier, $this->objectType);
196 $query = $this->persistenceManager->createQueryForType($this->objectType);
197 if ($this->defaultOrderings !== []) {
200 if ($this->defaultQuerySettings !==
null) {
214 public function __call($methodName, $arguments)
216 if (strpos($methodName,
'findBy') === 0 && strlen($methodName) > 7) {
217 $propertyName = lcfirst(substr($methodName, 6));
219 $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute();
222 if (strpos($methodName,
'findOneBy') === 0 && strlen($methodName) > 10) {
223 $propertyName = lcfirst(substr($methodName, 9));
226 $result = $query->matching($query->equals($propertyName, $arguments[0]))->setLimit(1)->execute();
227 if ($result instanceof QueryResultInterface) {
228 return $result->getFirst();
230 if (is_array($result)) {
231 return $result[0] ??
null;
233 } elseif (strpos($methodName,
'countBy') === 0 && strlen($methodName) > 8) {
234 $propertyName = lcfirst(substr($methodName, 7));
236 $result = $query->matching($query->equals($propertyName, $arguments[0]))->execute()->count();
239 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException(
'The method "' . $methodName .
'" is not supported by the repository.', 1233180480);
249 return static::class;