Skip to content

Commit 6cc66d9

Browse files
SebScoFrdkarlovi
authored andcommitted
Fixing unregistered commands (#534)
* Update oauth.xml * fixing commands * updating composer * composer fixes * fixing unregistered commands * cleaning
1 parent ed3ec73 commit 6cc66d9

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed

Command/BaseCommand.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSOAuthServerBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\OAuthServerBundle\Command;
13+
14+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15+
use Symfony\Component\DependencyInjection\ContainerInterface;
16+
use Symfony\Component\Console\Command\Command;
17+
18+
class BaseCommand extends Command implements ContainerAwareInterface
19+
{
20+
/**
21+
* @var ContainerInterface
22+
*/
23+
protected $container;
24+
25+
/**
26+
* {@inheritDoc}
27+
*/
28+
public function setContainer(ContainerInterface $container = null)
29+
{
30+
$this->container = $container;
31+
}
32+
33+
/**
34+
* @return ContainerInterface
35+
*/
36+
public function getContainer()
37+
{
38+
return $this->container;
39+
}
40+
}

Command/CleanCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@
1111

1212
namespace FOS\OAuthServerBundle\Command;
1313

14-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1514
use Symfony\Component\Console\Input\InputInterface;
1615
use Symfony\Component\Console\Output\OutputInterface;
1716
use FOS\OAuthServerBundle\Model\TokenManagerInterface;
1817
use FOS\OAuthServerBundle\Model\AuthCodeManagerInterface;
1918

20-
class CleanCommand extends ContainerAwareCommand
19+
class CleanCommand extends BaseCommand
2120
{
2221
/**
2322
* {@inheritdoc}
2423
*/
2524
protected function configure()
2625
{
26+
parent::configure();
27+
2728
$this
2829
->setName('fos:oauth-server:clean')
2930
->setDescription('Clean expired tokens')
@@ -40,11 +41,11 @@ protected function configure()
4041
*/
4142
protected function execute(InputInterface $input, OutputInterface $output)
4243
{
43-
$services = array(
44+
$services = [
4445
'fos_oauth_server.access_token_manager' => 'Access token',
4546
'fos_oauth_server.refresh_token_manager' => 'Refresh token',
4647
'fos_oauth_server.auth_code_manager' => 'Auth code',
47-
);
48+
];
4849

4950
foreach ($services as $service => $name) {
5051
/** @var $instance TokenManagerInterface */

Command/CreateClientCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
use Symfony\Component\Console\Style\SymfonyStyle;
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
18-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
18+
use FOS\OAuthServerBundle\Model\ClientManagerInterface;
1919

20-
class CreateClientCommand extends ContainerAwareCommand
20+
class CreateClientCommand extends BaseCommand
2121
{
2222
/**
2323
* {@inheritdoc}
2424
*/
2525
protected function configure()
2626
{
27+
parent::configure();
28+
2729
$this
2830
->setName('fos:oauth-server:create-client')
2931
->setDescription('Creates a new client')
@@ -60,6 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6062
$io->title('Client Credentials');
6163

6264
// Get the client manager
65+
/** @var ClientManagerInterface $clientManager */
6366
$clientManager = $this->getContainer()->get('fos_oauth_server.client_manager.default');
6467

6568
// Create a new client

Resources/config/oauth.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
<service id="FOS\OAuthServerBundle\Controller\TokenController">
2727
<argument type="service" id="fos_oauth_server.server" />
2828
</service>
29+
2930
<service id="fos_oauth_server.controller.token" alias="FOS\OAuthServerBundle\Controller\TokenController" public="true" />
31+
32+
<service id="fos_oauth_server.clean_command" class="FOS\OAuthServerBundle\Command\CleanCommand">
33+
<tag name="console.command" />
34+
</service>
35+
36+
<service id="fos_oauth_server.create_client_command" class="FOS\OAuthServerBundle\Command\CreateClientCommand">
37+
<tag name="console.command" />
38+
</service>
3039
</services>
3140
</container>

0 commit comments

Comments
 (0)