Skip to content

Commit 83076e9

Browse files
committed
Merge pull request #73 from jamesmoey/master
Remove Symfony framework dependency
2 parents d07d906 + 054e622 commit 83076e9

14 files changed

Lines changed: 139 additions & 32 deletions

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
"require": {
2020
"php": ">=5.4.0",
2121
"doctrine/common": "~2.4",
22-
"symfony/framework-bundle": "~2.3",
23-
"symfony/monolog-bundle": "~2.3"
22+
"symfony/dependency-injection": "~2.3, <3.0.0@dev",
23+
"symfony/config": "~2.3, <3.0.0@dev",
24+
"symfony/http-kernel": "~2.3, <3.0.0@dev",
25+
"symfony/console": "~2.3, <3.0.0@dev",
26+
"symfony/monolog-bundle": "~2.3, <3.0.0@dev"
2427
},
2528
"require-dev": {
2629
"phpunit/phpunit": "~3.7",

src/Command/QueueBuildCommand.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,37 @@
2222

2323
namespace Uecode\Bundle\QPushBundle\Command;
2424

25-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
25+
use Symfony\Component\Console\Command\Command;
2626
use Symfony\Component\Console\Input\InputArgument;
2727
use Symfony\Component\Console\Input\InputInterface;
2828
use Symfony\Component\Console\Output\OutputInterface;
29+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
30+
use Symfony\Component\DependencyInjection\ContainerInterface;
2931

3032
/**
3133
* @author Keith Kirk <kkirk@undergroundelephant.com>
3234
*/
33-
class QueueBuildCommand extends ContainerAwareCommand
35+
class QueueBuildCommand extends Command implements ContainerAwareInterface
3436
{
37+
/**
38+
* @var ContainerInterface
39+
*
40+
* @api
41+
*/
42+
protected $container;
43+
44+
/**
45+
* Sets the Container associated with this Controller.
46+
*
47+
* @param ContainerInterface $container A ContainerInterface instance
48+
*
49+
* @api
50+
*/
51+
public function setContainer(ContainerInterface $container = null)
52+
{
53+
$this->container = $container;
54+
}
55+
3556
protected $output;
3657

3758
protected function configure()
@@ -51,7 +72,7 @@ protected function configure()
5172
protected function execute(InputInterface $input, OutputInterface $output)
5273
{
5374
$this->output = $output;
54-
$registry = $this->getContainer()->get('uecode_qpush');
75+
$registry = $this->container->get('uecode_qpush');
5576

5677
$name = $input->getArgument('name');
5778

src/Command/QueueDestroyCommand.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,38 @@
2222

2323
namespace Uecode\Bundle\QPushBundle\Command;
2424

25-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
25+
use Symfony\Component\Console\Command\Command;
2626
use Symfony\Component\Console\Input\InputArgument;
2727
use Symfony\Component\Console\Input\InputInterface;
2828
use Symfony\Component\Console\Input\InputOption;
2929
use Symfony\Component\Console\Output\OutputInterface;
30+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
31+
use Symfony\Component\DependencyInjection\ContainerInterface;
3032

3133
/**
3234
* @author Keith Kirk <kkirk@undergroundelephant.com>
3335
*/
34-
class QueueDestroyCommand extends ContainerAwareCommand
36+
class QueueDestroyCommand extends Command implements ContainerAwareInterface
3537
{
38+
/**
39+
* @var ContainerInterface
40+
*
41+
* @api
42+
*/
43+
protected $container;
44+
45+
/**
46+
* Sets the Container associated with this Controller.
47+
*
48+
* @param ContainerInterface $container A ContainerInterface instance
49+
*
50+
* @api
51+
*/
52+
public function setContainer(ContainerInterface $container = null)
53+
{
54+
$this->container = $container;
55+
}
56+
3657
protected $output;
3758

3859
protected function configure()
@@ -58,7 +79,7 @@ protected function configure()
5879
protected function execute(InputInterface $input, OutputInterface $output)
5980
{
6081
$this->output = $output;
61-
$registry = $this->getContainer()->get('uecode_qpush');
82+
$registry = $this->container->get('uecode_qpush');
6283
$dialog = $this->getHelperSet()->get('dialog');
6384

6485
$name = $input->getArgument('name');

src/Command/QueuePublishCommand.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,37 @@
2222

2323
namespace Uecode\Bundle\QPushBundle\Command;
2424

25-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
25+
use Symfony\Component\Console\Command\Command;
2626
use Symfony\Component\Console\Input\InputArgument;
2727
use Symfony\Component\Console\Input\InputInterface;
2828
use Symfony\Component\Console\Output\OutputInterface;
29+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
30+
use Symfony\Component\DependencyInjection\ContainerInterface;
2931

3032
/**
3133
* @author Keith Kirk <kkirk@undergroundelephant.com>
3234
*/
33-
class QueuePublishCommand extends ContainerAwareCommand
35+
class QueuePublishCommand extends Command implements ContainerAwareInterface
3436
{
37+
/**
38+
* @var ContainerInterface
39+
*
40+
* @api
41+
*/
42+
protected $container;
43+
44+
/**
45+
* Sets the Container associated with this Controller.
46+
*
47+
* @param ContainerInterface $container A ContainerInterface instance
48+
*
49+
* @api
50+
*/
51+
public function setContainer(ContainerInterface $container = null)
52+
{
53+
$this->container = $container;
54+
}
55+
3556
protected $output;
3657

3758
protected function configure()
@@ -55,7 +76,7 @@ protected function configure()
5576
protected function execute(InputInterface $input, OutputInterface $output)
5677
{
5778
$this->output = $output;
58-
$registry = $this->getContainer()->get('uecode_qpush');
79+
$registry = $this->container->get('uecode_qpush');
5980

6081
$name = $input->getArgument('name');
6182
$message = $input->getArgument('message');

src/Command/QueueReceiveCommand.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,39 @@
2222

2323
namespace Uecode\Bundle\QPushBundle\Command;
2424

25-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
25+
use Symfony\Component\Console\Command\Command;
2626
use Symfony\Component\Console\Input\InputArgument;
2727
use Symfony\Component\Console\Input\InputInterface;
2828
use Symfony\Component\Console\Output\OutputInterface;
29+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
30+
use Symfony\Component\DependencyInjection\ContainerInterface;
2931
use Uecode\Bundle\QPushBundle\Event\Events;
3032
use Uecode\Bundle\QPushBundle\Event\MessageEvent;
3133

3234
/**
3335
* @author Keith Kirk <kkirk@undergroundelephant.com>
3436
*/
35-
class QueueReceiveCommand extends ContainerAwareCommand
37+
class QueueReceiveCommand extends Command implements ContainerAwareInterface
3638
{
39+
/**
40+
* @var ContainerInterface
41+
*
42+
* @api
43+
*/
44+
protected $container;
45+
46+
/**
47+
* Sets the Container associated with this Controller.
48+
*
49+
* @param ContainerInterface $container A ContainerInterface instance
50+
*
51+
* @api
52+
*/
53+
public function setContainer(ContainerInterface $container = null)
54+
{
55+
$this->container = $container;
56+
}
57+
3758
protected $output;
3859

3960
protected function configure()
@@ -53,7 +74,7 @@ protected function configure()
5374
protected function execute(InputInterface $input, OutputInterface $output)
5475
{
5576
$this->output = $output;
56-
$registry = $this->getContainer()->get('uecode_qpush');
77+
$registry = $this->container->get('uecode_qpush');
5778

5879
$name = $input->getArgument('name');
5980

src/DependencyInjection/UecodeQPushExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ private function createAwsClient($config, ContainerBuilder $container, $name)
139139
}
140140

141141
$aws = new Definition('Aws\Common\Aws');
142-
$aws->setFactoryClass('Aws\Common\Aws');
143-
$aws->setFactoryMethod('factory');
142+
$aws->setFactory(['Aws\Common\Aws', 'factory']);
144143
$aws->setArguments([
145144
[
146145
'key' => $config['key'],

src/EventListener/RequestListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function onKernelRequest(GetResponseEvent $event)
7979
* Handles Messages sent from a IronMQ Push Queue
8080
*
8181
* @param GetResponseEvent $event The Kernel Request's GetResponseEvent
82+
* @return string|void
8283
*/
8384
private function handleIronMqNotifications(GetResponseEvent $event)
8485
{
@@ -118,6 +119,7 @@ private function handleIronMqNotifications(GetResponseEvent $event)
118119
* Handles Notifications sent from AWS SNS
119120
*
120121
* @param GetResponseEvent $event The Kernel Request's GetResponseEvent
122+
* @return string
121123
*/
122124
private function handleSnsNotifications(GetResponseEvent $event)
123125
{

src/Provider/AbstractProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
use Doctrine\Common\Cache\Cache;
2626
use Symfony\Bridge\Monolog\Logger;
27+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2728
use Uecode\Bundle\QPushBundle\Provider\ProviderInterface;
2829
use Uecode\Bundle\QPushBundle\Event\MessageEvent;
2930
use Uecode\Bundle\QPushBundle\Event\NotificationEvent;
@@ -121,14 +122,18 @@ public function log($level, $message, array $context = [])
121122
}
122123

123124
/**
125+
* @param NotificationEvent $event
126+
* @param string $eventName Name of the event
127+
* @param EventDispatcherInterface $dispatcher
124128
* @return bool
125129
*/
126-
public function onNotification(NotificationEvent $event)
130+
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
127131
{
128132
return false;
129133
}
130134

131135
/**
136+
* @param MessageEvent $event
132137
* @return bool
133138
*/
134139
public function onMessageReceived(MessageEvent $event)

src/Provider/AwsProvider.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
namespace Uecode\Bundle\QPushBundle\Provider;
2424

2525
use Aws\Common\Aws;
26+
use Aws\Sns\SnsClient;
2627
use Aws\Sqs\SqsClient;
2728
use Aws\Sqs\Exception\SqsException;
2829
use Doctrine\Common\Cache\Cache;
2930
use Symfony\Bridge\Monolog\Logger;
31+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
3032
use Uecode\Bundle\QPushBundle\Event\Events;
3133
use Uecode\Bundle\QPushBundle\Event\MessageEvent;
3234
use Uecode\Bundle\QPushBundle\Event\NotificationEvent;
@@ -538,8 +540,11 @@ public function unsubscribeFromTopic($topicArn, $protocol, $endpoint)
538540
* the `{queue}.message_received` event for each message retrieved
539541
*
540542
* @param NotificationEvent $event The Notification Event
543+
* @param string $eventName Name of the event
544+
* @param EventDispatcherInterface $dispatcher
545+
* @return bool|void
541546
*/
542-
public function onNotification(NotificationEvent $event)
547+
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
543548
{
544549
if (NotificationEvent::TYPE_SUBSCRIPTION == $event->getType()) {
545550
$topicArn = $event->getNotification()->getMetadata()->get('TopicArn');
@@ -560,19 +565,20 @@ public function onNotification(NotificationEvent $event)
560565
foreach ($messages as $message) {
561566

562567
$messageEvent = new MessageEvent($this->name, $message);
563-
$event->getDispatcher()->dispatch(Events::Message($this->name), $messageEvent);
568+
$dispatcher->dispatch(Events::Message($this->name), $messageEvent);
564569
}
565570
}
566571

567572
/**
568573
* Removes the message from queue after all other listeners have fired
569574
*
570-
* If an earlier listener has errored or stopped propigation, this method
575+
* If an earlier listener has erred or stopped propagation, this method
571576
* will not fire and the Queued Message should become visible in queue again.
572577
*
573578
* Stops Event Propagation after removing the Message
574579
*
575580
* @param MessageEvent $event The SQS Message Event
581+
* @return bool|void
576582
*/
577583
public function onMessageReceived(MessageEvent $event)
578584
{

src/Provider/IronMqProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use IronMQ;
2626
use Doctrine\Common\Cache\Cache;
2727
use Symfony\Bridge\Monolog\Logger;
28+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2829
use Uecode\Bundle\QPushBundle\Event\Events;
2930
use Uecode\Bundle\QPushBundle\Event\MessageEvent;
3031
use Uecode\Bundle\QPushBundle\Event\NotificationEvent;
@@ -252,8 +253,11 @@ public function queueExists()
252253
* Dispatches the `{queue}.message_received` event
253254
*
254255
* @param NotificationEvent $event The Notification Event
256+
* @param string $eventName Name of the event
257+
* @param EventDispatcherInterface $dispatcher
258+
* @return void
255259
*/
256-
public function onNotification(NotificationEvent $event)
260+
public function onNotification(NotificationEvent $event, $eventName, EventDispatcherInterface $dispatcher)
257261
{
258262
$message = new Message(
259263
$event->getNotification()->getId(),
@@ -269,7 +273,7 @@ public function onNotification(NotificationEvent $event)
269273

270274
$messageEvent = new MessageEvent($this->name, $message);
271275

272-
$event->getDispatcher()->dispatch(
276+
$dispatcher->dispatch(
273277
Events::Message($this->name),
274278
$messageEvent
275279
);
@@ -284,6 +288,7 @@ public function onNotification(NotificationEvent $event)
284288
* Stops Event Propagation after removing the Message
285289
*
286290
* @param MessageEvent $event The SQS Message Event
291+
* @return void
287292
*/
288293
public function onMessageReceived(MessageEvent $event)
289294
{

0 commit comments

Comments
 (0)