/**
* Create a raw entity manager
*
* Do not construct an entity manager directly or it will lack access interceptors which are responsible for
* caching and event dispatching.
*
* @see EntityManager::build()
*
* @param DriverInterface $driver
* @param MapperInterface $mapper
* @param SerialiserMap $serialiser_map
* @param KeySchemeInterface $key_scheme
* @param Configuration $configuration
* @param EntityCachingInterface $cache
*/
protected function __construct(DriverInterface $driver, MapperInterface $mapper, SerialiserMap $serialiser_map = null, KeySchemeInterface $key_scheme = null, Configuration $configuration = null, EntityCachingInterface $cache = null)
{
$this->driver = $driver;
$this->mapper = $mapper;
$this->key_scheme = $key_scheme ?: $driver->getPreferredKeyScheme();
$this->config = $configuration ?: new Configuration();
$this->cache = $cache ?: new EphemeralEntityCache();
if ($serialiser_map) {
$this->serialiser_map = $serialiser_map;
} else {
$this->serialiser_map = new SerialiserMap();
$this->serialiser_map->addSerialiser(new JsonSerialiser());
}
$this->instance_id = uniqid();
$this->registerDefaultSubscribers();
}