Completed
Pull Request — 1.1 (#4)
by
unknown
02:47
created
src/Mouf/Utils/Patcher/PatchInstaller.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/SkipPatchCommand.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -15,45 +15,45 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/ApplyPatchCommand.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,47 +15,47 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/ApplyAllPatchesCommand.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/RevertPatchCommand.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -15,45 +15,45 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Commands/ListPatchesCommand.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,66 +15,66 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Mouf/Utils/Patcher/Controllers/PatchController.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 block discarded – undo
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
 	
Please login to merge, or discard this patch.
src/views/patchesList.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,8 @@  discard block
 block discarded – undo
5 5
 <?php if (empty($this->patchesArray)): ?>
6 6
 <div class="alert alert-info">No patches have been registered yet.</div>
7 7
 <?php 
8
-else:
8
+else {
9
+	:
9 10
 
10 11
 if ($this->nbAwaiting == 0 && $this->nbError == 0) {
11 12
 ?>
@@ -14,7 +15,9 @@  discard block
 block discarded – undo
14 15
 } else {
15 16
 ?>
16 17
 <form action="runAllPatches" method="post">
17
-	<input name="name" type="hidden" value="<?php echo plainstring_to_htmlprotected($this->instanceName); ?>"></input>
18
+	<input name="name" type="hidden" value="<?php echo plainstring_to_htmlprotected($this->instanceName);
19
+}
20
+?>"></input>
18 21
 	<input name="selfedit" type="hidden" value="<?php echo plainstring_to_htmlprotected($this->selfedit); ?>"></input>
19 22
 <?php 
20 23
 	echo '<button class="btn btn-large btn-success patch-run-all"><i class="icon-arrow-right icon-white"></i> Apply ';
Please login to merge, or discard this patch.