Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
JobStaticRegenerate.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $cache;
17 
21  protected $cleanupFiles;
22 
26  protected $status;
27 
37  public function __construct(
38  \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider,
39  \Symfony\Component\Console\Output\OutputInterface $output,
41  $name,
42  $params = []
43  ) {
44  $this->cleanupFiles = $objectManagerProvider->get()->get(\Magento\Framework\App\State\CleanupFiles::class);
45  $this->cache = $objectManagerProvider->get()->get(\Magento\Framework\App\Cache::class);
46 
47  parent::__construct($output, $status, $objectManagerProvider, $name, $params);
48  }
49 
56  public function execute()
57  {
58  try {
59  $mode = $this->getModeObject();
61  $filesystem = $this->getFilesystem();
62  $filesystem->regenerateStatic($this->getOutputObject());
63  } else {
64  $this->getStatusObject()->add(
65  'Cleaning generated files...',
66  \Psr\Log\LogLevel::INFO
67  );
68  $this->getCleanFilesObject()->clearCodeGeneratedFiles();
69  $this->getStatusObject()->add('Clearing cache...', \Psr\Log\LogLevel::INFO);
70  $this->getCacheObject()->clean();
71  $this->getStatusObject()->add(
72  'Cleaning static view files',
73  \Psr\Log\LogLevel::INFO
74  );
75  $this->getCleanFilesObject()->clearMaterializedViewFiles();
76  }
77  } catch (\Exception $e) {
78  $this->getStatusObject()->toggleUpdateError(true);
79  throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
80  }
81  }
82 
88  public function getCacheObject()
89  {
90  return $this->cache;
91  }
92 
98  public function getCleanFilesObject()
99  {
100  return $this->cleanupFiles;
101  }
102 
108  public function getStatusObject()
109  {
110  return $this->status;
111  }
112 
118  public function getOutputObject()
119  {
120  return $this->output;
121  }
122 
128  public function getFilesystem()
129  {
130  return $this->objectManager->create(\Magento\Deploy\Model\Filesystem::class);
131  }
132 
138  public function getModeObject()
139  {
140  return $this->objectManager->create(
141  \Magento\Deploy\Model\Mode::class,
142  [
143  'input' => new \Symfony\Component\Console\Input\ArrayInput([]),
144  'output' => $this->output,
145  ]
146  );
147  }
148 }
output($string, $level=INFO, $label='')
__construct(\Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider, \Symfony\Component\Console\Output\OutputInterface $output, \Magento\Setup\Model\Cron\Status $status, $name, $params=[])
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
$filesystem