示例#1
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $Folder = new Folder($this->Task->path . 'BakeTestApp');
     $Folder->delete();
     unset($this->Task);
 }
示例#2
0
 /**
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $dir = new Folder(TMP . 'lock');
     $dir->delete();
     unset($this->Lock);
 }
 public function tearDown()
 {
     parent::tearDown();
     $testPluginFolder = new Folder(ROOT . DS . 'plugins' . DS . 'PluginInstallerTest');
     $testPluginFolder->delete();
     $testPluginConfigFolder = new Folder(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'PluginInstallerTest');
     $testPluginConfigFolder->delete();
 }
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Model);
     TableRegistry::clear();
     $folder = new Folder(WWW_ROOT . 'upload');
     $folder->delete(WWW_ROOT . 'upload');
 }
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Task);
     $Folder = new Folder($this->path);
     $Folder->delete();
     Plugin::unload();
 }
示例#6
0
 private function removeAndCreateFolder($path)
 {
     $dir = new Folder($path);
     $dir->delete();
     $dir->create($path);
     $file = new File($path . DS . 'empty');
     $file->create();
 }
示例#7
0
 /**
  * Test exist theme plugin.
  *
  * @return void
  */
 public function testExistTheme()
 {
     $name = Configure::read('Theme.site');
     $path = $this->_paths[1] . $name;
     $this->_folder->create($path);
     $this->assertSame($path, Theme::exist($name));
     $this->_folder->delete($path);
 }
 private function createFileAndDeleteTmp($identifier, $filename)
 {
     $tmpFolder = new Folder($this->tmpChunkDir($identifier));
     $chunkFiles = $tmpFolder->read(true, true, true)[1];
     if ($this->createFileFromChunks($chunkFiles, $this->uploadFolder . DIRECTORY_SEPARATOR . $filename) && $this->deleteTmpFolder) {
         $tmpFolder->delete();
     }
 }
