Symfony\Bundle\FrameworkBundle\Console\Application::getKernel PHP Method

getKernel() public method

Gets the Kernel associated with this Console.
public getKernel ( ) : Symfony\Component\HttpKernel\KernelInterface
return Symfony\Component\HttpKernel\KernelInterface A KernelInterface instance
    public function getKernel()
    {
        return $this->kernel;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * create test db.
  */
 public function initDB()
 {
     static::bootKernel();
     $this->application = new Application(static::$kernel);
     $this->em = $this->getEntityManager();
     // drop the database
     $command = new DropDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:drop', '--force' => true));
     $command->run($input, new NullOutput());
     // we have to close the connection after dropping the database so we don't get "No database selected" error
     $connection = $this->application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     // create the database
     $command = new CreateDatabaseDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:create'));
     $command->run($input, new NullOutput());
     // create schema
     $command = new CreateSchemaDoctrineCommand();
     $this->application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:schema:create'));
     $command->run($input, new NullOutput());
 }
All Usage Examples Of Symfony\Bundle\FrameworkBundle\Console\Application::getKernel