PHP Class Bravo3\Orm\Services\EntityManager

Inheritance: use trait Bravo3\Orm\Traits\ProxyAwareTrait
Afficher le fichier Open project: bravo3/orm Class Usage Examples

Protected Properties

Свойство Type Description
$cache Bravo3\Orm\Services\Cache\EntityCachingInterface
$config Bravo3\Orm\Config\Configuration
$dispatcher Symfony\Component\EventDispatcher\EventDispatcher
$driver Bravo3\Orm\Drivers\DriverInterface
$index_manager IndexManager
$key_scheme Bravo3\Orm\KeySchemes\KeySchemeInterface
$maintenance_mode boolean
$mapper Bravo3\Orm\Mappers\MapperInterface
$query_manager QueryManager
$relationship_manager RelationshipManager
$serialiser_map Bravo3\Orm\Serialisers\SerialiserMap

Méthodes publiques

Méthode Description
addListener ( string $event_name, callable $listener, integer $priority ) Add an event listener
addSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber ) Add an event subscriber
build ( Bravo3\Orm\Drivers\DriverInterface $driver, Bravo3\Orm\Mappers\MapperInterface $mapper, SerialiserMap $serialiser_map = null, Bravo3\Orm\KeySchemes\KeySchemeInterface $key_scheme = null, Configuration $configuration = null, Bravo3\Orm\Services\Cache\EntityCachingInterface $cache = null ) : EntityManager Create a new entity manager
delete ( object $entity ) Delete an entity
flush ( ) Execute the current unit of work
getCache ( ) : Bravo3\Orm\Services\Cache\EntityCachingInterface Get caching service
getConfig ( ) : Configuration Get Config
getDispatcher ( ) : EventDispatcher Get the event dispatcher, lazy-loading
getDriver ( ) : Bravo3\Orm\Drivers\DriverInterface Get the underlying driver
getKeyScheme ( ) : Bravo3\Orm\KeySchemes\KeySchemeInterface Get the key scheme
getMaintenanceMode ( ) : boolean Get the state of the maintenance mode
getMapper ( ) : Bravo3\Orm\Mappers\MapperInterface Get the entity mapper
getSerialiserMap ( ) : SerialiserMap Get the serialiser mappings
indexedQuery ( IndexedQuery $query, boolean $use_cache = true ) : QueryResult Create a query against a table matching one or more indices
persist ( object $entity, integer $ttl = null ) Persist an entity
purge ( ) Purge the current unit of work, clearing any unexecuted commands
refresh ( object &$entity ) : object Will force a database update of an entity
retrieve ( string $class_name, string $id, boolean $use_cache = true ) : object Retrieve an entity, throwing a NotFoundException if the entity is not found
retrieveByIndex ( string $class_name, string $index_name, string $index_key, boolean $use_cache = true ) : object Retrieve an entity by an index
retrieveEntityOrNew ( string $class_name, integer $id, boolean $use_cache = true ) : object Retrieve an entity, creating a new instance if the entity is not found
retrieveEntityOrNull ( string $class_name, integer $id, boolean $use_cache = true ) : null | object Retrieve an entity, returning null if the entity is not found
setCache ( Bravo3\Orm\Services\Cache\EntityCachingInterface $cache ) Set caching service
setConfig ( Configuration $config ) Set Config
setMaintenanceMode ( boolean $enabled = true ) Enable or disable maintenance mode
setSerialiserMap ( SerialiserMap $serialiser_map ) Set the serialiser map
sortedQuery ( SortedQuery $query, boolean $check_full_set_size = false, boolean $use_cache = true ) : QueryResult Get all foreign entities ordered by a sort column

Méthodes protégées

Méthode Description
__construct ( Bravo3\Orm\Drivers\DriverInterface $driver, Bravo3\Orm\Mappers\MapperInterface $mapper, SerialiserMap $serialiser_map = null, Bravo3\Orm\KeySchemes\KeySchemeInterface $key_scheme = null, Configuration $configuration = null, Bravo3\Orm\Services\Cache\EntityCachingInterface $cache = null ) Create a raw entity manager
getIndexManager ( ) : IndexManager Lazy-loading index manager
getQueryManager ( ) : QueryManager Lazy-loading query manager
getRelationshipManager ( ) : RelationshipManager Lazy-loading relationship manager
registerDefaultSubscribers ( ) Register default event subscribers

Private Methods

Méthode Description
validateId ( string $id ) Throw an InvalidIdException if an ID contains illegal chars

Method Details

__construct() protected méthode

