‪TYPO3CMS  ‪main
TYPO3\CMS\Extbase\Persistence\Repository Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Persistence\Repository:
TYPO3\CMS\Extbase\Persistence\RepositoryInterface TYPO3\CMS\Extbase\Persistence\RepositoryInterface TYPO3\CMS\Core\SingletonInterface TYPO3\CMS\Beuser\Domain\Repository\BackendUserGroupRepository TYPO3\CMS\Beuser\Domain\Repository\BackendUserGroupRepository TYPO3\CMS\Beuser\Domain\Repository\BackendUserRepository TYPO3\CMS\Beuser\Domain\Repository\BackendUserRepository TYPO3\CMS\Beuser\Domain\Repository\FileMountRepository TYPO3\CMS\Beuser\Domain\Repository\FileMountRepository TYPO3\CMS\Extbase\Tests\Unit\Persistence\Fixture\Domain\Repository\EntityRepository TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository TYPO3Tests\BlogExample\Domain\Repository\AdministratorRepository TYPO3Tests\BlogExample\Domain\Repository\AdministratorRepository TYPO3Tests\BlogExample\Domain\Repository\BlogRepository TYPO3Tests\BlogExample\Domain\Repository\BlogRepository TYPO3Tests\BlogExample\Domain\Repository\PersonRepository TYPO3Tests\BlogExample\Domain\Repository\PersonRepository TYPO3Tests\BlogExample\Domain\Repository\PostRepository TYPO3Tests\BlogExample\Domain\Repository\PostRepository TYPO3Tests\BlogExample\Domain\Repository\RegistryEntryRepository TYPO3Tests\BlogExample\Domain\Repository\RegistryEntryRepository TYPO3Tests\BlogExample\Domain\Repository\TtContentRepository TYPO3Tests\BlogExample\Domain\Repository\TtContentRepository TYPO3Tests\ParentChildTranslation\Domain\Repository\MainRepository TYPO3Tests\ParentChildTranslation\Domain\Repository\MainRepository TYPO3Tests\TestIrreForeignfield\Domain\Repository\ContentRepository

Public Member Functions

 __construct ()
 
 add ($object)
 
 remove ($object)
 
 update ($modifiedObject)
 
QueryResultInterface array findAll ()
 
int countAll ()
 
 removeAll ()
 
object null findByUid ($uid)
 
object null findByIdentifier ($identifier)
 
 setDefaultOrderings (array $defaultOrderings)
 
 setDefaultQuerySettings (QuerySettingsInterface $defaultQuerySettings)
 
QueryInterface createQuery ()
 
mixed __call ($methodName, $arguments)
 
QueryResultInterface findBy (array $criteria, array $orderBy=null, int $limit=null, int $offset=null)
 
 findOneBy (array $criteria, array $orderBy=null)
 
 count (array $criteria)
 

Protected Member Functions

class string< static > getRepositoryClassName ()
 

Protected Attributes

PersistenceManagerInterface $persistenceManager
 
string $objectType
 