示例#9
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $this->File->close();
     unset($this->File);
     $Folder = new Folder();
     $Folder->delete(TMP . 'tests/permissions');
 }
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('ThemeInstallerTest');
     $testPluginFolder = new Folder(ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest');
     $testPluginFolder->delete();
     $testPluginConfigFolder = new Folder(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'ThemeInstallerTest');
     $testPluginConfigFolder->delete();
     $webrootThemeFolder = new Folder(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest');
     $webrootThemeFolder->delete();
 }
示例#11
0
 /**
  * testAddTestDirectoryRecursiveWithNonPhp
  *
  * @return void
  */
 public function testAddTestDirectoryRecursiveWithNonPhp()
 {
     $this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
     $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
     touch($Folder->path . DS . 'BackupTest.php~');
     touch($Folder->path . DS . 'SomeNotesTest.txt');
     touch($Folder->path . DS . 'NotHiddenTest.php');
     $suite = $this->getMock('Cake\\TestSuite\\TestSuite', ['addTestFile']);
     $suite->expects($this->exactly(1))->method('addTestFile');
     $suite->addTestDirectoryRecursive($Folder->pwd());
     $Folder->delete();
 }
示例#12
0
 /**
  * Delete folder action.
  *
  * @return \Cake\Network\Response|void
  */
 public function deleteFolder()
 {
     $path = $this->request->query('path');
     if ($this->request->is('post') && is_dir($path)) {
         $Folder = new Folder($path);
         if ($Folder->delete()) {
             $this->Flash->success(__d('file_manager', 'Folder successfully removed'));
         } else {
             $this->Flash->success(__d('file_manager', 'An error occurred while removing a folder'));
         }
     }
     return $this->redirect(['action' => 'browse']);
 }
 /**
  * afterDelete
  *
  * No need to use an adapter here, just delete the whole folder using cakes Folder class
  *
  * @param Event $event
  * @return boolean|null
  */
 public function afterDelete(Event $event)
 {
     if ($this->_checkEvent($event)) {
         $entity = $event->data['record'];
         $storageConfig = StorageManager::config($entity['adapter']);
         $path = $storageConfig['adapterOptions'][0] . $event->data['record']['path'];
         if (is_dir($path)) {
             $Folder = new Folder($path);
             $Folder->delete();
             $event->stopPropagation();
             $event->result = true;
             return true;
         }
         $event->stopPropagation();
         $event->result = false;
         return false;
     }
 }
示例#14
0
 public function handleChunk()
 {
     $file = $this->request->file();
     $identifier = $this->_resumableParam('identifier');
     $filename = $this->_resumableParam('filename');
     $chunkNumber = $this->_resumableParam('chunkNumber');
     $chunkSize = $this->_resumableParam('chunkSize');
     $totalSize = $this->_resumableParam('totalSize');
     if (!$this->isChunkUploaded($identifier, $filename, $chunkNumber)) {
         $chunkFile = $this->tmpChunkDir($identifier) . DIRECTORY_SEPARATOR . $this->tmpChunkFilename($filename, $chunkNumber);
         $this->moveUploadedFile($file['tmp_name'], $chunkFile);
     }
     if ($this->isFileUploadComplete($filename, $identifier, $chunkSize, $totalSize)) {
         $tmpFolder = new Folder($this->tmpChunkDir($identifier));
         $chunkFiles = $tmpFolder->read(true, true, true)[1];
         $this->createFileFromChunks($chunkFiles, $this->uploadFolder . DIRECTORY_SEPARATOR . $filename);
         if ($this->deleteTmpFolder) {
             $tmpFolder->delete();
         }
     }
     return $this->response->header(200);
 }
 /**
  * main method
  *
  * @param  string $tempDir an other directory to clear of all folders and files, if desired
  * @return void
  */
 public function main($tempDir = null)
 {
     if (empty($tempDir)) {
         $tempDir = Configure::read('Attachments.tmpUploadsPath');
     }
     if (!Folder::isAbsolute($tempDir)) {
         $this->out('The path must be absolute, "' . $tempDir . '" given.');
         exit;
     }
     $Folder = new Folder();
     if ($Folder->cd($tempDir) === false) {
         $this->out('Path "' . $tempDir . '" doesn\'t seem to exist.');
         exit;
     }
     $dir = new Folder($tempDir);
     $folders = $dir->read();
     $files = $dir->findRecursive();
     $deletedFiles = 0;
     $deletedFolders = 0;
     $this->out('Found ' . count($folders[0]) . ' folders and ' . count($files) . ' files');
     foreach ($files as $filePath) {
         $file = new File($filePath);
         // only delete if last change is longer than 24 hours ago
         if ($file->lastChange() < time() - 24 * 60 * 60 && $file->delete()) {
             $deletedFiles++;
         }
         $file->close();
     }
     foreach ($folders[0] as $folderName) {
         $folder = new Folder($dir->pwd() . $folderName);
         // only delete if folder is empty
         if ($folder->dirsize() === 0 && $folder->delete()) {
             $deletedFolders++;
         }
     }
     $this->out('Deleted ' . $deletedFolders . ' folders and ' . $deletedFiles . ' files.');
 }
示例#16
0
 /**
  * Reload DebugKit plugin.
  *
  * @param string $vendorDir
  */
 protected static function _reloadDebugKitPlugin($vendorDir)
 {
     $webRoot = $vendorDir . '/cakephp/debug_kit/webroot';
     $assetsDir = $vendorDir . '/cakephp/debug_kit/assets';
     if (is_dir($webRoot)) {
         //  Transport js styles.
         $debugWebroot = new Folder($webRoot);
         $debugWebroot->copy($assetsDir);
         $debugWebroot->delete($webRoot);
     }
     //  Rewrite include scripts.
     $debugFilterFile = $vendorDir . '/cakephp/debug_kit/src/Routing/Filter/DebugBarFilter.php';
     if (file_exists($debugFilterFile)) {
         $debugFilter = new File($debugFilterFile);
         $debugFilter->replaceText("Router::url('/debug_kit/js/toolbar.js')", "vPath()->url('DebugKit:assets/js/toolbar.js')");
     }
     //  Reload default DebugKit AjaxView.
     $debugViewFile = $vendorDir . '/cakephp/debug_kit/src/View/AjaxView.php';
     if (file_exists($debugViewFile)) {
         $debugView = new File($debugViewFile);
         $debugView->replaceText('use Cake\\View\\View;', '');
         $debugView->replaceText('extends View', 'extends \\Union\\App\\View\\AjaxView');
     }
 }
 public function updateDB()
 {
     $folderCache = new Folder(CACHE . '/models');
     $folderCache->delete();
     $stConfig = Configure::read('Core.Settings');
     $dataSetting = $this->Settings->find()->first();
     $queryAdd = "ALTER TABLE settings ";
     $count = 0;
     foreach ($stConfig as $field => $value) {
         $count++;
         $last = count($stConfig) > $count ? ', ' : '';
         $queryAdd .= "ADD " . $field . " TEXT NULL DEFAULT NULL" . $last;
     }
     $conn = ConnectionManager::get('default');
     $queryDrop = "DROP TABLE settings";
     $queryCreate = "CREATE TABLE settings (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY)";
     $conn->query($queryDrop);
     $conn->query($queryCreate);
     $conn->query($queryAdd);
     if ($dataSetting) {
         $dataSetting->isNew(true);
         $this->Settings->save($dataSetting);
     }
 }
示例#18
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->io = $this->getMock('Cake\\Console\\ConsoleIo', [], [], '', false);
     $this->Shell = new ShellTestShell($this->io);
     if (is_dir(TMP . 'shell_test')) {
         $Folder = new Folder(TMP . 'shell_test');
         $Folder->delete();
     }
 }
 /**
  * Export entire database to PHP fixtures.
  *
  * By default, all generated PHP files will be placed in `/tmp/fixture/`
  * directory, this can be changed using the `--destination` argument.
  *
  * @return bool
  */
 public function main()
 {
     $options = (array) $this->params;
     $destination = normalizePath("{$options['destination']}/");
     if (is_string($options['tables'])) {
         $options['tables'] = explode(',', $options['tables']);
     }
     if (is_string($options['no-data'])) {
         $options['no-data'] = explode(',', $options['no-data']);
     }
     if (file_exists($destination)) {
         $dst = new Folder($destination);
         $dst->delete();
         $this->out(__d('system', 'Removing existing directory: {0}', $destination), 1, Shell::VERBOSE);
     } else {
         new Folder($destination, true);
         $this->out(__d('system', 'Creating directory: {0}', $destination), 1, Shell::VERBOSE);
     }
     $db = ConnectionManager::get('default');
     $db->connect();
     $schemaCollection = $db->schemaCollection();
     $tables = $schemaCollection->listTables();
     foreach ($tables as $table) {
         if (!empty($options['tables']) && !in_array($table, $options['tables'])) {
             $this->out(__d('system', 'Table "{0}" skipped', $table), 1, Shell::VERBOSE);
             continue;
         }
         $Table = TableRegistry::get($table);
         $Table->behaviors()->reset();
         $fields = ['_constraints' => [], '_indexes' => [], '_options' => (array) $Table->schema()->options()];
         $columns = $Table->schema()->columns();
         $records = [];
         $primaryKeys = [];
         foreach ($Table->schema()->indexes() as $indexName) {
             $index = $Table->schema()->index($indexName);
             if (!empty($index['columns'])) {
                 $fields['_indexes']["{$table}_{$indexName}_index"] = $index;
             }
         }
         foreach ($columns as $column) {
             $fields[$column] = $Table->schema()->column($column);
         }
         foreach ($Table->schema()->constraints() as $constraint) {
             $constraintName = in_array($constraint, $columns) ? Inflector::underscore("{$table}_{$constraint}") : $constraint;
             $fields['_constraints'][$constraintName] = $Table->schema()->constraint($constraint);
             if (isset($fields['_constraints']['primary']['columns'])) {
                 $primaryKeys = $fields['_constraints']['primary']['columns'];
             }
         }
         foreach ($fields as $column => $info) {
             if (isset($info['length']) && in_array($column, $primaryKeys) && isset($info['autoIncrement']) && $info['autoIncrement'] === true) {
                 unset($fields[$column]['length']);
             }
         }
         // FIX: We need RAW data for time instead of Time Objects
         $originalTypes = [];
         foreach ($Table->schema()->columns() as $column) {
             $type = $Table->schema()->columnType($column);
             $originalTypes[$column] = $type;
             if (in_array($type, ['date', 'datetime', 'time'])) {
                 $Table->schema()->columnType($column, 'string');
             }
         }
         if ($options['mode'] === 'full') {
             foreach ($Table->find('all') as $row) {
                 $row = $row->toArray();
                 if ($this->params['no-id'] && isset($row['id'])) {
                     unset($row['id']);
                 }
                 $records[] = $row;
             }
         }
         $className = Inflector::camelize($table) . 'Fixture';
         if ($options['fixture'] && in_array($className, ['AcosFixture', 'UsersFixture'])) {
             $records = [];
         }
         // undo changes made by "FIX"
         foreach ($originalTypes as $column => $type) {
             $fields[$column]['type'] = $type;
         }
         if (empty($fields['_indexes'])) {
             unset($fields['_indexes']);
         }
         $fields = $this->_arrayToString($fields);
         $records = in_array($table, $options['no-data']) ? '[]' : $this->_arrayToString($records);
         $fixture = $this->_classFileHeader($className);
         $fixture .= "{\n";
         $fixture .= "\n";
         $fixture .= "    /**\n";
         $fixture .= "     * Table name.\n";
         $fixture .= "     *\n";
         $fixture .= "     * @var string\n";
         $fixture .= "     */\n";
         $fixture .= "    public \$table = '{$table}';\n";
         $fixture .= "\n";
         $fixture .= "    /**\n";
         $fixture .= "     * Table columns.\n";
         $fixture .= "     *\n";
         $fixture .= "     * @var array\n";
         $fixture .= "     */\n";
         $fixture .= "    public \$fields = {$fields};\n";
         $fixture .= "\n";
         $fixture .= "    /**\n";
         $fixture .= "     * Table records.\n";
         $fixture .= "     *\n";
         $fixture .= "     * @var array\n";
         $fixture .= "     */\n";
         $fixture .= "    public \$records = {$records};\n";
         $fixture .= "}\n";
         $file = new File(normalizePath("{$destination}/{$className}.php"), true);
         $file->write($fixture, 'w', true);
         $this->out(__d('system', 'Table "{0}" exported!', $table), 1, Shell::VERBOSE);
     }
     $this->out(__d('system', 'Database exported to: {0}', $destination));
     return true;
 }
 /**
  * TearDown
  *
  * @return void
  */
 public function tearDown()
 {
     // Cleanup temporary Api directory
     $apiFolder = new Folder($this->apiFolderPath);
     $apiFolder->delete();
 }
