Repository navigation
Expand file tree
/
Copy pathEntitiesCommand.php
More file actions
89 lines (79 loc) · 2.46 KB
/
Copy pathEntitiesCommand.php
File metadata and controls
89 lines (79 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* @file
* Contains \Drupal\Console\Command\Update\EntitiesCommand.
*/
namespace Drupal\Console\Command\Update;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Core\Command\Command;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Utility\Error;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Entity\EntityDefinitionUpdateManager;
use Drupal\Console\Core\Utils\ChainQueue;
/**
* Class EntitiesCommand.
*
* @package Drupal\Console\Command\Update
*/
class EntitiesCommand extends Command
{
/**
* @var StateInterface
*/
protected $state;
/**
* @var EntityDefinitionUpdateManager
*/
protected $entityDefinitionUpdateManager;
/**
* @var ChainQueue
*/
protected $chainQueue;
/**
* EntitiesCommand constructor.
*
* @param StateInterface $state
* @param EntityDefinitionUpdateManager $entityDefinitionUpdateManager
* @param ChainQueue $chainQueue
*/
public function __construct(
StateInterface $state,
EntityDefinitionUpdateManager $entityDefinitionUpdateManager,
ChainQueue $chainQueue
) {
$this->state = $state;
$this->entityDefinitionUpdateManager = $entityDefinitionUpdateManager;
$this->chainQueue = $chainQueue;
parent::__construct();
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('update:entities')
->setDescription($this->trans('commands.update.entities.description'))
->enableMaintenance()
->setAliases(['upe']);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$this->entityDefinitionUpdateManager->applyUpdates();
/* @var EntityStorageException $e */
} catch (EntityStorageException $e) {
/* @var Error $variables */
$variables = Error::decodeException($e);
$this->getIo()->errorLite($this->trans('commands.update.entities.messages.error'));
$this->getIo()->error(strtr('%type: @message in %function (line %line of %file).', $variables));
}
$this->getIo()->info($this->trans('commands.update.entities.messages.end'));
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
}
}