Example #1
0
 /**
  * {@inheritdoc}
  */
 public function open($filename)
 {
     if (!$this->files->exists($filename)) {
         throw new ImporterException("Unable import translator bundles from '{$filename}', file does not exists.");
     }
     $this->parseStrings($this->files->read($filename));
     return $this;
 }
Example #2
0
 /**
  * {@inheritdoc}
  *
  * @param int $expiration Current expiration time value in seconds (reference).
  */
 public function get($name, &$expiration = null)
 {
     if (!$this->files->exists($filename = $this->makeFilename($name))) {
         return null;
     }
     $cacheData = unserialize($this->files->read($filename));
     if (!empty($cacheData[0]) && $cacheData[0] < time()) {
         $this->delete($name);
         return null;
     }
     return $cacheData[1];
 }
Example #3
0
 /**
  * Get injector associated with specific config.
  *
  * @param string $config
  * @return ConfigInjector
  * @throws RegistratorException
  */
 protected function injector($config)
 {
     if (isset($this->injectors[$config])) {
         return $this->injectors[$config];
     }
     $content = $this->files->read($this->configFilename($config));
     //todo: move to container?
     return $this->injectors[$config] = new ConfigInjector($content);
 }
Example #4
0
 /**
  * @param DirectoriesInterface $directories
  * @param FilesInterface       $files
  * @param EncrypterConfig      $config
  */
 public function perform(DirectoriesInterface $directories, FilesInterface $files, EncrypterConfig $config)
 {
     $envFilename = $directories->directory('root') . '.env';
     if (!$files->exists($envFilename)) {
         $this->writeln("<fg=red>'env.' file does not exists, unable to sek encryption key.</fg=red>");
     }
     $files->write($envFilename, str_replace($config->getKey(), Strings::random(32), $files->read($envFilename)));
     $this->writeln("<info>Encryption key has been successfully updated.</info>");
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function registerMigration($name, $class)
 {
     if (!class_exists($class)) {
         throw new MigratorException("Unable to register migration, representing class does not exists.");
     }
     foreach ($this->getMigrations() as $migration) {
         if (get_class($migration) == $class) {
             //Already presented
             return false;
         }
     }
     //Copying
     $this->files->write($filename = $this->createFilename($name), $this->files->read((new \ReflectionClass($class))->getFileName()), FilesInterface::READONLY, true);
     return basename($filename);
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function registerMigration($name, $class, $body = null)
 {
     if (empty($body) && !class_exists($class)) {
         throw new RepositoryException("Unable to register migration '{$class}', representing class does not exists");
     }
     foreach ($this->getMigrations() as $migration) {
         if (get_class($migration) == $class) {
             throw new RepositoryException("Unable to register migration '{$class}', migration already exists");
         }
         if ($migration->getMeta()->getName() == $name) {
             throw new RepositoryException("Unable to register migration '{$name}', migration under same name already exists");
         }
     }
     if (empty($body)) {
         //Let's read body from a given class filename
         $body = $this->files->read((new \ReflectionClass($class))->getFileName());
     }
     //Copying
     $this->files->write($filename = $this->createFilename($name), $body, FilesInterface::READONLY);
     return basename($filename);
 }
Example #7
0
 /**
  * {@inheritdoc}
  *
  * @deprecated this method creates looped dependencies, drop it
  */
 public function fetchTokens($filename)
 {
     return $this->normalizeTokens(token_get_all($this->files->read($filename)));
 }
Example #8
0
 /**
  * Get source of non compiler view file.
  *
  * @return string
  */
 public function getSource()
 {
     return $this->files->read($this->filename);
 }
Example #9
0
 /**
  * {@inheritdoc}
  */
 public function getSource($path)
 {
     return $this->files->read($this->findView($path));
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function read($session_id)
 {
     return $this->files->exists($this->getFilename($session_id)) ? $this->files->read($this->getFilename($session_id)) : false;
 }