migrations icon indicating copy to clipboard operation
migrations copied to clipboard

Rethink configuration to make a lot easier to define own handlers

Open hrach opened this issue 8 years ago • 1 comments

https://github.com/nextras/migrations/commit/d46cbd649df0def60e5630e9943fba3ab432ed93#commitcomment-24528344

hrach avatar Sep 24 '17 18:09 hrach

Current sad sollution:

extensions:
	nextras.migrations: Nextras\Migrations\Bridges\NetteDI\MigrationsExtension

services:
	nextras.migrations.configuration:
		factory: MigrationConfiguration
		arguments:
			- %appDir%/../migrations
			- @Nextras\Migrations\IDriver
			- false
			- []
			- @Nette\DI\Container

nextras.migrations:
	dir: %appDir%/../migrations
	driver: pgsql
	dbal: nextras
<?php declare(strict_types = 1);

use Nette\DI\Container;
use Nextras\Migrations\Configurations\DefaultConfiguration;
use Nextras\Migrations\IDriver;


class MigrationConfiguration extends DefaultConfiguration
{
	/** @var Container */
	private $container;


	public function __construct($dir, IDriver $driver, $withDummyData = true, array $phpParams = [], Container $container)
	{
		parent::__construct($dir, $driver, $withDummyData, $phpParams);
		$this->container = $container;
	}


	public function getExtensionHandlers()
	{
		$handlers = parent::getExtensionHandlers();
		$handlers['php'] = $this->container->getByType(ConnectionPhpHandler::class);
		return $handlers;
	}
}

hrach avatar Sep 24 '17 18:09 hrach