Phpmig\Console\Command\AbstractCommand::bootstrapAdapter PHP Метод

bootstrapAdapter() защищенный Метод

protected bootstrapAdapter ( Symfony\Component\Console\Input\InputInterface $input ) : Phpmig\Adapter\AdapterInterface
$input Symfony\Component\Console\Input\InputInterface
Результат Phpmig\Adapter\AdapterInterface
    protected function bootstrapAdapter(InputInterface $input)
    {
        $container = $this->getContainer();
        $validAdapter = isset($container['phpmig.adapter']);
        $validSets = !isset($container['phpmig.sets']) || is_array($container['phpmig.sets']);
        if (!$validAdapter && !$validSets) {
            throw new \RuntimeException($this->getBootstrap() . 'must return container with phpmig.adapter or phpmig.sets');
        }
        if (isset($container['phpmig.sets'])) {
            $set = $input->getOption('set');
            if (!isset($container['phpmig.sets'][$set]['adapter'])) {
                throw new \RuntimeException($set . ' is undefined keys or adapter at phpmig.sets');
            }
            $adapter = $container['phpmig.sets'][$set]['adapter'];
        }
        if (isset($container['phpmig.adapter'])) {
            $adapter = $container['phpmig.adapter'];
        }
        if (!$adapter instanceof AdapterInterface) {
            throw new \RuntimeException("phpmig.adapter or phpmig.sets must be an instance of \\Phpmig\\Adapter\\AdapterInterface");
        }
        if (!$adapter->hasSchema()) {
            $adapter->createSchema();
        }
        return $adapter;
    }