public function provider() { $cache = CacheFactory::make('array'); $dbParams = $this->getDbParams(); $params = $this->getDoctrineParams(); return [[$cache, $dbParams, $params]]; }
public function provider() { $cache = CacheFactory::make('array'); $dbParams = $this->getDbParams(); $params = $this->getDoctrineParams(); $driver = new DriverManagerProvider($dbParams); $configuration = new ConfigurationProvider($cache, $params); return [[$driver, $configuration, $dbParams, $params, $cache]]; }
public function getCommandProvider() { $cache = CacheFactory::make('array'); $dbParams = $this->getDbParams(); $params = $this->getDoctrineParams(); $driver = new DriverManagerProvider($dbParams); $configuration = new ConfigurationProvider($cache, $params); $emProvider = EntityManagerProvider::getInstance(); $emProvider->driver($driver); $emProvider->configuration($configuration); $emProxy = new ProxyEntityManager($emProvider); $commandProvider = new DoctrineCommandProvider($emProxy); return $commandProvider; }
/** * Register the service provider. * * @return void */ public function register() { /** * @param Application $app Laravel Application * @param array $params Connection to be used * * @return EntityManager */ $this->app->singleton('Doctrine\\ORM\\EntityManager', function ($app) { $provider = $app->make('Paolooo\\LaravelDoctrine\\Providers\\EntityManagerProvider'); return new ProxyEntityManager($provider); }); /** * Provides a config for EntityManager * * @return EntityManagerProvider */ $this->app->singleton('Paolooo\\LaravelDoctrine\\Providers\\EntityManagerProvider', function () { // Cache $cacheType = config('cache.default'); $path = config("cache.stores.{$cacheType}.path"); $cache = CacheFactory::make($cacheType, $path); // DB Driver $dbType = config('database.default'); $dbParams = config("database.connections.{$dbType}"); $driver = new DriverManagerProvider($dbParams); // Doctrin Params $params = config('doctrine'); $configuration = new ConfigurationProvider($cache, $params); $provider = EntityManagerProvider::getInstance(); $provider->driver($driver); $provider->configuration($configuration); return $provider; }); $this->commands(['Paolooo\\LaravelDoctrine\\Console\\DoctrineCommand']); }
/** @test */ public function should_throw_invalid_cache_when_adding_existing_cache() { $this->setExpectedException('\\InvalidArgumentException', 'Cannot add new cache'); CacheFactory::addNewCache('file', '\\Unknown\\Namespace'); }