Completed
Pull Request — master (#4)
by dan
14:39
created

Maker/DatabaseNotificationMaker.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace IrishDan\NotificationBundle\Maker;
4
5
use Symfony\Bundle\MakerBundle\ConsoleStyle;
6
use Symfony\Bundle\MakerBundle\DependencyBuilder;
7
use Symfony\Bundle\MakerBundle\Generator;
8
use Symfony\Bundle\MakerBundle\InputConfiguration;
9
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
10
use Symfony\Bundle\MakerBundle\MakerInterface;
11
use Symfony\Component\Console\Command\Command;
12
use Symfony\Component\Console\Input\InputArgument;
13
use Symfony\Component\Console\Input\InputInterface;
14
15
class DatabaseNotificationMaker extends AbstractMaker
16
{
17
    private $channels;
18
    private $channelTemplates = [];
19
20
    public function setEnabledChannels(array $channels)
21
    {
22
        $this->channels = $channels;
23
    }
24
25
    public static function getCommandName(): string
26
    {
27
        return 'make:database-notification';
28
    }
29
30
31
    public function configureCommand(Command $command, InputConfiguration $inputConf)
32
    {
33
        $command
34
            ->setDescription('Creates a new doctrine entity class for use as a database notification')
35
            // ->addArgument('name', InputArgument::OPTIONAL, 'The name of the notification class (e.g. <fg=yellow>NewUserNotification</>)')
36
            ->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeDatabaseNotification.txt'))
37
        ;
38
    }
39
40 View Code Duplication
    public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $voterClassNameDetails = $generator->createClassNameDetails(
43
            'Notification',
44
            'Entity\\',
45
            'Entity'
46
        );
47
48
        $generator->generateClass(
49
            $voterClassNameDetails->getFullName(),
50
            __DIR__.'/../Resources/skeleton/notification/DatabaseNotification.tpl.php',
51
            []
52
        );
53
54
        $generator->writeChanges();
55
56
        $this->writeSuccessMessage($io);
57
58
        $io->text([
59
            'Next: Open your notification and add your logic.'
60
        ]);
61
    }
62
63
    public function configureDependencies(DependencyBuilder $dependencies)
64
    {
65
        // $dependencies->addClassDependency(
66
        //     Voter::class,
67
        //     'security'
68
        // );
69
    }
70
}