FileRepository extends AbstractRepository

Repository for accessing files it also serves as the public API for the indexing part of files in general

Tags
extends

AbstractRepository<File>

Table of Contents

Properties

$factory  : ResourceFactory
$objectType  : string
The main object type of this class. In some cases (fileReference) this repository can also return FileReference objects, implementing the common FileInterface.
$table  : string
Main File object storage table. Note that this repository also works on the sys_file_reference table when returning FileReference objects.
$type  : string
$typeField  : string

Methods

__call()  : mixed
Magic call method for repository methods.
__construct()  : mixed
Creates this object.
add()  : mixed
Adds an object to this repository.
countAll()  : int
Returns the total number objects of this repository.
createQuery()  : QueryInterface
Returns a query for objects of this repository
findAll()  : array<string|int, mixed>
Returns all objects of this repository.
findByIdentifier()  : object
Finds an object matching the given identifier.
findByRelation()  : array<string|int, mixed>
Find FileReference objects by relation to other records
findByUid()  : object
Finds an object matching the given identifier.
findFileReferenceByUid()  : FileReference|bool
Find FileReference objects by uid
getAddedObjects()  : array<string|int, mixed>
Returns all objects of this repository add()ed but not yet persisted to the storage layer.
getEntityClassName()  : string
Returns the object type this repository is managing.
getRemovedObjects()  : array<string|int, mixed>
Returns an array with objects remove()d from the repository that had been persisted to the storage layer before.
remove()  : mixed
Removes an object from this repository.
removeAll()  : mixed
Removes all objects of this repository as if remove() was called for all of them.
replace()  : mixed
Replaces an object by another.
setDefaultOrderings()  : mixed
Sets the property names to order the result by per default.
setDefaultQuerySettings()  : mixed
Sets the default query settings to be used in this repository
update()  : mixed
Replaces an existing object with the same identifier by the given object
createDomainObject()  : File
Creates an object managed by this repository.
getEnvironmentMode()  : string
Function to return the current application type based on $GLOBALS['TSFE'].
reapplySorting()  : array<string|int, mixed>
As sorting might have changed due to workspace overlays, PHP does the sorting again.

Properties

$objectType

The main object type of this class. In some cases (fileReference) this repository can also return FileReference objects, implementing the common FileInterface.

protected string $objectType = \TYPO3\CMS\Core\Resource\File::class

$table

Main File object storage table. Note that this repository also works on the sys_file_reference table when returning FileReference objects.

protected string $table = 'sys_file'

$typeField

protected string $typeField = ''

Methods

__call()

Magic call method for repository methods.

public __call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
$method : string

Name of the method

$arguments : array<string|int, mixed>

The arguments

Internal
Tags
throws
BadMethodCallException

__construct()

Creates this object.

public __construct() : mixed

add()

Adds an object to this repository.

public add(object $object) : mixed
Parameters
$object : object

The object to add

Tags
phpstan-param

T $object

countAll()

Returns the total number objects of this repository.

public countAll() : int
Return values
int

The object count

findAll()

Returns all objects of this repository.

public findAll() : array<string|int, mixed>
Tags
phpstan-return

iterable<T>

Return values
array<string|int, mixed>

An array of objects, empty if no objects found

findByIdentifier()

Finds an object matching the given identifier.

public findByIdentifier(mixed $identifier) : object
Parameters
$identifier : mixed

The identifier of the object to find

Tags
throws
RuntimeException
throws
InvalidArgumentException
phpstan-return

T

Return values
object

The matching object if found

findByRelation()

Find FileReference objects by relation to other records

public findByRelation(string $tableName, string $fieldName, int $uid[, int|null $workspaceId = null ]) : array<string|int, mixed>
Parameters
$tableName : string

Table name of the related record

$fieldName : string

Field name of the related record

$uid : int

The UID of the related record (needs to be the localized uid, as translated IRRE elements relate to them)

$workspaceId : int|null = null
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

An array of objects, empty if no objects found

findByUid()

Finds an object matching the given identifier.

public findByUid(int $uid) : object
Parameters
$uid : int

The identifier of the object to find

Tags
throws
RuntimeException
throws
InvalidArgumentException
phpstan-return

T

Return values
object

The matching object

findFileReferenceByUid()

Find FileReference objects by uid

public findFileReferenceByUid(int $uid) : FileReference|bool
Parameters
$uid : int

The UID of the sys_file_reference record

Tags
throws
InvalidArgumentException
Return values
FileReference|bool

getAddedObjects()

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

public getAddedObjects() : array<string|int, mixed>
Internal
Tags
phpstan-return

T[]

Return values
array<string|int, mixed>

An array of objects

getEntityClassName()

Returns the object type this repository is managing.

public getEntityClassName() : string
Return values
string

getRemovedObjects()

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

public getRemovedObjects() : array<string|int, mixed>
Internal
Tags
phpstan-return

T[]

Return values
array<string|int, mixed>

remove()

Removes an object from this repository.

public remove(object $object) : mixed
Parameters
$object : object

The object to remove

Tags
phpstan-param

T $object

removeAll()

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

public removeAll() : mixed

replace()

Replaces an object by another.

public replace(object $existingObject, object $newObject) : mixed
Parameters
$existingObject : object

The existing object

$newObject : object

The new object

Tags
phpstan-param

T $existingObject

phpstan-param

T $newObject

setDefaultOrderings()

Sets the property names to order the result by per default.

public setDefaultOrderings(array<string|int, mixed> $defaultOrderings) : mixed

Expected like this: array( 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING )

Parameters
$defaultOrderings : array<string|int, mixed>

The property names to order by

Tags
throws
BadMethodCallException

setDefaultQuerySettings()

Sets the default query settings to be used in this repository

public setDefaultQuerySettings(QuerySettingsInterface $defaultQuerySettings) : mixed
Parameters
$defaultQuerySettings : QuerySettingsInterface

The query settings to be used by default

Tags
throws
BadMethodCallException

update()

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

public update(object $modifiedObject) : mixed
Parameters
$modifiedObject : object

The modified object

Tags
phpstan-param

T $modifiedObject

createDomainObject()

Creates an object managed by this repository.

protected createDomainObject(array<string|int, mixed> $databaseRow) : File
Parameters
$databaseRow : array<string|int, mixed>
Return values
File

getEnvironmentMode()

Function to return the current application type based on $GLOBALS['TSFE'].

protected getEnvironmentMode() : string

This function can be mocked in unit tests to be able to test frontend behaviour.

Return values
string

reapplySorting()

As sorting might have changed due to workspace overlays, PHP does the sorting again.

protected reapplySorting(array<string|int, mixed> $itemList) : array<string|int, mixed>
Parameters
$itemList : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results