1 | <?php |
||||
2 | |||||
3 | namespace Terox\SubscriptionBundle\Command; |
||||
4 | |||||
5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
||||
6 | use Symfony\Component\Console\Input\InputArgument; |
||||
7 | use Symfony\Component\Console\Input\InputInterface; |
||||
8 | use Symfony\Component\Console\Output\OutputInterface; |
||||
9 | use Terox\SubscriptionBundle\Model\SubscriptionInterface; |
||||
10 | use Terox\SubscriptionBundle\Subscription\SubscriptionManager; |
||||
11 | |||||
12 | abstract class AbstractCommand extends ContainerAwareCommand |
||||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||||
13 | { |
||||
14 | /** |
||||
15 | * @var InputInterface |
||||
16 | */ |
||||
17 | protected $input; |
||||
18 | |||||
19 | /** |
||||
20 | * @var OutputInterface |
||||
21 | */ |
||||
22 | protected $output; |
||||
23 | |||||
24 | /** |
||||
25 | * {@inheritdoc} |
||||
26 | */ |
||||
27 | 3 | protected function configure() |
|||
28 | { |
||||
29 | 3 | $this->addArgument( |
|||
30 | 3 | 'id', |
|||
31 | 3 | InputArgument::REQUIRED, |
|||
32 | 3 | 'Subscription ID' |
|||
33 | ); |
||||
34 | 3 | } |
|||
35 | |||||
36 | /** |
||||
37 | * {@inheritdoc} |
||||
38 | */ |
||||
39 | 3 | protected function execute(InputInterface $input, OutputInterface $output) |
|||
40 | { |
||||
41 | // Save the input interfaces |
||||
42 | 3 | $this->input = $input; |
|||
43 | 3 | $this->output = $output; |
|||
44 | |||||
45 | 3 | $subscriptionId = $input->getArgument('id'); |
|||
46 | 3 | $subscription = $this->getContainer()->get('terox.subscription.repository.subscription')->findById($subscriptionId); |
|||
47 | |||||
48 | 3 | if(null === $subscription) { |
|||
49 | return $output->writeln(sprintf('<error>The subscription with ID "%s" was not found.</error>', $subscriptionId)); |
||||
0 ignored issues
–
show
It seems like
$subscriptionId can also be of type string[] ; however, parameter $args of sprintf() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
50 | } |
||||
51 | |||||
52 | // Execute the action |
||||
53 | 3 | $this->action($subscription); |
|||
54 | |||||
55 | 3 | $output->writeln('<green>Finished.</green>'); |
|||
56 | 3 | } |
|||
57 | |||||
58 | /** |
||||
59 | * Action to execute when |
||||
60 | * |
||||
61 | * @param SubscriptionInterface $subscription |
||||
62 | * |
||||
63 | * @return void |
||||
64 | */ |
||||
65 | abstract protected function action(SubscriptionInterface $subscription); |
||||
66 | |||||
67 | /** |
||||
68 | * Get SubscriptionManager. |
||||
69 | * |
||||
70 | * @return SubscriptionManager |
||||
71 | */ |
||||
72 | 3 | protected function getManager() |
|||
73 | { |
||||
74 | 3 | return $this->getContainer()->get('terox.subscription.manager'); |
|||
75 | } |
||||
76 | } |
||||
77 |