Do not construct an entity manager directly or it will lack access interceptors which are responsible for caching and event dispatching.
See also: EntityManager::build()
protected __construct ( Bravo3\Orm\Drivers\DriverInterface $driver, Bravo3\Orm\Mappers\MapperInterface $mapper, SerialiserMap $serialiser_map = null, Bravo3\Orm\KeySchemes\KeySchemeInterface $key_scheme = null, Configuration $configuration = null, Bravo3\Orm\Services\Cache\EntityCachingInterface $cache = null )
$driver Bravo3\Orm\Drivers\DriverInterface
$mapper Bravo3\Orm\Mappers\MapperInterface
$serialiser_map Bravo3\Orm\Serialisers\SerialiserMap
$key_scheme Bravo3\Orm\KeySchemes\KeySchemeInterface
$configuration Bravo3\Orm\Config\Configuration
$cache Bravo3\Orm\Services\Cache\EntityCachingInterface

addListener() public méthode

Add an event listener
public addListener ( string $event_name, callable $listener, integer $priority )
$event_name string
$listener callable
$priority integer

addSubscriber() public méthode

Add an event subscriber
public addSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber )
$subscriber Symfony\Component\EventDispatcher\EventSubscriberInterface

build() public static méthode

Create a new entity manager
public static build ( Bravo3\Orm\Drivers\DriverInterface $driver, Bravo3\Orm\Mappers\MapperInterface $mapper, SerialiserMap $serialiser_map = null, Bravo3\Orm\KeySchemes\KeySchemeInterface $key_scheme = null, Configuration $configuration = null, Bravo3\Orm\Services\Cache\EntityCachingInterface $cache = null ) : EntityManager
$driver Bravo3\Orm\Drivers\DriverInterface
$mapper Bravo3\Orm\Mappers\MapperInterface
$serialiser_map Bravo3\Orm\Serialisers\SerialiserMap
$key_scheme Bravo3\Orm\KeySchemes\KeySchemeInterface
$configuration Bravo3\Orm\Config\Configuration
$cache Bravo3\Orm\Services\Cache\EntityCachingInterface
Résultat EntityManager

delete() public méthode

Any modifications to the entity will be ignored; the persisted state (ID, relationships) of the entity will be deleted. If a new entity is passed to this function, any persisted entity with matching ID & class will be deleted. No error will be raised if a persisted entity is not matched.
public delete ( object $entity )
$entity object

flush() public méthode

Execute the current unit of work
public flush ( )

getCache() public méthode

Get caching service
public getCache ( ) : Bravo3\Orm\Services\Cache\EntityCachingInterface
Résultat Bravo3\Orm\Services\Cache\EntityCachingInterface

getConfig() public méthode

Get Config
public getConfig ( ) : Configuration
Résultat Bravo3\Orm\Config\Configuration

getDispatcher() public méthode

Get the event dispatcher, lazy-loading
public getDispatcher ( ) : EventDispatcher
Résultat Symfony\Component\EventDispatcher\EventDispatcher

getDriver() public méthode

Get the underlying driver
public getDriver ( ) : Bravo3\Orm\Drivers\DriverInterface
Résultat Bravo3\Orm\Drivers\DriverInterface

getIndexManager() protected méthode

Lazy-loading index manager
protected getIndexManager ( ) : IndexManager
Résultat IndexManager

getKeyScheme() public méthode

Get the key scheme
public getKeyScheme ( ) : Bravo3\Orm\KeySchemes\KeySchemeInterface
Résultat Bravo3\Orm\KeySchemes\KeySchemeInterface

getMaintenanceMode() public méthode

Get the state of the maintenance mode
public getMaintenanceMode ( ) : boolean
Résultat boolean

getMapper() public méthode

Get the entity mapper
public getMapper ( ) : Bravo3\Orm\Mappers\MapperInterface
Résultat Bravo3\Orm\Mappers\MapperInterface

getQueryManager() protected méthode

Lazy-loading query manager
protected getQueryManager ( ) : QueryManager
Résultat QueryManager

getRelationshipManager() protected méthode

Lazy-loading relationship manager
protected getRelationshipManager ( ) : RelationshipManager
Résultat RelationshipManager

getSerialiserMap() public méthode

Get the serialiser mappings
public getSerialiserMap ( ) : SerialiserMap
Résultat Bravo3\Orm\Serialisers\SerialiserMap

indexedQuery() public méthode