array< non-empty-string, $defaultOrderings=array();protected QuerySettingsInterface $defaultQuerySettings;public function injectPersistenceManager(PersistenceManagerInterface $persistenceManager) { $this-> persistenceManager = $persistenceManager
 

Detailed Description

The base repository - will usually be extended by a more concrete repository. @template T of \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface <T>

Definition at line 29 of file Repository.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Persistence\Repository::__construct ( )

Member Function Documentation

◆ __call()

mixed TYPO3\CMS\Extbase\Persistence\Repository::__call (   $methodName,
  $arguments 
)

Dispatches magic methods (findBy[Property]())

Parameters
non-empty-string$methodName‪The name of the magic method
array<int,mixed>‪$arguments The arguments of the magic method
Exceptions
UnsupportedMethodException
Returns
‪mixed
Deprecated:
‪since v12, will be removed in v14, use {
See also
findBy}, {
findOneBy} and {
count} instead

Definition at line 224 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\createQuery().

Referenced by TYPO3\CMS\Extbase\Tests\Unit\Persistence\RepositoryTest\magicCallMethodTriggersAnErrorIfUnknownMethodsAreCalled().

◆ add()

TYPO3\CMS\Extbase\Persistence\Repository::add (   $object)

Adds an object to this repository

Parameters
object$object‪The object to add @phpstan-param T $object
Exceptions
Exception

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 71 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\persistenceManager.

◆ count()

TYPO3\CMS\Extbase\Persistence\Repository::count ( array  $criteria)

◆ countAll()

int TYPO3\CMS\Extbase\Persistence\Repository::countAll ( )

Returns the total number objects of this repository.

Returns
‪int The object count

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Reimplemented in TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository.

Definition at line 126 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\createQuery(), and TYPO3\CMS\Extbase\Persistence\QueryInterface\execute().

◆ createQuery()

QueryInterface TYPO3\CMS\Extbase\Persistence\Repository::createQuery ( )

Returns a query for objects of this repository

Returns
QueryInterface @phpstan-return QueryInterface<T>

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Reimplemented in TYPO3\CMS\Beuser\Domain\Repository\BackendUserRepository, and TYPO3\CMS\Beuser\Domain\Repository\BackendUserGroupRepository.

Definition at line 203 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\persistenceManager.

Referenced by TYPO3\CMS\Extbase\Persistence\Repository\__call(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\countAll(), TYPO3\CMS\Extbase\Persistence\Repository\countAll(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findAll(), TYPO3\CMS\Extbase\Persistence\Repository\findAll(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findAllByBlog(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findAllCommunityDistributions(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findAllOfficialDistributions(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findAllSortedByCategory(), TYPO3\CMS\Extbase\Persistence\Repository\findBy(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findByCategory(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findByExtensionKeyOrderedByVersion(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findByTagAndBlog(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findByVersionRangeAndExtensionKeyOrderedByVersion(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findHighestAvailableVersion(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findNext(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findOneByCurrentVersionByExtensionKey(), TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\findOneByExtensionKeyAndVersion(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findPrevious(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findRecentByBlog(), TYPO3Tests\BlogExample\Domain\Repository\PostRepository\findRemaining(), and TYPO3Tests\ParentChildTranslation\Domain\Repository\MainRepository\initializeObject().

◆ findAll()

QueryResultInterface array TYPO3\CMS\Extbase\Persistence\Repository::findAll ( )

◆ findBy()

QueryResultInterface TYPO3\CMS\Extbase\Persistence\Repository::findBy ( array  $criteria,
array  $orderBy = null,
int  $limit = null,
int  $offset = null 
)

@phpstan-param array<non-empty-string, mixed> $criteria @phpstan-param array<non-empty-string, QueryInterface::ORDER_*>|null $orderBy @phpstan-param 0|positive-int|null $limit @phpstan-param 0|positive-int|null $offset @phpstan-return QueryResultInterface<T>

Returns
QueryResultInterface

Definition at line 272 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\count(), and TYPO3\CMS\Extbase\Persistence\Repository\createQuery().

Referenced by TYPO3\CMS\Extbase\Persistence\Repository\count(), and TYPO3\CMS\Extbase\Persistence\Repository\findOneBy().

◆ findByIdentifier()

object null TYPO3\CMS\Extbase\Persistence\Repository::findByIdentifier (   $identifier)

Finds an object matching the given identifier.

Parameters
mixed$identifier‪The identifier of the object to find
Returns
‪object|null The matching object if found, otherwise NULL @phpstan-return T|null

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 161 of file Repository.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Extbase\Persistence\Repository\persistenceManager.

Referenced by TYPO3\CMS\Extbase\Persistence\Repository\findByUid().

◆ findByUid()

object null TYPO3\CMS\Extbase\Persistence\Repository::findByUid (   $uid)

Finds an object matching the given identifier.

Parameters
int$uid‪The identifier of the object to find
Returns
‪object|null The matching object if found, otherwise NULL @phpstan-return T|null

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 149 of file Repository.php.

References TYPO3\CMS\Webhooks\Message\$uid, and TYPO3\CMS\Extbase\Persistence\Repository\findByIdentifier().

Referenced by TYPO3\CMS\Extbase\Tests\Unit\Persistence\RepositoryTest\findByUidReturnsResultOfGetObjectByIdentifierCall().

◆ findOneBy()

TYPO3\CMS\Extbase\Persistence\Repository::findOneBy ( array  $criteria,
array  $orderBy = null 
)

@phpstan-param array<non-empty-string, mixed> $criteria @phpstan-param array<non-empty-string, QueryInterface::ORDER_*>|null $orderBy @phpstan-return T|null

Definition at line 306 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\findBy(), and TYPO3\CMS\Extbase\Persistence\QueryResultInterface\getFirst().

◆ getRepositoryClassName()

class string<static> TYPO3\CMS\Extbase\Persistence\Repository::getRepositoryClassName ( )
protected

Returns the class name of this class.

Returns
‪class-string<static> Class name of the repository.

Definition at line 325 of file Repository.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Repository\__construct().

◆ remove()

TYPO3\CMS\Extbase\Persistence\Repository::remove (   $object)

Removes an object from this repository.

Parameters
object$object‪The object to remove @phpstan-param T $object
Exceptions
Exception

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 86 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\persistenceManager.

◆ removeAll()

TYPO3\CMS\Extbase\Persistence\Repository::removeAll ( )

Removes all objects of this repository as if remove() was called for all of them.

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 135 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\findAll().

◆ setDefaultOrderings()

TYPO3\CMS\Extbase\Persistence\Repository::setDefaultOrderings ( array  $defaultOrderings)

Sets the property names to order the result by per default. Expected like this: array( 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING )

Parameters
array<non-empty-string,QueryInterface::ORDER_*>‪$defaultOrderings The property names to order by

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 176 of file Repository.php.

◆ setDefaultQuerySettings()

TYPO3\CMS\Extbase\Persistence\Repository::setDefaultQuerySettings ( QuerySettingsInterface  $defaultQuerySettings)

Sets the default query settings to be used in this repository.

A typical use case is an initializeObject() method that creates a QuerySettingsInterface object, configures it and sets it to be used for all queries created by the repository.

Warning: Using this setter fully overrides native query settings created by QueryFactory->create(). This especially means that storagePid settings from configuration are not applied anymore, if not explicitly set. Make sure to apply these to your own QuerySettingsInterface object if needed, when using this method.

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 192 of file Repository.php.

Referenced by TYPO3\CMS\Beuser\Domain\Repository\FileMountRepository\initializeObject(), TYPO3Tests\ParentChildTranslation\Domain\Repository\MainRepository\initializeObject(), and TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository\initializeObject().

◆ update()

TYPO3\CMS\Extbase\Persistence\Repository::update (   $modifiedObject)

Replaces an existing object with the same identifier by the given object

Parameters
object$modifiedObject‪The modified object @phpstan-param T $modifiedObject
Exceptions
Exception

Implements TYPO3\CMS\Extbase\Persistence\RepositoryInterface.

Definition at line 102 of file Repository.php.

References TYPO3\CMS\Extbase\Persistence\Repository\persistenceManager.

Referenced by TYPO3\CMS\Extbase\Tests\Unit\Persistence\RepositoryTest\updateChecksObjectType().

Member Data Documentation

◆ $objectType

string TYPO3\CMS\Extbase\Persistence\Repository::$objectType
protected

@phpstan-var class-string<T>

Definition at line 38 of file Repository.php.

◆ $persistenceManager

PersistenceManagerInterface TYPO3\CMS\Extbase\Persistence\Repository::$persistenceManager
protected

Definition at line 33 of file Repository.php.

◆ persistenceManager

array<non-empty-string, $defaultOrderings = array( ); protected QuerySettingsInterface $defaultQuerySettings; public function injectPersistenceManager(PersistenceManagerInterface $persistenceManager) { $this-> TYPO3\CMS\Extbase\Persistence\Repository::persistenceManager = $persistenceManager
protected