Permalink
Browse files

add IMigrationGroupsProvider

  • Loading branch information...
JanTvrdik committed Jan 22, 2018
1 parent 73a3bbf commit 2ed3dc0b6de07a4dd7496d83fe7c92834e26f084
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Nextras community extensions of Nette Framework
*
* @license New BSD License
* @link https://github.com/nextras/migrations
*/
namespace Nextras\Migrations\Bridges\NetteDI;
use Nextras;
use Nextras\Migrations\Entities\Group;
interface IMigrationGroupsProvider
{
/**
* @return Group[]
*/
public function getMigrationGroups(): array;
}
@@ -232,6 +232,18 @@ private function createDefaultGroupConfiguration($dir, $withDummyData)
private function createGroupDefinitions(array $groups)
{
/** @var IMigrationGroupsProvider $provider */
foreach ($this->compiler->getExtensions('Nextras\Migrations\Bridges\NetteDI\IMigrationGroupsProvider') as $provider) {
foreach ($provider->getMigrationGroups() as $group) {
$groups[$group->name] = [
'enabled' => $group->enabled,
'directory' => $group->directory,
'dependencies' => $group->dependencies,
'generator' => $group->generator,
];
}
}
$builder = $this->getContainerBuilder();
$groupDefinitions = [];
View
@@ -21,15 +21,80 @@ class Group
public $name;
/** @var bool */
public $enabled;
public $enabled = true;
/** @var string absolute path do directory */
public $directory;
/** @var string[] */
public $dependencies;
public $dependencies = [];
/** @var IDiffGenerator|NULL */
public $generator;
/**
* @param null|string $name
* @param null|string $directory
*/
public function __construct($name = null, $directory = null)
{
$this->name = $name;
$this->directory = $directory;
}
/**
* @param string $name
* @return static
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @param bool $enabled
* @return static
*/
public function setEnabled($enabled)
{
$this->enabled = $enabled;
return $this;
}
/**
* @param string $directory
* @return static
*/
public function setDirectory($directory)
{
$this->directory = $directory;
return $this;
}
/**
* @param string[] $dependencies
* @return static
*/
public function setDependencies(array $dependencies)
{
$this->dependencies = $dependencies;
return $this;
}
/**
* @param IDiffGenerator|NULL $generator
* @return static
*/
public function setGenerator(IDiffGenerator $generator = NULL)
{
$this->generator = $generator;
return $this;
}
}

0 comments on commit 2ed3dc0

Please sign in to comment.