@@ -18,41 +18,41 @@ |
||
| 18 | 18 | |
| 19 | 19 | class PatchInstaller implements PackageInstallerInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * (non-PHPdoc) |
|
| 23 | - * @see \Mouf\Installer\PackageInstallerInterface::install() |
|
| 24 | - * @param MoufManager $moufManager |
|
| 25 | - * @throws \Mouf\MoufException |
|
| 26 | - */ |
|
| 27 | - public static function install(MoufManager $moufManager) |
|
| 28 | - { |
|
| 29 | - // Let's create the instance. |
|
| 30 | - $patchService = InstallUtils::getOrCreateInstance('patchService', 'Mouf\\Utils\\Patcher\\PatchService', $moufManager); |
|
| 31 | - |
|
| 32 | - $consoleUtils = new ConsoleUtils($moufManager); |
|
| 33 | - |
|
| 34 | - $listPatchesCommand = $moufManager->createInstance(ListPatchesCommand::class); |
|
| 35 | - $listPatchesCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 36 | - $consoleUtils->registerCommand($listPatchesCommand); |
|
| 37 | - |
|
| 38 | - $applyAllPatchesCommand = $moufManager->createInstance(ApplyAllPatchesCommand::class); |
|
| 39 | - $applyAllPatchesCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 40 | - $consoleUtils->registerCommand($applyAllPatchesCommand); |
|
| 41 | - |
|
| 42 | - $applyPatchCommand = $moufManager->createInstance(ApplyPatchCommand::class); |
|
| 43 | - $applyPatchCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 44 | - $consoleUtils->registerCommand($applyPatchCommand); |
|
| 45 | - |
|
| 46 | - $skipPatchCommand = $moufManager->createInstance(SkipPatchCommand::class); |
|
| 47 | - $skipPatchCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 48 | - $consoleUtils->registerCommand($skipPatchCommand); |
|
| 49 | - |
|
| 50 | - $revertPatchCommand = $moufManager->createInstance(RevertPatchCommand::class); |
|
| 51 | - $revertPatchCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 52 | - $consoleUtils->registerCommand($revertPatchCommand); |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - // Let's rewrite the MoufComponents.php file to save the component |
|
| 56 | - $moufManager->rewriteMouf(); |
|
| 57 | - } |
|
| 21 | + /** |
|
| 22 | + * (non-PHPdoc) |
|
| 23 | + * @see \Mouf\Installer\PackageInstallerInterface::install() |
|
| 24 | + * @param MoufManager $moufManager |
|
| 25 | + * @throws \Mouf\MoufException |
|
| 26 | + */ |
|
| 27 | + public static function install(MoufManager $moufManager) |
|
| 28 | + { |
|
| 29 | + // Let's create the instance. |
|
| 30 | + $patchService = InstallUtils::getOrCreateInstance('patchService', 'Mouf\\Utils\\Patcher\\PatchService', $moufManager); |
|
| 31 | + |
|
| 32 | + $consoleUtils = new ConsoleUtils($moufManager); |
|
| 33 | + |
|
| 34 | + $listPatchesCommand = $moufManager->createInstance(ListPatchesCommand::class); |
|
| 35 | + $listPatchesCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 36 | + $consoleUtils->registerCommand($listPatchesCommand); |
|
| 37 | + |
|
| 38 | + $applyAllPatchesCommand = $moufManager->createInstance(ApplyAllPatchesCommand::class); |
|
| 39 | + $applyAllPatchesCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 40 | + $consoleUtils->registerCommand($applyAllPatchesCommand); |
|
| 41 | + |
|
| 42 | + $applyPatchCommand = $moufManager->createInstance(ApplyPatchCommand::class); |
|
| 43 | + $applyPatchCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 44 | + $consoleUtils->registerCommand($applyPatchCommand); |
|
| 45 | + |
|
| 46 | + $skipPatchCommand = $moufManager->createInstance(SkipPatchCommand::class); |
|
| 47 | + $skipPatchCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 48 | + $consoleUtils->registerCommand($skipPatchCommand); |
|
| 49 | + |
|
| 50 | + $revertPatchCommand = $moufManager->createInstance(RevertPatchCommand::class); |
|
| 51 | + $revertPatchCommand->getConstructorArgumentProperty("patchService")->setValue($patchService); |
|
| 52 | + $consoleUtils->registerCommand($revertPatchCommand); |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + // Let's rewrite the MoufComponents.php file to save the component |
|
| 56 | + $moufManager->rewriteMouf(); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -15,45 +15,45 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class SkipPatchCommand extends Command |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var PatchService |
|
| 20 | - */ |
|
| 21 | - private $patchService; |
|
| 18 | + /** |
|
| 19 | + * @var PatchService |
|
| 20 | + */ |
|
| 21 | + private $patchService; |
|
| 22 | 22 | |
| 23 | - public function __construct(PatchService $patchService) |
|
| 24 | - { |
|
| 25 | - parent::__construct(); |
|
| 26 | - $this->patchService = $patchService; |
|
| 27 | - } |
|
| 23 | + public function __construct(PatchService $patchService) |
|
| 24 | + { |
|
| 25 | + parent::__construct(); |
|
| 26 | + $this->patchService = $patchService; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function configure() |
|
| 34 | - { |
|
| 35 | - $this |
|
| 36 | - ->setName('patches:skip') |
|
| 37 | - ->setDescription('Skip a patch.') |
|
| 38 | - ->addArgument( |
|
| 39 | - 'name', |
|
| 40 | - InputArgument::REQUIRED, |
|
| 41 | - 'The name of the patch instance to be skipped' |
|
| 42 | - ) |
|
| 43 | - ->setHelp(<<<EOT |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function configure() |
|
| 34 | + { |
|
| 35 | + $this |
|
| 36 | + ->setName('patches:skip') |
|
| 37 | + ->setDescription('Skip a patch.') |
|
| 38 | + ->addArgument( |
|
| 39 | + 'name', |
|
| 40 | + InputArgument::REQUIRED, |
|
| 41 | + 'The name of the patch instance to be skipped' |
|
| 42 | + ) |
|
| 43 | + ->setHelp(<<<EOT |
|
| 44 | 44 | Skips a patch. You must pass in parameter the name of the patch. |
| 45 | 45 | EOT |
| 46 | - ); |
|
| 47 | - } |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * {@inheritdoc} |
|
| 51 | - */ |
|
| 52 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | - { |
|
| 54 | - $patchName = $input->getArgument('name'); |
|
| 55 | - $this->patchService->skip($patchName); |
|
| 49 | + /** |
|
| 50 | + * {@inheritdoc} |
|
| 51 | + */ |
|
| 52 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | + { |
|
| 54 | + $patchName = $input->getArgument('name'); |
|
| 55 | + $this->patchService->skip($patchName); |
|
| 56 | 56 | |
| 57 | - $output->writeln('Patch marked as skipped'); |
|
| 58 | - } |
|
| 57 | + $output->writeln('Patch marked as skipped'); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -15,47 +15,47 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ApplyPatchCommand extends Command |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var PatchService |
|
| 20 | - */ |
|
| 21 | - private $patchService; |
|
| 22 | - |
|
| 23 | - public function __construct(PatchService $patchService) |
|
| 24 | - { |
|
| 25 | - parent::__construct(); |
|
| 26 | - $this->patchService = $patchService; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function configure() |
|
| 34 | - { |
|
| 35 | - $this |
|
| 36 | - ->setName('patches:apply') |
|
| 37 | - ->setDescription('Apply a patch.') |
|
| 38 | - ->addArgument( |
|
| 39 | - 'name', |
|
| 40 | - InputArgument::REQUIRED, |
|
| 41 | - 'The name of the patch instance to be applied' |
|
| 42 | - ) |
|
| 43 | - ->setHelp(<<<EOT |
|
| 18 | + /** |
|
| 19 | + * @var PatchService |
|
| 20 | + */ |
|
| 21 | + private $patchService; |
|
| 22 | + |
|
| 23 | + public function __construct(PatchService $patchService) |
|
| 24 | + { |
|
| 25 | + parent::__construct(); |
|
| 26 | + $this->patchService = $patchService; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function configure() |
|
| 34 | + { |
|
| 35 | + $this |
|
| 36 | + ->setName('patches:apply') |
|
| 37 | + ->setDescription('Apply a patch.') |
|
| 38 | + ->addArgument( |
|
| 39 | + 'name', |
|
| 40 | + InputArgument::REQUIRED, |
|
| 41 | + 'The name of the patch instance to be applied' |
|
| 42 | + ) |
|
| 43 | + ->setHelp(<<<EOT |
|
| 44 | 44 | Apply a patch. You must pass in parameter the name of the patch. |
| 45 | 45 | |
| 46 | 46 | Use patches:apply-all to apply all pending patches. |
| 47 | 47 | EOT |
| 48 | - ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 55 | - { |
|
| 56 | - $patchName = $input->getArgument('name'); |
|
| 57 | - $this->patchService->apply($patchName); |
|
| 58 | - |
|
| 59 | - $output->writeln('Patch successfully applied'); |
|
| 60 | - } |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 55 | + { |
|
| 56 | + $patchName = $input->getArgument('name'); |
|
| 57 | + $this->patchService->apply($patchName); |
|
| 58 | + |
|
| 59 | + $output->writeln('Patch successfully applied'); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -15,65 +15,65 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ApplyAllPatchesCommand extends Command |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var PatchService |
|
| 20 | - */ |
|
| 21 | - private $patchService; |
|
| 18 | + /** |
|
| 19 | + * @var PatchService |
|
| 20 | + */ |
|
| 21 | + private $patchService; |
|
| 22 | 22 | |
| 23 | - public function __construct(PatchService $patchService) |
|
| 24 | - { |
|
| 25 | - parent::__construct(); |
|
| 26 | - $this->patchService = $patchService; |
|
| 27 | - } |
|
| 23 | + public function __construct(PatchService $patchService) |
|
| 24 | + { |
|
| 25 | + parent::__construct(); |
|
| 26 | + $this->patchService = $patchService; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function configure() |
|
| 34 | - { |
|
| 35 | - $this |
|
| 36 | - ->setName('patches:apply-all') |
|
| 37 | - ->setDescription('Apply all pending patches.') |
|
| 38 | - ->setDefinition(array( |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function configure() |
|
| 34 | + { |
|
| 35 | + $this |
|
| 36 | + ->setName('patches:apply-all') |
|
| 37 | + ->setDescription('Apply all pending patches.') |
|
| 38 | + ->setDefinition(array( |
|
| 39 | 39 | |
| 40 | - )) |
|
| 41 | - ->setHelp(<<<EOT |
|
| 40 | + )) |
|
| 41 | + ->setHelp(<<<EOT |
|
| 42 | 42 | Apply all pending patches. |
| 43 | 43 | |
| 44 | 44 | Use patches:apply if you want to cherry-pick a particular patch. |
| 45 | 45 | EOT |
| 46 | - ); |
|
| 47 | - } |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * {@inheritdoc} |
|
| 51 | - */ |
|
| 52 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | - { |
|
| 54 | - $patchesArray = $this->patchService->getView(); |
|
| 49 | + /** |
|
| 50 | + * {@inheritdoc} |
|
| 51 | + */ |
|
| 52 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | + { |
|
| 54 | + $patchesArray = $this->patchService->getView(); |
|
| 55 | 55 | |
| 56 | - $count = 0; |
|
| 57 | - try { |
|
| 58 | - foreach ($patchesArray as $patch) { |
|
| 59 | - if ($patch['status'] == PatchInterface::STATUS_AWAITING || $patch['status'] == PatchInterface::STATUS_ERROR) { |
|
| 60 | - $this->patchService->apply($patch['uniqueName']); |
|
| 61 | - $count++; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } catch (\Exception $e) { |
|
| 65 | - $output->writeln(sprintf( |
|
| 66 | - 'An error occured while applying patch <info>%s</info>: <error>%s</error>', $patch['uniqueName'], $e->getMessage() |
|
| 67 | - )); |
|
| 68 | - throw $e; |
|
| 69 | - } |
|
| 56 | + $count = 0; |
|
| 57 | + try { |
|
| 58 | + foreach ($patchesArray as $patch) { |
|
| 59 | + if ($patch['status'] == PatchInterface::STATUS_AWAITING || $patch['status'] == PatchInterface::STATUS_ERROR) { |
|
| 60 | + $this->patchService->apply($patch['uniqueName']); |
|
| 61 | + $count++; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } catch (\Exception $e) { |
|
| 65 | + $output->writeln(sprintf( |
|
| 66 | + 'An error occured while applying patch <info>%s</info>: <error>%s</error>', $patch['uniqueName'], $e->getMessage() |
|
| 67 | + )); |
|
| 68 | + throw $e; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - if ($count) { |
|
| 72 | - $output->writeln(sprintf( |
|
| 73 | - '<info>%d</info> patches successfully applied', $count |
|
| 74 | - )); |
|
| 75 | - } else { |
|
| 76 | - $output->writeln('<info>No patches to apply</info>'); |
|
| 77 | - } |
|
| 78 | - } |
|
| 71 | + if ($count) { |
|
| 72 | + $output->writeln(sprintf( |
|
| 73 | + '<info>%d</info> patches successfully applied', $count |
|
| 74 | + )); |
|
| 75 | + } else { |
|
| 76 | + $output->writeln('<info>No patches to apply</info>'); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -15,45 +15,45 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class RevertPatchCommand extends Command |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var PatchService |
|
| 20 | - */ |
|
| 21 | - private $patchService; |
|
| 18 | + /** |
|
| 19 | + * @var PatchService |
|
| 20 | + */ |
|
| 21 | + private $patchService; |
|
| 22 | 22 | |
| 23 | - public function __construct(PatchService $patchService) |
|
| 24 | - { |
|
| 25 | - parent::__construct(); |
|
| 26 | - $this->patchService = $patchService; |
|
| 27 | - } |
|
| 23 | + public function __construct(PatchService $patchService) |
|
| 24 | + { |
|
| 25 | + parent::__construct(); |
|
| 26 | + $this->patchService = $patchService; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function configure() |
|
| 34 | - { |
|
| 35 | - $this |
|
| 36 | - ->setName('patches:revert') |
|
| 37 | - ->setDescription('Revert a patch.') |
|
| 38 | - ->addArgument( |
|
| 39 | - 'name', |
|
| 40 | - InputArgument::REQUIRED, |
|
| 41 | - 'The name of the patch instance to be reverted' |
|
| 42 | - ) |
|
| 43 | - ->setHelp(<<<EOT |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function configure() |
|
| 34 | + { |
|
| 35 | + $this |
|
| 36 | + ->setName('patches:revert') |
|
| 37 | + ->setDescription('Revert a patch.') |
|
| 38 | + ->addArgument( |
|
| 39 | + 'name', |
|
| 40 | + InputArgument::REQUIRED, |
|
| 41 | + 'The name of the patch instance to be reverted' |
|
| 42 | + ) |
|
| 43 | + ->setHelp(<<<EOT |
|
| 44 | 44 | Reverts a patch. You must pass in parameter the name of the patch. |
| 45 | 45 | EOT |
| 46 | - ); |
|
| 47 | - } |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * {@inheritdoc} |
|
| 51 | - */ |
|
| 52 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | - { |
|
| 54 | - $patchName = $input->getArgument('name'); |
|
| 55 | - $this->patchService->revert($patchName); |
|
| 49 | + /** |
|
| 50 | + * {@inheritdoc} |
|
| 51 | + */ |
|
| 52 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | + { |
|
| 54 | + $patchName = $input->getArgument('name'); |
|
| 55 | + $this->patchService->revert($patchName); |
|
| 56 | 56 | |
| 57 | - $output->writeln('Patch successfully reverted'); |
|
| 58 | - } |
|
| 57 | + $output->writeln('Patch successfully reverted'); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -15,66 +15,66 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class ListPatchesCommand extends Command |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var PatchService |
|
| 20 | - */ |
|
| 21 | - private $patchService; |
|
| 18 | + /** |
|
| 19 | + * @var PatchService |
|
| 20 | + */ |
|
| 21 | + private $patchService; |
|
| 22 | 22 | |
| 23 | - public function __construct(PatchService $patchService) |
|
| 24 | - { |
|
| 25 | - parent::__construct(); |
|
| 26 | - $this->patchService = $patchService; |
|
| 27 | - } |
|
| 23 | + public function __construct(PatchService $patchService) |
|
| 24 | + { |
|
| 25 | + parent::__construct(); |
|
| 26 | + $this->patchService = $patchService; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - protected function configure() |
|
| 34 | - { |
|
| 35 | - $this |
|
| 36 | - ->setName('patches:list') |
|
| 37 | - ->setDescription('List all the patches.') |
|
| 38 | - ->setDefinition(array( |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + protected function configure() |
|
| 34 | + { |
|
| 35 | + $this |
|
| 36 | + ->setName('patches:list') |
|
| 37 | + ->setDescription('List all the patches.') |
|
| 38 | + ->setDefinition(array( |
|
| 39 | 39 | |
| 40 | - )) |
|
| 41 | - ->setHelp(<<<EOT |
|
| 40 | + )) |
|
| 41 | + ->setHelp(<<<EOT |
|
| 42 | 42 | List all patches declared in Mouf patch service. |
| 43 | 43 | |
| 44 | 44 | The command will display the status of each patch, i.e. whether it has been applied or skipped or is waiting to be applied. |
| 45 | 45 | EOT |
| 46 | - ); |
|
| 47 | - } |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * {@inheritdoc} |
|
| 51 | - */ |
|
| 52 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | - { |
|
| 54 | - $patches = $this->patchService->getView(); |
|
| 49 | + /** |
|
| 50 | + * {@inheritdoc} |
|
| 51 | + */ |
|
| 52 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
| 53 | + { |
|
| 54 | + $patches = $this->patchService->getView(); |
|
| 55 | 55 | |
| 56 | - $rows = array_map(function($row) { |
|
| 57 | - return [ $row['uniqueName'], $this->renderStatus($row['status']) ]; |
|
| 58 | - }, $patches); |
|
| 56 | + $rows = array_map(function($row) { |
|
| 57 | + return [ $row['uniqueName'], $this->renderStatus($row['status']) ]; |
|
| 58 | + }, $patches); |
|
| 59 | 59 | |
| 60 | - $table = new Table($output); |
|
| 61 | - $table |
|
| 62 | - ->setHeaders(array('Patch', 'Status')) |
|
| 63 | - ->setRows($rows) |
|
| 64 | - ; |
|
| 65 | - $table->render(); |
|
| 66 | - } |
|
| 60 | + $table = new Table($output); |
|
| 61 | + $table |
|
| 62 | + ->setHeaders(array('Patch', 'Status')) |
|
| 63 | + ->setRows($rows) |
|
| 64 | + ; |
|
| 65 | + $table->render(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - private function renderStatus($status) { |
|
| 69 | - $map = [ |
|
| 70 | - PatchInterface::STATUS_APPLIED => "<info>Applied</info>", |
|
| 71 | - PatchInterface::STATUS_SKIPPED => "<comment>Skipped</comment>", |
|
| 72 | - PatchInterface::STATUS_AWAITING => "Awaiting", |
|
| 73 | - PatchInterface::STATUS_ERROR => "<error>Skipped</error>", |
|
| 74 | - ]; |
|
| 75 | - if (!isset($map[$status])) { |
|
| 76 | - throw new \Exception('Unexpected status "'.$map[$status].'"'); |
|
| 77 | - } |
|
| 78 | - return $map[$status]; |
|
| 79 | - } |
|
| 68 | + private function renderStatus($status) { |
|
| 69 | + $map = [ |
|
| 70 | + PatchInterface::STATUS_APPLIED => "<info>Applied</info>", |
|
| 71 | + PatchInterface::STATUS_SKIPPED => "<comment>Skipped</comment>", |
|
| 72 | + PatchInterface::STATUS_AWAITING => "Awaiting", |
|
| 73 | + PatchInterface::STATUS_ERROR => "<error>Skipped</error>", |
|
| 74 | + ]; |
|
| 75 | + if (!isset($map[$status])) { |
|
| 76 | + throw new \Exception('Unexpected status "'.$map[$status].'"'); |
|
| 77 | + } |
|
| 78 | + return $map[$status]; |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | $patches = $this->patchService->getView(); |
| 55 | 55 | |
| 56 | 56 | $rows = array_map(function($row) { |
| 57 | - return [ $row['uniqueName'], $this->renderStatus($row['status']) ]; |
|
| 57 | + return [$row['uniqueName'], $this->renderStatus($row['status'])]; |
|
| 58 | 58 | }, $patches); |
| 59 | 59 | |
| 60 | 60 | $table = new Table($output); |
@@ -18,7 +18,6 @@ |
||
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The controller to track which patchs have been applied. |
| 21 | - |
|
| 22 | 21 | */ |
| 23 | 22 | class PatchController extends AbstractMoufInstanceController { |
| 24 | 23 | |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | * @Action |
| 44 | 44 | * @Logged |
| 45 | 45 | */ |
| 46 | - public function defaultAction($name, $selfedit="false") { |
|
| 46 | + public function defaultAction($name, $selfedit = "false") { |
|
| 47 | 47 | $this->initController($name, $selfedit); |
| 48 | 48 | |
| 49 | 49 | $patchService = new InstanceProxy($name, $selfedit == "true"); |
@@ -161,15 +161,15 @@ |
||
| 161 | 161 | |
| 162 | 162 | $html = '<strong>Patcher</strong>: <a href="'.ROOT_URL.'vendor/mouf/mouf/patcher/?name='.$instanceName.'" class="btn btn-large btn-success patch-run-all"><i class="icon-arrow-right icon-white"></i> Apply '; |
| 163 | 163 | if ($nbAwaitingPatchs != 0) { |
| 164 | - $html .= $nbAwaitingPatchs." awaiting patch".(($nbAwaitingPatchs != 1)?"es":""); |
|
| 164 | + $html .= $nbAwaitingPatchs." awaiting patch".(($nbAwaitingPatchs != 1) ? "es" : ""); |
|
| 165 | 165 | if ($nbPatchsInError != 0) { |
| 166 | - $html .=" and"; |
|
| 166 | + $html .= " and"; |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | if ($nbPatchsInError != 0) { |
| 170 | - $html .=$nbPatchsInError." patch".(($nbPatchsInError != 1)?"es":"")." in error"; |
|
| 170 | + $html .= $nbPatchsInError." patch".(($nbPatchsInError != 1) ? "es" : "")." in error"; |
|
| 171 | 171 | } |
| 172 | - $html .='</a>'; |
|
| 172 | + $html .= '</a>'; |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | return new MoufValidatorResult($status, $html); |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | <?php |
| 20 | 20 | echo '<button class="btn btn-large btn-success patch-run-all"><i class="icon-arrow-right icon-white"></i> Apply '; |
| 21 | 21 | if ($this->nbAwaiting != 0) { |
| 22 | - echo $this->nbAwaiting." awaiting patch".(($this->nbAwaiting != 1)?"es":""); |
|
| 22 | + echo $this->nbAwaiting." awaiting patch".(($this->nbAwaiting != 1) ? "es" : ""); |
|
| 23 | 23 | if ($this->nbError != 0) { |
| 24 | 24 | echo " and "; |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | if ($this->nbError != 0) { |
| 28 | - echo $this->nbError." patch".(($this->nbError != 1)?"es":"")." in error"; |
|
| 28 | + echo $this->nbError." patch".(($this->nbError != 1) ? "es" : "")." in error"; |
|
| 29 | 29 | } |
| 30 | 30 | echo '</button>'; |
| 31 | 31 | ?> |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | <td> |
| 67 | 67 | <?php |
| 68 | 68 | |
| 69 | - echo '<button class="btn btn-mini btn-success patch-apply" '.(($patch['status'] == PatchInterface::STATUS_APPLIED)?'disabled="disabled"':'').'><i class="icon-arrow-right icon-white"></i> Apply</button>'; |
|
| 70 | - echo ' <button class="btn btn-mini btn-info patch-skip" '.(($patch['status'] == PatchInterface::STATUS_APPLIED || $patch['status'] == PatchInterface::STATUS_SKIPPED)?'disabled="disabled"':'').'><i class="icon-share-alt icon-white"></i> Skip</button>'; |
|
| 69 | + echo '<button class="btn btn-mini btn-success patch-apply" '.(($patch['status'] == PatchInterface::STATUS_APPLIED) ? 'disabled="disabled"' : '').'><i class="icon-arrow-right icon-white"></i> Apply</button>'; |
|
| 70 | + echo ' <button class="btn btn-mini btn-info patch-skip" '.(($patch['status'] == PatchInterface::STATUS_APPLIED || $patch['status'] == PatchInterface::STATUS_SKIPPED) ? 'disabled="disabled"' : '').'><i class="icon-share-alt icon-white"></i> Skip</button>'; |
|
| 71 | 71 | if ($patch['canRevert']) { |
| 72 | - echo ' <button class="btn btn-mini btn-inverse patch-revert" '.(($patch['status'] == PatchInterface::STATUS_AWAITING)?'disabled="disabled"':'').'><i class="icon-arrow-left icon-white"></i> Revert</button>'; |
|
| 72 | + echo ' <button class="btn btn-mini btn-inverse patch-revert" '.(($patch['status'] == PatchInterface::STATUS_AWAITING) ? 'disabled="disabled"' : '').'><i class="icon-arrow-left icon-white"></i> Revert</button>'; |
|
| 73 | 73 | } |
| 74 | 74 | if ($patch['edit_url']) { |
| 75 | 75 | echo ' <a class="btn btn-mini btn-danger patch-edit" href="'.ROOT_URL.$patch['edit_url'].'"><i class="icon-edit icon-white"></i> Edit</a>'; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | <tr> |
| 83 | 83 | <td colspan="4"> |
| 84 | 84 | <div class="alert alert-error"> |
| 85 | - <strong>Last error message</strong>: <?php echo plainstring_to_htmlprotected($patch['error_message']);?> |
|
| 85 | + <strong>Last error message</strong>: <?php echo plainstring_to_htmlprotected($patch['error_message']); ?> |
|
| 86 | 86 | </div> |
| 87 | 87 | </td> |
| 88 | 88 | </tr> |