Documentation

MediaSource extends DataSource

Class MediaSource

Tags
copyright

Cloudrexx AG

author

Robin Glauser robin.glauser@comvation.com

subpackage

coremodule_mediabrowser

Table of Contents

Properties

$accessIds  : array<string|int, mixed>
Array with access ids to use with \Permission::checkAccess($id, 'static', true)
$dataAccesses  : Collection
$directory  : array<string|int, mixed>
Array with the web and normal path to the directory.
$fileSystem  : FileSystem
$humanName  : string
Human readable name
$id  : int
$identifier  : string
$isIndexingActivated  : bool
$localeCodes  : array<string|int, mixed>
List of locale codes ordered by translation fallback order per Cx instance
$name  : string
Name of the mediatype e.g. files, shop, media1
$nestingCount  : int
Counts the nesting level of __call()
$options  : string
$position  : int
$stringRepresentationBlank  : bool
Whether blank string representations are valid
$stringRepresentationFields  : array<string|int, mixed>
List of fields that should be available in the string representation
$stringRepresentationFormat  : string
Sprintf format for the string representation
$supportedOperations  : array<string|int, mixed>
List of operations supported by this DataSource
$systemComponentController  : SystemComponentController
$type  : string
$validators  : array<string|int, mixed>
Initialize this array as follows: array( 'columName' => Zend_Validate )
$virtual  : bool
Defines if an entity is virtual and therefore not persistable.

Methods

__call()  : mixed
Route methods like getName(), getType(), getDirectory(), etc.
__construct()  : mixed
Constructor
__get()  : mixed
This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.
__toString()  : string
Returns this entity's identifying value
add()  : mixed
Adds a new entry to this DataSource
addDataAccess()  : DataSource
Add dataAccesses
checkAccess()  : bool
get()  : array<string|int, mixed>
Gets one or more entries from this DataSource
getAccessIds()  : array<string|int, mixed>
getComponentController()  : SystemComponent
Returns the component controller for this component
getCurrentVersion()  : int
Returns version number if DataSource is versionable
getDataAccesses()  : type
Get the data access
getDirectory()  : array<string|int, mixed>
getFileSystem()  : FileSystem
getFileSystemMatches()  : array<string|int, mixed>
Get all matches from search term.
getHumanName()  : string
getId()  : int
Get id
getIdentifier()  : string
Get the identifier
getIdentifierFieldNames()  : array<string|int, mixed>
Returns a list of field names that uniquely identify objects
getKeyAsString()  : string
Returns this entity's key
getName()  : string
getOption()  : mixed
Get an option by key
getOptions()  : array<string|int, mixed>
Get the options
getPosition()  : int
getSupportedOperations()  : array<string|int, mixed>
Returns the list of operations supported by this DataSource
getSystemComponentController()  : SystemComponentController
getTranslatedFieldValue()  : mixed
Returns the value of a translatable field using fallback mechanisms
getType()  : string
Get the type
hasField()  : bool
Tells whether this DataSource has a field named $field
initializeValidators()  : mixed
Set $this->validators
isIndexingActivated()  : bool
Get information if indexer is activated
isVersionable()  : bool
Returns if DataSource supports versioning
isVirtual()  : bool
Returns the virtuality of the entity
listFields()  : array<string|int, mixed>
Returns a list of field names this DataSource consists of
remove()  : mixed
Drops an entry from this DataSource
removeDataAccess()  : mixed
Remove dataAccesses
setAccessIds()  : mixed
setDataAccesses()  : mixed
Set the data access
setHumanName()  : mixed
setIdentifier()  : mixed
Set the identifier
setIndexingActivated()  : void
Define if indexer is activated
setName()  : mixed
setOptions()  : mixed
Set the options
setPosition()  : mixed
setVirtual()  : mixed
Set the virtuality of the entity
supportsOperation()  : bool
Tells whether operation $operation is supported by this DataSource
update()  : mixed
Updates an existing entry of this DataSource
validate()  : mixed
getAllFilesAsObjects()  : array<string|int, mixed>
Returns an array with all file paths of all files in this directory, including files located in subdirectories.
getFallbackLocaleCodes()  : array<string|int, mixed>
Returns a list of all locale codes ordered by fallback order
getMediaSource()  : MediaSource
Returns the real instance of this MediaSource
getStringRepresentationBlank()  : bool
Whether blank string representations are valid
getStringRepresentationFields()  : array<string|int, mixed>
Returns a list of fields available in the string representation
getStringRepresentationFormat()  : string
Returns the sprintf() format for the string representation

