Exemplo n.º 1
0
 public function __construct($appConfig, Filesystem $filesystem)
 {
     if (!isset($appConfig['migrations'])) {
         throw new RuntimeException("Missing migrations configuration");
     }
     $options = $appConfig['migrations'];
     if (!isset($options['dir'])) {
         throw new RuntimeException("`dir` has not be specified in migrations configuration");
     }
     $this->dir = $options['dir'];
     if (!isset($options['namespace'])) {
         throw new RuntimeException("`namespace` has not be specified in migrations configuration");
     }
     $this->namespace = $options['namespace'];
     if (!$filesystem->isDir($this->dir)) {
         $filesystem->mkdir($this->dir, 0775);
     } elseif (!$filesystem->isWritable($this->dir)) {
         throw new RuntimeException(sprintf('Migrations directory is not writable %s', $this->dir));
     }
     if (!isset($options['adapter'])) {
         $options['adapter'] = 'Zend\\Db\\Adapter\\Adapter';
     }
     $this->adapter = $options['adapter'];
     if (isset($options['show_log'])) {
         $this->showLog = $options['show_log'];
     }
 }