diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php b/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php new file mode 100644 index 00000000..b40b589a --- /dev/null +++ b/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php | |||
@@ -0,0 +1,41 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
6 | use Symfony\Component\Console\Input\InputArgument; | ||
7 | use Symfony\Component\Console\Output\OutputInterface; | ||
8 | |||
9 | abstract class AbstractNotificationCommand extends ContainerAwareCommand | ||
10 | { | ||
11 | /** @var OutputInterface */ | ||
12 | protected $output; | ||
13 | |||
14 | protected function configure() | ||
15 | { | ||
16 | $this | ||
17 | ->addArgument( | ||
18 | 'username', | ||
19 | InputArgument::OPTIONAL, | ||
20 | 'User to send the notification to' | ||
21 | ) | ||
22 | ; | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * Fetches a user from its username. | ||
27 | * | ||
28 | * @param string $username | ||
29 | * | ||
30 | * @return \Wallabag\UserBundle\Entity\User | ||
31 | */ | ||
32 | protected function getUser($username) | ||
33 | { | ||
34 | return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username); | ||
35 | } | ||
36 | |||
37 | protected function getDoctrine() | ||
38 | { | ||
39 | return $this->getContainer()->get('doctrine'); | ||
40 | } | ||
41 | } | ||