Properties

$accessIds

Array with access ids to use with \Permission::checkAccess($id, 'static', true)

protected array<string|int, mixed> $accessIds = array()

Accepts various formats. Most basic is as follows: array( [,,...] )

This will set the access as follows:

  • for both, read and write access, the user must have access to every listed id (as specified by ).

Use the following format instead, to change the requirement of having access to all listed IDs, but instead only one of the listed IDs: array( 'any' => array( [,,...] ), )

To set different read and write access permissions, do specify as follows: array( 'read' => array( [,,...] ), 'write' => array( [,,...] ), )

Again, to make the user only require having access to one of the listed IDs, do specify as follows: array( 'read' => array( 'any' => array( [,,...] ), ), 'write' => array( 'any' => array( [,,...] ), ), )

$directory

Array with the web and normal path to the directory.

protected array<string|int, mixed> $directory = array()

e.g: array( $this->cx->getWebsiteImagesContentPath(), $this->cx->getWebsiteImagesContentWebPath(), )

$isIndexingActivated

protected bool $isIndexingActivated

if indexer is activated

$localeCodes

List of locale codes ordered by translation fallback order per Cx instance

protected static array<string|int, mixed> $localeCodes = array()

Array in the form: array(<instanceId> => array(<localeCode>, ...))

Tags
see
getFallbackLocaleCodes()

$name

Name of the mediatype e.g. files, shop, media1

protected string $name

$nestingCount

Counts the nesting level of __call()

protected static int $nestingCount = 0

$stringRepresentationBlank

Whether blank string representations are valid

protected bool $stringRepresentationBlank = false

Whether blank string representations are valid

Tags
see
getStringRepresentationBlank()

$stringRepresentationFields

List of fields that should be available in the string representation

protected array<string|int, mixed> $stringRepresentationFields = array()

List of field names

Tags
see
getStringRepresentationFields()

$stringRepresentationFormat

Sprintf format for the string representation

protected string $stringRepresentationFormat = ''

Sprintf format string

Tags
see
getStringRepresentationFormat()

$supportedOperations

List of operations supported by this DataSource

protected array<string|int, mixed> $supportedOperations = array()

List of operations

$validators

Initialize this array as follows: array( 'columName' => Zend_Validate )

protected array<string|int, mixed> $validators = array()

$virtual

Defines if an entity is virtual and therefore not persistable.

protected bool $virtual = false

Defaults to FALSE - not virtual.

Methods

__call()

Route methods like getName(), getType(), getDirectory(), etc.

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

Name of method to call

$arguments : array<string|int, mixed>

List of arguments for the method to call

Tags
throws
Exception

If __call() nesting level reaches 20

Attributes
#[ReturnTypeWillChange]
Return values
mixed

Return value of the method to call

__construct()

Constructor

public __construct(mixed $name, mixed $humanName, mixed $directory[, mixed $accessIds = array() ][, mixed $position = '' ][, FileSystem $fileSystem = null ][, SystemComponentController $systemComponentController = null ][, mixed $isIndexingActivated = true ]) : mixed
Parameters
$name : mixed
$humanName : mixed
$directory : mixed
$accessIds : mixed = array()
$position : mixed = ''
$fileSystem : FileSystem = null
$systemComponentController : SystemComponentController = null
$isIndexingActivated : mixed = true

__get()

This is an ugly solution to allow $this->cx to be available in all entity classes Since the entity's constructor is not called when an entity is loaded from DB this cannot be assigned there.

public __get(mixed $name) : mixed
Parameters
$name : mixed
Attributes
#[ReturnTypeWillChange]

__toString()

Returns this entity's identifying value

public __toString() : string

By default this returns the same as getKeyAsString(), but this method might get overridden by subclasses.

Return values
string

Identifying value for this entity

add()

Adds a new entry to this DataSource

