public function doCreate(callable $callbackAskNameAndService)
	{
		assert($this->_dispatcher);
		assert($this->_container);

		$this->_clearStatProperties();
		$this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create());

		try
		{
			$this->notify(self::STATE_FIRED);

			$modulesAndFiles = $this->_findModulesAndMigrationFiles();
			$migrations      = $this->_parseMigrationFiles($modulesAndFiles);

			$folders = array_map('dirname', $modulesAndFiles[$this->getProjectName()]);
			asort($folders);

			$migrationsPath = reset($folders) ?: $this->getProjectPath().DIRECTORY_SEPARATOR.'migrations';
			file_exists($migrationsPath) || mkdir($migrationsPath, 0775, true);

			$this->notify(self::STATE_FIND_MIGRATIONS);
			list($name, $service) = $callbackAskNameAndService(array_keys($folders), array_keys($migrations));

			if (empty($name))
			{
				$this->_printError(self::ERROR_EMPTY_FILE_NAME);
			}
			elseif (empty($service))
			{
				$this->_printError(self::ERROR_EMPTY_SERVICE_NAME);
			}
			else
			{
				$this->_filePutContents($migrationsPath.DIRECTORY_SEPARATOR.$name.'.ini', implode("\n", [
					"; File $name.ini by ".(getenv('USERNAME') ?: getenv('USER') ?: 'unknown user'),
					'',
					'['.self::INI_SECTION_MIGRATION.']',
					self::INI_KEY_CREATED.'="'.date('Y-m-d H:i O').'"',
					self::INI_KEY_SERVICE.'="'.$service.'"',
					'',
					'['.self::INI_SECTION_ACTIONS.']',
					'a001="php> echo \'Migration applied!\'.PHP_EOL;"',
					'r001="php> echo \'Migration rejected!\'.PHP_EOL;"',
					'',
				]));
			}

			$this->notify(self::STATE_COMPLETE);
		}
		catch (Exception $exception)
		{
			$this->_printError($exception);
			$this->notify(self::STATE_COMPLETE);
		}
		finally
		{
			$this->_stateMigrationName = null;
			$this->_state = self::STATE_INITIALIZED;

			$this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create());
		}
	}
public function doCreate(callable $callbackAskNameAndService)
	{
		assert($this->_dispatcher);
		assert($this->_container);

		$this->_clearStatProperties();
		$this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create());

		try
		{
			$this->notify(self::STATE_FIRED);

			$modulesAndFiles = $this->_findModulesAndMigrationFiles();
			$migrations      = $this->_parseMigrationFiles($modulesAndFiles);

			$folders = array_map('dirname', $modulesAndFiles[$this->getProjectName()]);
			asort($folders);

			$migrationsPath = reset($folders) ?: $this->getProjectPath().DIRECTORY_SEPARATOR.'migrations';
			file_exists($migrationsPath) || mkdir($migrationsPath, 0775, true);

			$this->notify(self::STATE_FIND_MIGRATIONS);
			list($name, $service) = $callbackAskNameAndService(array_keys($folders), array_keys($migrations));

			if (empty($name))
			{
				$this->_printError(self::ERROR_EMPTY_FILE_NAME);
			}
			elseif (empty($service))
			{
				$this->_printError(self::ERROR_EMPTY_SERVICE_NAME);
			}
			else
			{
				$this->_filePutContents($migrationsPath.DIRECTORY_SEPARATOR.$name.'.ini', implode("\n", [
					"; File $name.ini by ".(getenv('USERNAME') ?: getenv('USER') ?: 'unknown user'),
					'',
					'['.self::INI_SECTION_MIGRATION.']',
					self::INI_KEY_CREATED.'="'.date('Y-m-d H:i O').'"',
					self::INI_KEY_SERVICE.'="'.$service.'"',
					'',
					'['.self::INI_SECTION_ACTIONS.']',
					'a001="php> echo \'Migration applied!\'.PHP_EOL;"',
					'r001="php> echo \'Migration rejected!\'.PHP_EOL;"',
					'',
				]));
			}

			$this->notify(self::STATE_COMPLETE);
		}
		catch (Exception $exception)
		{
			$this->_printError($exception);
			$this->notify(self::STATE_COMPLETE);
		}
		finally
		{
			$this->_stateMigrationName = null;
			$this->_state = self::STATE_INITIALIZED;

			$this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create());
		}
	}
public function doCreate ( callable $ callbackAskNameAndService ) { assert ( $ this -> _dispatcher ) ; assert ( $ this -> _container ) ; $ this -> _clearStatProperties ( ) ; $ this -> _dispatcher -> dispatch ( self :: EVENT_INIT_SERVICE , OnInitService :: create ( ) ) ; try { $ this -> notify ( self :: STATE_FIRED ) ; $ modulesAndFiles = $ this -> _findModulesAndMigrationFiles ( ) ; $ migrations = $ this -> _parseMigrationFiles ( $ modulesAndFiles ) ; $ folders = array_map ( 'dirname' , $ modulesAndFiles [ $ this -> getProjectName ( ) ] ) ; asort ( $ folders ) ; $ migrationsPath = reset ( $ folders ) ? : $ this -> getProjectPath ( ) . DIRECTORY_SEPARATOR . 'migrations' ; file_exists ( $ migrationsPath ) || mkdir ( $ migrationsPath , 0775 , true ) ; $ this -> notify ( self :: STATE_FIND_MIGRATIONS ) ; list ( $ name , $ service ) = $ callbackAskNameAndService ( array_keys ( $ folders ) , array_keys ( $ migrations ) ) ; if ( empty ( $ name ) ) { $ this -> _printError ( self :: ERROR_EMPTY_FILE_NAME ) ; } elseif ( empty ( $ service ) ) { $ this -> _printError ( self :: ERROR_EMPTY_SERVICE_NAME ) ; } else { $ this -> _filePutContents ( $ migrationsPath . DIRECTORY_SEPARATOR . $ name . '.ini' , implode ( "\n" , [ "; File $name.ini by " . ( getenv ( 'USERNAME' ) ? : getenv ( 'USER' ) ? : 'unknown user' ) , '' , '[' . self :: INI_SECTION_MIGRATION . ']' , self :: INI_KEY_CREATED . '="' . date ( 'Y-m-d H:i O' ) . '"' , self :: INI_KEY_SERVICE . '="' . $ service . '"' , '' , '[' . self :: INI_SECTION_ACTIONS . ']' , 'a001="php> echo \'Migration applied!\'.PHP_EOL;"' , 'r001="php> echo \'Migration rejected!\'.PHP_EOL;"' , '' , ] ) ) ; } $ this -> notify ( self :: STATE_COMPLETE ) ; } catch ( Exception $ exception ) { $ this -> _printError ( $ exception ) ; $ this -> notify ( self :: STATE_COMPLETE ) ; } finally { $ this -> _stateMigrationName = null ; $ this -> _state = self :: STATE_INITIALIZED ; $ this -> _dispatcher -> dispatch ( self :: EVENT_FREE_SERVICE , OnFreeService :: create ( ) ) ; } }
Create INI file template for new migration.

@param callable $callbackAskNameAndService
Create INI file template for new migration .