示例#21
0
 /**
  * testCopy
  *
  * @return void
  */
 public function testCopy()
 {
     Plugin::load('TestPlugin');
     Plugin::load('Company/TestPluginThree');
     $this->Task->copy();
     $path = WWW_ROOT . 'test_plugin';
     $dir = new \SplFileInfo($path);
     $this->assertTrue($dir->isDir());
     $this->assertTrue(file_exists($path . DS . 'root.js'));
     $folder = new Folder($path);
     $folder->delete();
     $path = WWW_ROOT . 'company' . DS . 'test_plugin_three';
     $link = new \SplFileInfo($path);
     $this->assertTrue($link->isDir());
     $this->assertTrue(file_exists($path . DS . 'css' . DS . 'company.css'));
     $folder = new Folder(WWW_ROOT . 'company');
     $folder->delete();
 }
示例#22
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $folder = new Folder(TEST_WWW_ROOT . 'upload');
     $folder->delete(TEST_WWW_ROOT . 'upload');
 }
示例#23
0
 /**
  * Upload user profile image.
  *
  * @param User $user
  */
 protected function _uploadAvatar(User $user)
 {
     if (isset($this->_tmpImage) && file_exists($this->_tmpImage['tmp_name'])) {
         $imageInfo = pathinfo($this->_tmpImage['name']);
         $imageName = 'orig_' . $user->get('id') . '.' . $imageInfo['extension'];
         $folderPath = $this->_path->entityFolderPath($user->get('id'), DS);
         $imagePath = $folderPath . $imageName;
         $Folder = new Folder();
         //  Delete user folder if upload new image.
         if (is_dir($folderPath)) {
             $Folder->delete($folderPath);
         }
         if (!is_dir($folderPath)) {
             $Folder->create($folderPath);
         }
         if (is_dir($folderPath) && move_uploaded_file($this->_tmpImage['tmp_name'], $imagePath)) {
             $user->set('image', $imageName);
             $thumbName = 'thumb_' . $user->get('id') . '.' . $imageInfo['extension'];
             //  Resize original image.
             $Resize = new ImageThumbnail($imagePath);
             $Resize->sizeWidth(450);
             $Resize->save($imagePath);
             //  Resize and crop thumb.
             $Thumbnail = new ImageThumbnail($imagePath);
             $Thumbnail->setResize(false);
             $Thumbnail->setSize($this->_config['thumbWidth'], $this->_config['thumbHeight']);
             $Thumbnail->save($folderPath . $thumbName);
         }
     }
 }
