Esempio n. 1
0
 /**
  * Test the IoC::instance method.
  *
  * @group laravel
  */
 public function testInstancesAreReturnedBySingleton()
 {
     $object = new StdClass();
     IoC::instance('bar', $object);
     $this->assertTrue($object === IoC::resolve('bar'));
 }
Esempio n. 2
0
        $cache = IoC::resolve('doctrine::cache.provider');
    } else {
        $cache = new Doctrine\Common\Cache\ArrayCache();
    }
    /**
     * Register the cache provider with the Doctrine configuration.
     */
    $config = new Doctrine\ORM\Configuration();
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);
    /**
     * Resolve and register the meta-data driver.
     */
    if (IoC::registered('doctrine::metadata.driver')) {
        $driverImpl = IoC::resolve('doctrine::metadata.driver', array($config));
    } else {
        $driverImpl = $config->newDefaultAnnotationDriver(Config::get('doctrine::config.models'));
    }
    $config->setMetadataDriverImpl($driverImpl);
    /**
     * Register the proxy configuration with Doctrine.
     */
    $config->setProxyDir(Config::get('doctrine::config.proxy.directory'));
    $config->setProxyNamespace(Config::get('doctrine::config.proxy.namespace'));
    $config->setAutoGenerateProxyClasses(Config::get('doctrine::config.proxy.auto_generate'));
    /**
     * Register an EntityManager in the IoC container as an instance.
     */
    $em = EntityManager::create(array('pdo' => Laravel\Database::connection()->pdo), $config);
    IoC::instance('doctrine::manager', $em);
});