Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     $proxyCacheDirectory = $this->proxyConfiguration->getProxiesTargetDir();
     if (!is_dir($proxyCacheDirectory)) {
         mkdir($proxyCacheDirectory, 0777, true);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(Configuration $configuration = null)
 {
     if (null !== $configuration && sys_get_temp_dir() !== $configuration->getProxiesTargetDir()) {
         $fs = new Filesystem();
         $fs->mkdir($configuration->getProxiesTargetDir());
     }
     parent::__construct($configuration);
 }
 /**
  * Create the lazy services delegator factory.
  *
  * Creates the lazy services delegator factory based on the lazy_services
  * configuration present.
  *
  * @return Proxy\LazyServiceFactory
  * @throws ServiceNotCreatedException when the lazy service class_map
  *     configuration is missing
  */
 private function createLazyServiceDelegatorFactory()
 {
     if ($this->lazyServicesDelegator) {
         return $this->lazyServicesDelegator;
     }
     if (!isset($this->lazyServices['class_map'])) {
         throw new ServiceNotCreatedException('Missing "class_map" config key in "lazy_services"');
     }
     $factoryConfig = new ProxyConfiguration();
     if (isset($this->lazyServices['proxies_namespace'])) {
         $factoryConfig->setProxiesNamespace($this->lazyServices['proxies_namespace']);
     }
     if (isset($this->lazyServices['proxies_target_dir'])) {
         $factoryConfig->setProxiesTargetDir($this->lazyServices['proxies_target_dir']);
     }
     if (!isset($this->lazyServices['write_proxy_files']) || !$this->lazyServices['write_proxy_files']) {
         $factoryConfig->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
     } else {
         $factoryConfig->setGeneratorStrategy(new FileWriterGeneratorStrategy(new FileLocator($factoryConfig->getProxiesTargetDir())));
     }
     spl_autoload_register($factoryConfig->getProxyAutoloader());
     $this->lazyServicesDelegator = new Proxy\LazyServiceFactory(new LazyLoadingValueHolderFactory($factoryConfig), $this->lazyServices['class_map']);
     return $this->lazyServicesDelegator;
 }
Exemple #4
0
 /**
  * @covers \ProxyManager\Configuration::getProxiesTargetDir
  * @covers \ProxyManager\Configuration::setProxiesTargetDir
  */
 public function testSetGetProxiesTargetDir()
 {
     $this->assertTrue(is_dir($this->configuration->getProxiesTargetDir()));
     $this->configuration->setProxiesTargetDir(__DIR__);
     $this->assertSame(__DIR__, $this->configuration->getProxiesTargetDir());
 }