public add(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

Field=>value-type array. Not all fields may be required.

Tags
todo

Chunked upload is untested and will most likely not work

throws
Exception

If something did not go as planned

checkAccess()

public checkAccess([string $scope = 'read' ]) : bool
Parameters
$scope : string = 'read'

Set to 'read' or 'write' to check for specific access permissions.

Return values
bool

get()

Gets one or more entries from this DataSource

public get([mixed $elementId = array() ][, mixed $filter = array() ][, mixed $order = array() ][, mixed $limit = 0 ][, mixed $offset = 0 ][, mixed &$count = 0 ][, mixed $fieldList = array() ]) : array<string|int, mixed>
Parameters
$elementId : mixed = array()

(optional) field=>value-type condition array identifying an entry

$filter : mixed = array()

(optional) field=>value-type condition array, only supports = for now

$order : mixed = array()

(optional) field=>order-type array, order is either "ASC" or "DESC"

$limit : mixed = 0

(optional) If set, no more than $limit results are returned

$offset : mixed = 0

(optional) Entry to start with

$count : mixed = 0

(optional / passed by reference) Will be set to the total matched entries

$fieldList : mixed = array()

(optional) Limits the result to the values for the fields in this list

Tags
inheritdoc
Return values
array<string|int, mixed>

Two dimensional array (/table) of results (array($row=>array($fieldName=>$value)))

getAccessIds()

public getAccessIds() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCurrentVersion()

Returns version number if DataSource is versionable

public getCurrentVersion(array<string|int, mixed> $elementId) : int

You can use this method to get the current version number of a DataSource. If the DataSource is not versionable, the default value is 0. Version number needs to be >= 1 to be versionable, 0 is no valid version number. Subclasses can overwrite this method isVersionable()

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

array identifying an entry

Return values
int

see description above

getDataAccesses()

Get the data access

public getDataAccesses() : type
Return values
type

getDirectory()

public getDirectory() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFileSystemMatches()

Get all matches from search term.

public getFileSystemMatches(mixed $searchterm, mixed $path[, mixed $limit = null ][, mixed $offset = null ][, mixed &$count = 0 ]) : array<string|int, mixed>
Parameters
$searchterm : mixed

string term to search

$path : mixed

string path to search in

$limit : mixed = null

int|null (optional) Limits the max number of results

$offset : mixed = null

int|null (optional) Offset if $limit is used

$count : mixed = 0

int (optional, reference) Total number of results

Tags
todo

This currently only works for indexers that use the default index table. To allow other ways of storage a storage driver should be introduced. Indexers using the same storage driver could then still be queried at once.

throws
SystemComponentException
Return values
array<string|int, mixed>

Search results as specified by Search component

getIdentifier()

Get the identifier

public getIdentifier() : string
Return values
string

$identifier

getIdentifierFieldNames()

Returns a list of field names that uniquely identify objects

public getIdentifierFieldNames() : array<string|int, mixed>
Tags
inheritdoc
Return values
array<string|int, mixed>

List of field names

getKeyAsString()

Returns this entity's key

public final getKeyAsString([string $separator = '/' ]) : string

If this entity has a composite key, the fields are separated by $separator.

Parameters
$separator : string = '/'

(optional) Separator for composite key fields, default "/"

Return values
string

Entity key as string

getOption()

Get an option by key

public getOption(string $key) : mixed
Parameters
$key : string

Path to desired info, delimited by "."

Return values
mixed

Desired information or false if not found

getOptions()

Get the options

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

$options

getSupportedOperations()

Returns the list of operations supported by this DataSource

public getSupportedOperations() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of supported operations

getTranslatedFieldValue()

Returns the value of a translatable field using fallback mechanisms

public getTranslatedFieldValue(string $fieldName) : mixed

If the field is not translatable its value is returned anyway. Tries to return the value in the following locales (if non-empty):

  • Current locale
  • Default locale
  • All other locales
Parameters
$fieldName : string

Name of a translatable field

getType()

Get the type

public getType() : string
Return values
string

$type

hasField()

Tells whether this DataSource has a field named $field

public hasField(string $field) : bool
Parameters
$field : string

Name of a field

Return values
bool

True if $field exists in this DataSource, false otherwise

initializeValidators()

Set $this->validators

public initializeValidators() : mixed

Validators can be found in lib/FRAMEWORK/Validator.class.php These will be executed if validate() is called

isIndexingActivated()

Get information if indexer is activated

public isIndexingActivated() : bool
Return values
bool

isVersionable()

Returns if DataSource supports versioning

public isVersionable() : bool

This method is to ensure that DataAccess can check if DataSource supports versioning. The default value is set to false. If the desired DataSource should be versionable, this method can be overwritten to achieve this.

Return values
bool

If set true, DataSource supports versioning

isVirtual()

Returns the virtuality of the entity

public isVirtual() : bool
Return values
bool

TRUE if the entity is virtual, otherwise FALSE

listFields()

Returns a list of field names this DataSource consists of

public listFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of field names

remove()

Drops an entry from this DataSource

public remove(array<string|int, mixed> $elementId) : mixed
Parameters
$elementId : array<string|int, mixed>

field=>value-type condition array identifying an entry

Tags
throws
Exception

If something did not go as planned

setAccessIds()

public setAccessIds(array<string|int, mixed> $accessIds) : mixed
Parameters
$accessIds : array<string|int, mixed>

See DocBlock of {link $this->accessIds}

setHumanName()

public setHumanName(string $humanName) : mixed
Parameters
$humanName : string

setIdentifier()

Set the identifier

public setIdentifier(string $identifier) : mixed
Parameters
$identifier : string

setIndexingActivated()

Define if indexer is activated

public setIndexingActivated(mixed $activated) : void
Parameters
$activated : mixed

setOptions()

Set the options

public setOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

setPosition()

public setPosition(int $position) : mixed
Parameters
$position : int

setVirtual()

Set the virtuality of the entity

public setVirtual(bool $virtual) : mixed
Parameters
$virtual : bool

TRUE to set the entity as virtual or otherwise to FALSE

supportsOperation()

Tells whether operation $operation is supported by this DataSource

public supportsOperation(string $operation) : bool
Parameters
$operation : string

Name of an operation

Return values
bool

True if $operation is supported by this DataSource

update()

Updates an existing entry of this DataSource

public update(array<string|int, mixed> $elementId, array<string|int, mixed> $data) : mixed
Parameters
$elementId : array<string|int, mixed>

field=>value-type condition array identifying an entry

$data : array<string|int, mixed>

Field=>value-type array. Not all fields are required.

Tags
throws
Exception

If something did not go as planned

getAllFilesAsObjects()

Returns an array with all file paths of all files in this directory, including files located in subdirectories.

protected getAllFilesAsObjects(mixed $fileList, mixed $file, mixed $result) : array<string|int, mixed>
Parameters
$fileList : mixed

array all files and directories

$file : mixed

\Cx\Core\MediaSource\Model\Entity\LocalFile file to check

$result : mixed

array existing result

Return values
array<string|int, mixed>

with all files as \Cx\Core\MediaSource\Model\Entity\LocalFile

getFallbackLocaleCodes()

Returns a list of all locale codes ordered by fallback order

protected getFallbackLocaleCodes() : array<string|int, mixed>
  • First entry is the current locale
  • Second entry is the default locale (if different from current, it's omitted otherwise)
  • Then all other locales follow (in no particular order)
Tags
todo

Order the array by the fallback order (same as in ContentManager)

Return values
array<string|int, mixed>

List of locale codes

getMediaSource()

Returns the real instance of this MediaSource

protected getMediaSource() : MediaSource

DataSources are loaded from DB, MediaSources are loaded via event hooks, MediaSource is a DataSource --> MediaSources cannot be loaded from DB yet. As soon as this is possible this can be removed.

Return values
MediaSource

Real instance of this MediaSource

getStringRepresentationBlank()

Whether blank string representations are valid

protected getStringRepresentationBlank() : bool
Return values
bool

Whether blank string representations are valid

getStringRepresentationFields()

Returns a list of fields available in the string representation

protected getStringRepresentationFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of field names

getStringRepresentationFormat()

Returns the sprintf() format for the string representation

protected getStringRepresentationFormat() : string
Return values
string

sprintf() format string


        
On this page

Search results