Skip to content

Commit 6e7a6a6

Browse files
authored
Merge pull request #15 from matteosister/master
Update for newer Symfony versions
2 parents 64a0f60 + d9db374 commit 6e7a6a6

File tree

6 files changed

+83
-29
lines changed

6 files changed

+83
-29
lines changed

Command/CommitCommand.php

+18-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use GitElephant\Objects\Remote;
77
use GitElephant\Repository;
88
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
9+
use Symfony\Component\Console\Command\Command;
910
use Symfony\Component\Console\Input\InputArgument;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Input\InputOption;
@@ -19,8 +20,22 @@
1920
* @package Cypress\GitElephantBundle\Command
2021
* @author David Romaní <[email protected]>
2122
*/
22-
class CommitCommand extends ContainerAwareCommand
23+
class CommitCommand extends Command
2324
{
25+
26+
/**
27+
* The collection of repositories from which one will be commiting
28+
*
29+
* @var GitElephantRepositoryCollection
30+
*/
31+
private $repositories;
32+
33+
public function __construct(GitElephantRepositoryCollection $c)
34+
{
35+
$this->repositories = $c;
36+
parent::__construct();
37+
}
38+
2439
/**
2540
* Commit command configuration
2641
*/
@@ -83,15 +98,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
8398
);
8499
}
85100

86-
/** @var GitElephantRepositoryCollection $rc */
87-
$rc = $this->getContainer()->get('git_repositories');
88-
89-
if ($rc->count() == 0) {
101+
if ($this->repositories->count() == 0) {
90102
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
91103
}
92104

93105
/** @var Repository $repository */
94-
foreach ($rc as $key => $repository) {
106+
foreach ($this->repositories as $key => $repository) {
95107
if ($key == 0 || $key > 0 && $input->getOption('all')) {
96108
$repository->commit($input->getArgument('message'), !$input->getOption('no-stage-all'));
97109
if (!$input->getOption('no-push')) {

Command/HitCommand.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Cypress\GitElephantBundle\Collection\GitElephantRepositoryCollection;
66
use GitElephant\Objects\Branch;
77
use GitElephant\Repository;
8-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
8+
use Symfony\Component\Console\Command\Command;
99
use Symfony\Component\Console\Input\ArrayInput;
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Input\InputInterface;
@@ -20,8 +20,22 @@
2020
* @package Cypress\GitElephantBundle\Command
2121
* @author David Romaní <[email protected]>
2222
*/
23-
class HitCommand extends ContainerAwareCommand
23+
class HitCommand extends Command
2424
{
25+
26+
/**
27+
* The collection of repositories from which one will be commiting
28+
*
29+
* @var GitElephantRepositoryCollection
30+
*/
31+
private $repositories;
32+
33+
public function __construct(GitElephantRepositoryCollection $c)
34+
{
35+
$this->repositories = $c;
36+
parent::__construct();
37+
}
38+
2539
/**
2640
* Hit command configuration
2741
*/
@@ -102,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
102116
}
103117

104118
/** @var GitElephantRepositoryCollection $rc */
105-
$rc = $this->getContainer()->get('git_repositories');
119+
$rc = $this->repositories;
106120

107121
if ($rc->count() == 0) {
108122
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');

Command/MergeCommand.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use GitElephant\Objects\Branch;
77
use GitElephant\Objects\Remote;
88
use GitElephant\Repository;
9-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
9+
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputArgument;
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Input\InputOption;
@@ -20,8 +20,21 @@
2020
* @package Cypress\GitElephantBundle\Command
2121
* @author David Romaní <[email protected]>
2222
*/
23-
class MergeCommand extends ContainerAwareCommand
23+
class MergeCommand extends Command
2424
{
25+
/**
26+
* The collection of repositories from which one will be commiting
27+
*
28+
* @var GitElephantRepositoryCollection
29+
*/
30+
private $repositories;
31+
32+
public function __construct(GitElephantRepositoryCollection $c)
33+
{
34+
$this->repositories = $c;
35+
parent::__construct();
36+
}
37+
2538
/**
2639
* Merge command configuration
2740
*/
@@ -92,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
92105
}
93106

94107
/** @var GitElephantRepositoryCollection $rc */
95-
$rc = $this->getContainer()->get('git_repositories');
108+
$rc = $this->repositories;
96109

97110
if ($rc->count() == 0) {
98111
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');

Command/TagCommand.php

+22-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
namespace Cypress\GitElephantBundle\Command;
44

5-
use Cypress\GitElephantBundle\Collection\GitElephantRepositoryCollection;
6-
use GitElephant\Objects\Remote;
75
use GitElephant\Repository;
8-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6+
use GitElephant\Objects\Remote;
7+
use Symfony\Component\Console\Output\Output;
8+
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Input\InputOption;
910
use Symfony\Component\Console\Input\InputArgument;
1011
use Symfony\Component\Console\Input\InputInterface;
11-
use Symfony\Component\Console\Input\InputOption;
12-
use Symfony\Component\Console\Output\Output;
1312
use Symfony\Component\Console\Output\OutputInterface;
13+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
14+
use Cypress\GitElephantBundle\Collection\GitElephantRepositoryCollection;
1415

1516
/**
1617
* Class TagCommand
@@ -19,8 +20,22 @@
1920
* @package Cypress\GitElephantBundle\Command
2021
* @author David Romaní <[email protected]>
2122
*/
22-
class TagCommand extends ContainerAwareCommand
23+
class TagCommand extends Command
2324
{
25+
26+
/**
27+
* The collection of repositories from which one will be commiting
28+
*
29+
* @var GitElephantRepositoryCollection
30+
*/
31+
private $repositories;
32+
33+
public function __construct(GitElephantRepositoryCollection $c)
34+
{
35+
$this->repositories = $c;
36+
parent::__construct();
37+
}
38+
2439
/**
2540
* Tag command configuration
2641
*/
@@ -83,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8398
}
8499

85100
/** @var GitElephantRepositoryCollection $rc */
86-
$rc = $this->getContainer()->get('git_repositories');
101+
$rc = $this->repositories;
87102

88103
if ($rc->count() == 0) {
89104
throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');

DependencyInjection/Configuration.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
1717
*/
1818
public function getConfigTreeBuilder()
1919
{
20-
$treeBuilder = new TreeBuilder();
21-
$rootNode = $treeBuilder->root('cypress_git_elephant');
20+
$treeBuilder = new TreeBuilder('cypress_git_elephant');
21+
$rootNode = $treeBuilder->getRootNode();
2222

2323
$rootNode
2424
->children()

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.0.0",
18-
"symfony/config": "^2.3|^3.0|^4.0",
19-
"symfony/console": "^2.3|^3.0|^4.0",
20-
"symfony/dependency-injection": "^2.3|^3.0|^4.0",
21-
"symfony/framework-bundle": "^2.3|^3.0|^4.0",
22-
"symfony/http-foundation": "^2.3|^3.0|^4.0",
23-
"symfony/http-kernel": "^2.3|^3.0|^4.0",
24-
"cypresslab/gitelephant": "^3.0|^4.0"
17+
"php": ">=7.2.0",
18+
"symfony/config": "^4.0|^5.0",
19+
"symfony/console": "^4.0|^5.0",
20+
"symfony/dependency-injection": "^4.0|^5.0",
21+
"symfony/framework-bundle": "^4.0|^5.0",
22+
"symfony/http-foundation": "^4.0|^5.0",
23+
"symfony/http-kernel": "^4.0|^5.0",
24+
"cypresslab/gitelephant": "^4.0"
2525
},
2626
"autoload": {
2727
"psr-0": {

0 commit comments

Comments
 (0)