Create a query against a table matching one or more indices
public indexedQuery ( IndexedQuery $query, boolean $use_cache = true ) : QueryResult
$query Bravo3\Orm\Query\IndexedQuery
$use_cache boolean
Résultat Bravo3\Orm\Query\QueryResult

persist() public méthode

Persist an entity
public persist ( object $entity, integer $ttl = null )
$entity object Entity object to persist
$ttl integer Optional TTL if the driver supports it, seconds past current time

purge() public méthode

Purge the current unit of work, clearing any unexecuted commands
public purge ( )

refresh() public méthode

This will also convert a fresh entity to an OrmProxyInterface.
public refresh ( object &$entity ) : object
$entity object
Résultat object

registerDefaultSubscribers() protected méthode

Register default event subscribers

retrieve() public méthode

Retrieve an entity, throwing a NotFoundException if the entity is not found
public retrieve ( string $class_name, string $id, boolean $use_cache = true ) : object
$class_name string
$id string
$use_cache boolean
Résultat object

retrieveByIndex() public méthode

Retrieve an entity by an index
public retrieveByIndex ( string $class_name, string $index_name, string $index_key, boolean $use_cache = true ) : object
$class_name string
$index_name string
$index_key string
$use_cache boolean
Résultat object

retrieveEntityOrNew() public méthode

NB: The entity must be able to be constructed without constructor arguments.
public retrieveEntityOrNew ( string $class_name, integer $id, boolean $use_cache = true ) : object
$class_name string
$id integer
$use_cache boolean
Résultat object

retrieveEntityOrNull() public méthode

Retrieve an entity, returning null if the entity is not found
public retrieveEntityOrNull ( string $class_name, integer $id, boolean $use_cache = true ) : null | object
$class_name string
$id integer
$use_cache boolean
Résultat null | object

setCache() public méthode

Set caching service
public setCache ( Bravo3\Orm\Services\Cache\EntityCachingInterface $cache )
$cache Bravo3\Orm\Services\Cache\EntityCachingInterface

setConfig() public méthode

Set Config
public setConfig ( Configuration $config )
$config Bravo3\Orm\Config\Configuration

setMaintenanceMode() public méthode

Enable or disable maintenance mode
public setMaintenanceMode ( boolean $enabled = true )
$enabled boolean

setSerialiserMap() public méthode

Set the serialiser map
public setSerialiserMap ( SerialiserMap $serialiser_map )
$serialiser_map Bravo3\Orm\Serialisers\SerialiserMap

sortedQuery() public méthode

If you have applied a limit to the query but need to know the full size of the unfiltered set, you must set $check_full_set_size to true to gather this information at the expense of a second database query.
public sortedQuery ( SortedQuery $query, boolean $check_full_set_size = false, boolean $use_cache = true ) : QueryResult
$query Bravo3\Orm\Query\SortedQuery
$check_full_set_size boolean
$use_cache boolean
Résultat Bravo3\Orm\Query\QueryResult

Property Details

$cache protected_oe property

protected EntityCachingInterface,Bravo3\Orm\Services\Cache $cache
Résultat Bravo3\Orm\Services\Cache\EntityCachingInterface

$config protected_oe property

protected Configuration,Bravo3\Orm\Config $config
Résultat Bravo3\Orm\Config\Configuration

$dispatcher protected_oe property

protected EventDispatcher,Symfony\Component\EventDispatcher $dispatcher
Résultat Symfony\Component\EventDispatcher\EventDispatcher

$driver protected_oe property

protected DriverInterface,Bravo3\Orm\Drivers $driver
Résultat Bravo3\Orm\Drivers\DriverInterface

$index_manager protected_oe property

protected IndexManager,Bravo3\Orm\Services $index_manager
Résultat IndexManager

$key_scheme protected_oe property

protected KeySchemeInterface,Bravo3\Orm\KeySchemes $key_scheme
Résultat Bravo3\Orm\KeySchemes\KeySchemeInterface

$maintenance_mode protected_oe property

protected bool $maintenance_mode
Résultat boolean

$mapper protected_oe property

protected MapperInterface,Bravo3\Orm\Mappers $mapper
Résultat Bravo3\Orm\Mappers\MapperInterface

$query_manager protected_oe property

protected QueryManager,Bravo3\Orm\Services $query_manager
Résultat QueryManager

$relationship_manager protected_oe property

protected RelationshipManager,Bravo3\Orm\Services $relationship_manager
Résultat RelationshipManager

$serialiser_map protected_oe property

protected SerialiserMap,Bravo3\Orm\Serialisers $serialiser_map
Résultat Bravo3\Orm\Serialisers\SerialiserMap