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 Kunstmaan\MediaBundle\Command; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Doctrine\ORM\EntityManagerInterface; |
||
7 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
||
8 | use Symfony\Component\Console\Input\InputInterface; |
||
9 | use Symfony\Component\Console\Output\OutputInterface; |
||
10 | |||
11 | /** |
||
12 | * @final since 5.1 |
||
13 | * NEXT_MAJOR extend from `Command` and remove `$this->getContainer` usages |
||
14 | */ |
||
15 | class RebuildFolderTreeCommand extends ContainerAwareCommand |
||
0 ignored issues
–
show
|
|||
16 | { |
||
17 | /** |
||
18 | * @var EntityManager |
||
19 | */ |
||
20 | private $em; |
||
21 | |||
22 | /** |
||
23 | * @param EntityManagerInterface|null $em |
||
24 | */ |
||
25 | public function __construct(/* EntityManagerInterface */ $em = null) |
||
26 | { |
||
27 | parent::__construct(); |
||
28 | |||
29 | if (!$em instanceof EntityManagerInterface) { |
||
30 | @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version symfony 3.4 and will be removed in symfony 4.0. If the command was registered by convention, make it a service instead. ', __METHOD__), E_USER_DEPRECATED); |
||
31 | |||
32 | $this->setName(null === $em ? 'kuma:media:rebuild-folder-tree' : $em); |
||
33 | |||
34 | return; |
||
35 | } |
||
36 | |||
37 | $this->em = $em; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | protected function configure() |
||
44 | { |
||
45 | parent::configure(); |
||
46 | |||
47 | $this->setName('kuma:media:rebuild-folder-tree') |
||
48 | ->setDescription('Rebuild the media folder tree.') |
||
49 | ->setHelp('The <info>kuma:media:rebuild-folder-tree</info> will loop over all media folders and update the media folder tree.'); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | protected function execute(InputInterface $input, OutputInterface $output) |
||
56 | { |
||
57 | if (null === $this->em) { |
||
58 | $this->em = $this->getContainer()->get('doctrine.orm.entity_manager'); |
||
59 | } |
||
60 | |||
61 | $this->em->getRepository('KunstmaanMediaBundle:Folder')->rebuildTree(); |
||
62 | $output->writeln('Updated all folders'); |
||
63 | |||
64 | return 0; |
||
65 | } |
||
66 | } |
||
67 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.