mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-23 09:07:43 +02:00
[ticket/12664] Refactor develop/migration_tips.php into a console command.
PHPBB3-12664
This commit is contained in:
parent
456ff2559a
commit
2964fb37e8
phpBB
@ -75,6 +75,13 @@ services:
|
||||
tags:
|
||||
- { name: console.command }
|
||||
|
||||
console.command.dev.migration_tips:
|
||||
class: phpbb\console\command\dev\migration_tips
|
||||
arguments:
|
||||
- @ext.manager
|
||||
tags:
|
||||
- { name: console.command }
|
||||
|
||||
console.command.extension.disable:
|
||||
class: phpbb\console\command\extension\disable
|
||||
arguments:
|
||||
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
// This is to help with creating migration files for new versions
|
||||
// Use this to find what migrations are not depended on by any other migration
|
||||
// (the current migration tree tips)
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
include($phpbb_root_path . 'common.' . $phpEx);
|
||||
|
||||
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
||||
$finder = $phpbb_extension_manager->get_finder();
|
||||
|
||||
$migrations = $finder
|
||||
->core_path('phpbb/db/migration/data/')
|
||||
->get_classes();
|
||||
$tips = $migrations;
|
||||
|
||||
foreach ($migrations as $migration_class)
|
||||
{
|
||||
foreach ($migration_class::depends_on() as $dependency)
|
||||
{
|
||||
if (($tips_key = array_search($dependency, $tips)) !== false)
|
||||
{
|
||||
unset($tips[$tips_key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($tips as $migration)
|
||||
{
|
||||
echo "\t\t\t'{$migration}',\n";
|
||||
}
|
||||
|
63
phpBB/phpbb/console/command/dev/migration_tips.php
Normal file
63
phpBB/phpbb/console/command/dev/migration_tips.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
namespace phpbb\console\command\dev;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class migration_tips extends \phpbb\console\command\command
|
||||
{
|
||||
/** @var \phpbb\extension\manager */
|
||||
protected $extension_manager;
|
||||
|
||||
function __construct(\phpbb\extension\manager $extension_manager)
|
||||
{
|
||||
$this->extension_manager = $extension_manager;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('dev:migration-tips')
|
||||
->setDescription('Finds migrations that are not depended on.')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$migrations = $this->extension_manager->get_finder()
|
||||
->core_path('phpbb/db/migration/data/')
|
||||
->get_classes();
|
||||
$tips = $migrations;
|
||||
|
||||
foreach ($migrations as $migration_class)
|
||||
{
|
||||
foreach ($migration_class::depends_on() as $dependency)
|
||||
{
|
||||
$tips_key = array_search($dependency, $tips);
|
||||
if ($tips_key !== false)
|
||||
{
|
||||
unset($tips[$tips_key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln("\t\tarray(");
|
||||
foreach ($tips as $migration)
|
||||
{
|
||||
$output->writeln("\t\t\t'{$migration}',");
|
||||
}
|
||||
$output->writeln("\t\t);");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user