示例#24
0
 /**
  * @return void
  */
 protected function _clearCache()
 {
     $path = vPath()->get('cache:');
     $folder = new Folder($path);
     $folder->delete();
 }
示例#25
0
 /**
  * test item() with enclosure data.
  *
  * @return void
  */
 public function testItemEnclosureLength()
 {
     if (!is_writable(WWW_ROOT)) {
         $this->markTestSkipped('Webroot is not writable.');
     }
     $testExists = is_dir(WWW_ROOT . 'tests');
     $tmpFile = WWW_ROOT . 'tests/cakephp.file.test.tmp';
     $File = new File($tmpFile, true);
     $this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile);
     clearstatcache();
     $item = ['title' => ['value' => 'My Title', 'cdata' => true], 'link' => 'http://www.example.com/1', 'description' => ['value' => 'descriptive words', 'cdata' => true], 'enclosure' => ['url' => '/tests/cakephp.file.test.tmp'], 'pubDate' => '2008-05-31 12:00:00', 'guid' => 'http://www.example.com/1', 'category' => [['value' => 'CakePHP', 'cdata' => true, 'domain' => 'http://www.cakephp.org'], ['value' => 'Bakery', 'cdata' => true]]];
     $result = $this->Rss->item(null, $item);
     if (!function_exists('mime_content_type')) {
         $type = null;
     } else {
         $type = mime_content_type($tmpFile);
     }
     $expected = ['<item', '<title', '<![CDATA[My Title]]', '/title', '<link', 'http://www.example.com/1', '/link', '<description', '<![CDATA[descriptive words]]', '/description', 'enclosure' => ['url' => $this->Rss->Url->build('/tests/cakephp.file.test.tmp', true), 'length' => filesize($tmpFile), 'type' => $type], '<pubDate', date('r', strtotime('2008-05-31 12:00:00')), '/pubDate', '<guid', 'http://www.example.com/1', '/guid', 'category' => ['domain' => 'http://www.cakephp.org'], '<![CDATA[CakePHP]]', '/category', '<category', '<![CDATA[Bakery]]', '/category', '/item'];
     if ($type === null) {
         unset($expected['enclosure']['type']);
     }
     $this->assertHtml($expected, $result);
     $File->delete();
     if (!$testExists) {
         $Folder = new Folder(WWW_ROOT . 'tests');
         $Folder->delete();
     }
 }
 /**
  * Clears any previous installation.
  *
  * @return void
  */
 protected function _clear()
 {
     $folder = new Folder(ROOT . '/plugins/NukedApp/');
     $folder->delete();
     snapshot();
 }
