PHP Class Bravo3\Orm\Services\EntityManager

Inheritance: use trait Bravo3\Orm\Traits\ProxyAwareTrait
Datei anzeigen Open project: bravo3/orm Class Usage Examples

Protected Properties

Property 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

Public Methods

Method 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

Protected Methods

Method 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

Method Description
validateId ( string $id ) Throw an InvalidIdException if an ID contains illegal chars

Method Details

__construct() protected method

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 method

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

addSubscriber() public method

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

build() public static method

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
return EntityManager

delete() public method

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 method

Execute the current unit of work
public flush ( )

getCache() public method

Get caching service
public getCache ( ) : Bravo3\Orm\Services\Cache\EntityCachingInterface
return Bravo3\Orm\Services\Cache\EntityCachingInterface

getConfig() public method

Get Config
public getConfig ( ) : Configuration
return Bravo3\Orm\Config\Configuration

getDispatcher() public method

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

getDriver() public method

Get the underlying driver
public getDriver ( ) : Bravo3\Orm\Drivers\DriverInterface
return Bravo3\Orm\Drivers\DriverInterface

getIndexManager() protected method

Lazy-loading index manager
protected getIndexManager ( ) : IndexManager
return IndexManager

getKeyScheme() public method

Get the key scheme
public getKeyScheme ( ) : Bravo3\Orm\KeySchemes\KeySchemeInterface
return Bravo3\Orm\KeySchemes\KeySchemeInterface

getMaintenanceMode() public method

Get the state of the maintenance mode
public getMaintenanceMode ( ) : boolean
return boolean

getMapper() public method

Get the entity mapper
public getMapper ( ) : Bravo3\Orm\Mappers\MapperInterface
return Bravo3\Orm\Mappers\MapperInterface

getQueryManager() protected method

Lazy-loading query manager
protected getQueryManager ( ) : QueryManager
return QueryManager

getRelationshipManager() protected method

Lazy-loading relationship manager
protected getRelationshipManager ( ) : RelationshipManager
return RelationshipManager

getSerialiserMap() public method

Get the serialiser mappings
public getSerialiserMap ( ) : SerialiserMap
return Bravo3\Orm\Serialisers\SerialiserMap

indexedQuery() public method

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
return Bravo3\Orm\Query\QueryResult

persist() public method

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 method

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

refresh() public method

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

registerDefaultSubscribers() protected method

Register default event subscribers

retrieve() public method

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
return object

retrieveByIndex() public method

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
return object

retrieveEntityOrNew() public method

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
return object

retrieveEntityOrNull() public method

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
return null | object

setCache() public method

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

setConfig() public method

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

setMaintenanceMode() public method

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

setSerialiserMap() public method

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

sortedQuery() public method

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
return Bravo3\Orm\Query\QueryResult

Property Details

$cache protected_oe property

protected EntityCachingInterface,Bravo3\Orm\Services\Cache $cache
return Bravo3\Orm\Services\Cache\EntityCachingInterface

$config protected_oe property

protected Configuration,Bravo3\Orm\Config $config
return Bravo3\Orm\Config\Configuration

$dispatcher protected_oe property

protected EventDispatcher,Symfony\Component\EventDispatcher $dispatcher
return Symfony\Component\EventDispatcher\EventDispatcher

$driver protected_oe property

protected DriverInterface,Bravo3\Orm\Drivers $driver
return Bravo3\Orm\Drivers\DriverInterface

$index_manager protected_oe property

protected IndexManager,Bravo3\Orm\Services $index_manager
return IndexManager

$key_scheme protected_oe property

protected KeySchemeInterface,Bravo3\Orm\KeySchemes $key_scheme
return Bravo3\Orm\KeySchemes\KeySchemeInterface

$maintenance_mode protected_oe property

protected bool $maintenance_mode
return boolean

$mapper protected_oe property

protected MapperInterface,Bravo3\Orm\Mappers $mapper
return Bravo3\Orm\Mappers\MapperInterface

$query_manager protected_oe property

protected QueryManager,Bravo3\Orm\Services $query_manager
return QueryManager

$relationship_manager protected_oe property

protected RelationshipManager,Bravo3\Orm\Services $relationship_manager
return RelationshipManager

$serialiser_map protected_oe property

protected SerialiserMap,Bravo3\Orm\Serialisers $serialiser_map
return Bravo3\Orm\Serialisers\SerialiserMap