PHP Class Mongolid\Manager

With the Mongolid\Manager, you can start using Mongolid with pure PHP by simply calling the addConnection method.
Show file Open project: leroy-merlin-br/mongolid Class Usage Examples

Public Properties

Property Type Description
$cacheComponent Mongolid\Util\CacheComponent Mongolid cache component object.
$connectionPool Mongolid\Connection\Pool Mongolid connection pool being object.
$container Illuminate\Contracts\Container Container being used by Mongolid.

Protected Properties

Property Type Description
$schemas array Stores the schemas that have been registered for later use. This may be useful when using Mongolid DataMapper pattern.
$singleton Manager Singleton instance of the manager.

Public Methods

Method Description
addConnection ( Connection $connection ) : boolean Main entry point to openning a connection and start using Mongolid in pure PHP. After adding a connection into the Manager you are ready to persist and query your models.
getConnection ( ) : MongoDB\Client Get the raw MongoDB connection.
getMapper ( string $entityClass ) : DataMapper | null Retrieves a DataMapper for the given $entityClass. This can only be done if the Schema for that entity has been previously registered with registerSchema() method.
registerSchema ( Schema $schema ) : void Allow document Schemas to be registered for later use.
setEventTrigger ( Mongolid\Event\EventTriggerInterface $eventTrigger ) : void Sets the event trigger for Mongolid events.

Protected Methods

Method Description
init ( ) : void Initializes the Mongolid manager.

Method Details

addConnection() public method

Main entry point to openning a connection and start using Mongolid in pure PHP. After adding a connection into the Manager you are ready to persist and query your models.
public addConnection ( Connection $connection ) : boolean
$connection Mongolid\Connection\Connection Connection instance to be used in database interactions.
return boolean Success

getConnection() public method

Get the raw MongoDB connection.
public getConnection ( ) : MongoDB\Client
return MongoDB\Client

getMapper() public method

Retrieves a DataMapper for the given $entityClass. This can only be done if the Schema for that entity has been previously registered with registerSchema() method.
public getMapper ( string $entityClass ) : DataMapper | null
$entityClass string Class of the entity that needs to be mapped.
return Mongolid\DataMapper\DataMapper | null DataMapper configured for the $entityClass.

init() protected method

Initializes the Mongolid manager.
protected init ( ) : void
return void

registerSchema() public method

Allow document Schemas to be registered for later use.
public registerSchema ( Schema $schema ) : void
$schema Mongolid\Schema\Schema Schema being registered.
return void

setEventTrigger() public method

Sets the event trigger for Mongolid events.
public setEventTrigger ( Mongolid\Event\EventTriggerInterface $eventTrigger ) : void
$eventTrigger Mongolid\Event\EventTriggerInterface External event trigger.
return void

Property Details

$cacheComponent public property

Mongolid cache component object.
public CacheComponent,Mongolid\Util $cacheComponent
return Mongolid\Util\CacheComponent

$connectionPool public property

Mongolid connection pool being object.
public Pool,Mongolid\Connection $connectionPool
return Mongolid\Connection\Pool

$container public property

Container being used by Mongolid.
public Container,Illuminate\Contracts $container
return Illuminate\Contracts\Container

$schemas protected property

Stores the schemas that have been registered for later use. This may be useful when using Mongolid DataMapper pattern.
protected array $schemas
return array

$singleton protected static property

Singleton instance of the manager.
protected static Manager,mongolid $singleton
return Manager