aboutsummaryrefslogblamecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Command/AbstractNotificationCommand.php
blob: b40b589a1b4af002c60129c1c49c932bbd428300 (plain) (tree)








































                                                                                                            
<?php

namespace Wallabag\CoreBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;

abstract class AbstractNotificationCommand extends ContainerAwareCommand
{
    /** @var OutputInterface */
    protected $output;

    protected function configure()
    {
        $this
            ->addArgument(
                'username',
                InputArgument::OPTIONAL,
                'User to send the notification to'
            )
        ;
    }

    /**
     * Fetches a user from its username.
     *
     * @param string $username
     *
     * @return \Wallabag\UserBundle\Entity\User
     */
    protected function getUser($username)
    {
        return $this->getDoctrine()->getRepository('WallabagUserBundle:User')->findOneByUserName($username);
    }

    protected function getDoctrine()
    {
        return $this->getContainer()->get('doctrine');
    }
}