예제 #1
0
 /**
  * Returns an instance of CakeManager
  *
  * @param \Phinx\Config\ConfigInterface|null $config ConfigInterface the Manager needs to run
  * @return \Migrations\CakeManager Instance of CakeManager
  */
 public function getManager($config = null)
 {
     if (!$this->manager instanceof CakeManager) {
         if (!$config instanceof ConfigInterface) {
             throw new \RuntimeException('You need to pass a ConfigInterface object for your first getManager() call');
         }
         $this->manager = new CakeManager($config, $this->output);
     } elseif ($config !== null) {
         $this->manager->setConfig($config);
     }
     return $this->manager;
 }
예제 #2
0
파일: Migrations.php 프로젝트: lhas/pep
 /**
  * Sets the adapter the manager is going to need to operate on the DB
  * This will make sure the adapter instance is a \Migrations\CakeAdapter instance
  *
  * @return void
  */
 public function setAdapter()
 {
     if ($this->input !== null) {
         $connectionName = 'default';
         if ($this->input->getOption('connection')) {
             $connectionName = $this->input->getOption('connection');
         }
         $connection = ConnectionManager::get($connectionName);
         $env = $this->manager->getEnvironment('default');
         $adapter = $env->getAdapter();
         if (!$adapter instanceof CakeAdapter) {
             $env->setAdapter(new CakeAdapter($adapter, $connection));
         }
     }
 }