Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractJob.php
Go to the documentation of this file.
1 <?php
7 
8 use Symfony\Component\Console\Output\OutputInterface;
11 
15 abstract class AbstractJob
16 {
20  protected $command;
21 
25  protected $output;
26 
30  protected $name;
31 
35  protected $params;
36 
40  protected $cache;
41 
45  protected $cleanupFiles;
46 
50  protected $status;
51 
55  protected $objectManager;
56 
66  public function __construct(
67  \Symfony\Component\Console\Output\OutputInterface $output,
69  \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider,
70  $name,
71  array $params = []
72  ) {
73  $this->output = $output;
74  $this->status = $status;
75  $this->name = $name;
76  $this->params = $params;
77 
78  $this->objectManager = $objectManagerProvider->get();
79  $this->cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class);
80  $this->cache = $this->objectManager->get(\Magento\Framework\App\Cache::class);
81  }
82 
88  public function getName()
89  {
90  return $this->name;
91  }
92 
98  public function __toString()
99  {
100  return $this->name . ' ' . json_encode($this->params, JSON_UNESCAPED_SLASHES);
101  }
102 
108  protected function performCleanup()
109  {
110  $this->status->add('Cleaning generated files...', \Psr\Log\LogLevel::INFO);
111  $this->cleanupFiles->clearCodeGeneratedFiles();
112  $this->status->add('Complete!', \Psr\Log\LogLevel::INFO);
113  $this->status->add('Clearing cache...', \Psr\Log\LogLevel::INFO);
114  $this->cache->clean();
115  $this->status->add('Complete!', \Psr\Log\LogLevel::INFO);
116  }
117 
123  abstract public function execute();
124 }
output($string, $level=INFO, $label='')
__construct(\Symfony\Component\Console\Output\OutputInterface $output, \Magento\Setup\Model\Cron\Status $status, \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider, $name, array $params=[])
Definition: AbstractJob.php:66