示例#27
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->io = $this->getMockBuilder('Cake\\Console\\ConsoleIo')->disableOriginalConstructor()->getMock();
     $this->Shell = new ShellTestShell($this->io);
     if (is_dir(TMP . 'shell_test')) {
         $Folder = new Folder(TMP . 'shell_test');
         $Folder->delete();
     }
 }
示例#28
0
 /**
  * Test that baking a plugin for a project that contains a composer.json, the later
  * will be updated
  *
  * @return void
  */
 public function testMainUpdateComposer()
 {
     $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
     $this->io->expects($this->any())->method('askChoice')->will($this->returnValue('y'));
     $this->Task->expects($this->any())->method('findComposer')->will($this->returnValue('composer.phar'));
     $file = TMP . 'tests' . DS . 'main-composer.json';
     file_put_contents($file, '{}');
     $savePath = $this->Task->path;
     $this->Task->path = ROOT . DS . 'tests' . DS . 'BakedPlugins/';
     $this->Task->expects($this->any())->method('_rootComposerFilePath')->will($this->returnValue($file));
     $this->Task->expects($this->once())->method('callProcess')->with('php ' . escapeshellarg('composer.phar') . ' dump-autoload');
     $this->Task->main('ComposerExample');
     $result = file_get_contents($file);
     $this->assertSameAsFile(__FUNCTION__ . '.json', $result);
     $folder = new Folder($this->Task->path);
     $folder->delete();
     $this->Task->path = $savePath;
 }
 /**
  * Extracts the current ZIP package.
  *
  * @param  string $file Full path to the ZIP package
  * @return bool True on success
  */
 protected function _unzip($file)
 {
     include_once Plugin::classPath('Installer') . 'Lib/pclzip.lib.php';
     $File = new File($file);
     $to = normalizePath($File->folder()->pwd() . '/' . $File->name() . '_unzip/');
     if (is_readable($to)) {
         $folder = new Folder($to);
         $folder->delete();
     } else {
         $folder = new Folder($to, true);
     }
     $PclZip = new \PclZip($file);
     $PclZip->delete(PCLZIP_OPT_BY_EREG, '/__MACOSX/');
     $PclZip->delete(PCLZIP_OPT_BY_EREG, '/\\.DS_Store$/');
     if ($PclZip->extract(PCLZIP_OPT_PATH, $to)) {
         list($directories, $files) = $folder->read(false, false, true);
         if (count($directories) === 1 && empty($files)) {
             $container = new Folder($directories[0]);
             $container->move(['to' => $to]);
         }
         $this->_workingDir = $to;
         return true;
     }
     $this->err(__d('installer', 'Unzip error: {0}', [$PclZip->errorInfo(true)]));
     return false;
 }
 /**
  * Runs uninstallation logic inside a safe transactional thread. This prevent
  * DB inconsistencies on uninstall failure.
  *
  * @return bool True on success, false otherwise
  */
 protected function _runTransactional()
 {
     // to avoid any possible issue
     snapshot();
     if (!is_writable(TMP)) {
         $this->err(__d('installer', 'Enable write permissions in /tmp directory before uninstall any plugin or theme.'));
         return false;
     }
     if (!$this->params['plugin']) {
         $this->err(__d('installer', 'No plugin/theme was given to remove.'));
         return false;
     }
     $this->loadModel('System.Plugins');
     try {
         $plugin = plugin($this->params['plugin']);
         $pluginEntity = $this->Plugins->find()->where(['name' => $this->params['plugin']])->limit(1)->first();
     } catch (\Exception $ex) {
         $plugin = $pluginEntity = false;
     }
     if (!$plugin || !$pluginEntity) {
         $this->err(__d('installer', 'Plugin "{0}" was not found.', $this->params['plugin']));
         return false;
     }
     $this->_plugin = $plugin;
     $type = $plugin->isTheme ? 'theme' : 'plugin';
     if ($plugin->isTheme && in_array($plugin->name, [option('front_theme'), option('back_theme')])) {
         $this->err(__d('installer', '{0} "{1}" is currently being used and cannot be removed.', $type == 'plugin' ? __d('installer', 'The plugin') : __d('installer', 'The theme'), $plugin->humanName));
         return false;
     }
     $requiredBy = Plugin::checkReverseDependency($this->params['plugin']);
     if (!empty($requiredBy)) {
         $names = [];
         foreach ($requiredBy as $p) {
             $names[] = $p->name();
         }
         $this->err(__d('installer', '{0} "{1}" cannot be removed as it is required by: {2}', $type == 'plugin' ? __d('installer', 'The plugin') : __d('installer', 'The theme'), $plugin->humanName, implode(', ', $names)));
         return false;
     }
     if (!$this->_canBeDeleted($plugin->path)) {
         return false;
     }
     if (!$this->params['no-callbacks']) {
         try {
             $event = $this->trigger("Plugin.{$plugin->name}.beforeUninstall");
             if ($event->isStopped() || $event->result === false) {
                 $this->err(__d('installer', 'Task was explicitly rejected by {0}.', $type == 'plugin' ? __d('installer', 'the plugin') : __d('installer', 'the theme')));
                 return false;
             }
         } catch (\Exception $e) {
             $this->err(__d('installer', 'Internal error, {0} did not respond to "beforeUninstall" callback correctly.', $type == 'plugin' ? __d('installer', 'the plugin') : __d('installer', 'the theme')));
             return false;
         }
     }
     if (!$this->Plugins->delete($pluginEntity)) {
         $this->err(__d('installer', '{0} "{1}" could not be unregistered from DB.', $type == 'plugin' ? __d('installer', 'The plugin') : __d('installer', 'The theme'), $plugin->humanName));
         return false;
     }
     $this->_removeOptions();
     $this->_clearAcoPaths();
     $folder = new Folder($plugin->path);
     $folder->delete();
     snapshot();
     if (!$this->params['no-callbacks']) {
         try {
             $this->trigger("Plugin.{$plugin->name}.afterUninstall");
         } catch (\Exception $e) {
             $this->err(__d('installer', '{0} did not respond to "afterUninstall" callback.', $type == 'plugin' ? __d('installer', 'The plugin') : __d('installer', 'The theme')));
         }
     }
     Plugin::unload($plugin->name);
     Plugin::dropCache();
     return true;
 }