Esempio n. 1
0
 /**
  * Do the cleanup
  *
  * @return void
  */
 protected function performCleanup()
 {
     $this->status->add('Cleaning generated files...', \Psr\Log\LogLevel::INFO);
     $this->cleanupFiles->clearCodeGeneratedFiles();
     $this->status->add('Complete!', \Psr\Log\LogLevel::INFO);
     $this->status->add('Clearing cache...', \Psr\Log\LogLevel::INFO);
     $this->cache->clean();
     $this->status->add('Complete!', \Psr\Log\LogLevel::INFO);
 }
    /**
     * Clear var/generation and reset object manager
     *
     * @return void
     */
    private function cleanupGeneratedFiles()
    {
        $this->log->log('File system cleanup:');
        $messages = $this->cleanupFiles->clearCodeGeneratedFiles();

        // unload Magento autoloader because it may be using compiled definition
        foreach (spl_autoload_functions() as $autoloader) {
            if ($autoloader[0] instanceof \Magento\Framework\Code\Generator\Autoloader) {
                spl_autoload_unregister([$autoloader[0], $autoloader[1]]);
                break;
            }
        }

        // Corrected Magento autoloader will be loaded upon next get() call on $this->objectManagerProvider
        $this->objectManagerProvider->reset();

        foreach ($messages as $message) {
            $this->log->log($message);
        }
    }