TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AbstractRepository Class Reference
Inheritance diagram for AbstractRepository:
RepositoryInterface SingletonInterface FileRepository ProcessedFileRepository StorageRepository

Public Member Functions

 __construct ()
 
 add ($object)
 
 remove ($object)
 
 replace ($existingObject, $newObject)
 
 update ($modifiedObject)
 
 getAddedObjects ()
 
 getRemovedObjects ()
 
 findAll ()
 
 countAll ()
 
 removeAll ()
 
 findByUid ($uid)
 
 setDefaultOrderings (array $defaultOrderings)
 
 setDefaultQuerySettings (\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $defaultQuerySettings)
 
 createQuery ()
 
 findByIdentifier ($identifier)
 
 __call ($method, $arguments)
 
 getEntityClassName ()
 

Protected Member Functions

 createDomainObject (array $databaseRow)
 
 getWhereClauseForEnabledFields ()
 
 getEnvironmentMode ()
 
 getDatabaseConnection ()
 

Protected Attributes

 $table = ''
 
 $factory
 
 $typeField = ''
 
 $type = ''
 

Detailed Description

Abstract repository implementing the basic repository methods

Definition at line 20 of file AbstractRepository.php.

Constructor & Destructor Documentation

__construct ( )

Creates this object.

Definition at line 45 of file AbstractRepository.php.

Member Function Documentation

__call (   $method,
  $arguments 
)

Magic call method for repository methods.

Parameters
string$methodName of the method
array$argumentsThe arguments
Exceptions
\BadMethodCallException
Returns
void

Definition at line 274 of file AbstractRepository.php.

add (   $object)

Adds an object to this repository.

Parameters
object$objectThe object to add
Returns
void

Implements RepositoryInterface.

Definition at line 57 of file AbstractRepository.php.

countAll ( )

Returns the total number objects of this repository.

Returns
int The object count

Implements RepositoryInterface.

Definition at line 151 of file AbstractRepository.php.

createDomainObject ( array  $databaseRow)
abstractprotected

Creates an object managed by this repository.

Parameters
array$databaseRow
Returns
object

Referenced by AbstractRepository\findAll(), and AbstractRepository\findByUid().

createQuery ( )

Returns a query for objects of this repository

Exceptions
\BadMethodCallException
Returns

Implements RepositoryInterface.

Definition at line 248 of file AbstractRepository.php.

findAll ( )

Returns all objects of this repository.

Returns
array An array of objects, empty if no objects found

Implements RepositoryInterface.

Definition at line 120 of file AbstractRepository.php.

References $GLOBALS, AbstractRepository\createDomainObject(), and AbstractRepository\getWhereClauseForEnabledFields().

findByIdentifier (   $identifier)

Finds an object matching the given identifier.

Parameters
mixed$identifierThe identifier of the object to find
Returns
object|NULL The matching object if found, otherwise NULL

Implements RepositoryInterface.

Definition at line 260 of file AbstractRepository.php.

References AbstractRepository\findByUid().

findByUid (   $uid)

Finds an object matching the given identifier.

Parameters
int$uidThe identifier of the object to find
Exceptions
\RuntimeException
\InvalidArgumentException
Returns
object The matching object

Implements RepositoryInterface.

Definition at line 176 of file AbstractRepository.php.

References $GLOBALS, MathUtility\canBeInterpretedAsInteger(), AbstractRepository\createDomainObject(), and AbstractRepository\getWhereClauseForEnabledFields().

Referenced by AbstractRepository\findByIdentifier().

getAddedObjects ( )

Returns all objects of this repository add()ed but not yet persisted to the storage layer.

Returns
array An array of objects

Definition at line 100 of file AbstractRepository.php.

getDatabaseConnection ( )
protected
Returns

Definition at line 304 of file AbstractRepository.php.

References $GLOBALS.

getEntityClassName ( )

Returns the object type this repository is managing.

Returns
string

Definition at line 285 of file AbstractRepository.php.

getEnvironmentMode ( )
protected

Function to return the current TYPO3_MODE. This function can be mocked in unit tests to be able to test frontend behaviour.

Returns
string

Definition at line 296 of file AbstractRepository.php.

Referenced by AbstractRepository\getWhereClauseForEnabledFields().

getRemovedObjects ( )

Returns an array with objects remove()d from the repository that had been persisted to the storage layer before.

Returns
array

Definition at line 110 of file AbstractRepository.php.

getWhereClauseForEnabledFields ( )
protected

get the WHERE clause for the enabled fields of this TCA table depending on the context

Returns
string the additional where clause, something like " AND deleted=0 AND hidden=0"

Definition at line 194 of file AbstractRepository.php.

References $GLOBALS, and AbstractRepository\getEnvironmentMode().

Referenced by AbstractRepository\findAll(), AbstractRepository\findByUid(), and StorageRepository\initializeLocalCache().

remove (   $object)

Removes an object from this repository.

Parameters
object$objectThe object to remove
Returns
void

Implements RepositoryInterface.

Definition at line 68 of file AbstractRepository.php.

removeAll ( )

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

Returns
void

Implements RepositoryInterface.

Definition at line 162 of file AbstractRepository.php.

replace (   $existingObject,
  $newObject 
)

Replaces an object by another.

Parameters
object$existingObjectThe existing object
object$newObjectThe new object
Returns
void

Definition at line 80 of file AbstractRepository.php.

setDefaultOrderings ( array  $defaultOrderings)

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

Parameters
array$defaultOrderingsThe property names to order by
Exceptions
\BadMethodCallException
Returns
void

Implements RepositoryInterface.

Definition at line 222 of file AbstractRepository.php.

setDefaultQuerySettings ( \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface  $defaultQuerySettings)

Sets the default query settings to be used in this repository

Parameters
\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface$defaultQuerySettingsThe query settings to be used by default
Exceptions
\BadMethodCallException
Returns
void

Implements RepositoryInterface.

Definition at line 236 of file AbstractRepository.php.

update (   $modifiedObject)

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

Parameters
object$modifiedObjectThe modified object

Implements RepositoryInterface.

Definition at line 90 of file AbstractRepository.php.

Member Data Documentation

$factory
protected

Definition at line 30 of file AbstractRepository.php.

$table = ''
protected

Definition at line 25 of file AbstractRepository.php.

$type = ''
protected

Definition at line 40 of file AbstractRepository.php.

$typeField = ''
protected

Definition at line 35 of file AbstractRepository.php.