bootstrap = ROOT . DS . 'config' . DS . 'bootstrap.php'; if (empty($plugin)) { $this->err('You must provide a plugin name in CamelCase format.'); $this->err('To unload an "Example" plugin, run `cake plugin unload Example`.'); return false; } $write = $this->_modifyBootstrap($plugin); if ($write) { return true; } return false; } /** * Update the applications bootstrap.php file. * * @param string $plugin Name of plugin. * @return bool If modify passed. */ protected function _modifyBootstrap($plugin) { $finder = "/\nPlugin::load\('$plugin'(.|.\n|)+\);\n/"; $bootstrap = new File($this->bootstrap, false); $contents = $bootstrap->read(); if (!preg_match("@\n\s*Plugin::loadAll@", $contents)) { $contents = preg_replace($finder, "", $contents); $bootstrap->write($contents); $this->out(''); $this->out(sprintf('%s modified', $this->bootstrap)); return true; } return false; } /** * GetOptionParser method. * * @return \Cake\Console\ConsoleOptionParser */ public function getOptionParser() { $parser = parent::getOptionParser(); $parser->addArgument('plugin', [ 'help' => 'Name of the plugin to load.', ]); return $parser; } }