Cake\Shell\Task\LoadTask::_modifyBootstrap PHP Method

_modifyBootstrap() protected method

Update the applications bootstrap.php file.
protected _modifyBootstrap ( string $plugin, boolean $hasBootstrap, boolean $hasRoutes, boolean $hasAutoloader ) : boolean
$plugin string Name of plugin.
$hasBootstrap boolean Whether or not bootstrap should be loaded.
$hasRoutes boolean Whether or not routes should be loaded.
$hasAutoloader boolean Whether or not there is an autoloader configured for the plugin.
return boolean If modify passed.
    protected function _modifyBootstrap($plugin, $hasBootstrap, $hasRoutes, $hasAutoloader)
    {
        $bootstrap = new File($this->bootstrap, false);
        $contents = $bootstrap->read();
        if (!preg_match("@\n\\s*Plugin::loadAll@", $contents)) {
            $autoloadString = $hasAutoloader ? "'autoload' => true" : '';
            $bootstrapString = $hasBootstrap ? "'bootstrap' => true" : '';
            $routesString = $hasRoutes ? "'routes' => true" : '';
            $append = "\nPlugin::load('%s', [%s]);\n";
            $options = implode(', ', array_filter([$autoloadString, $bootstrapString, $routesString]));
            $bootstrap->append(str_replace(', []', '', sprintf($append, $plugin, $options)));
            $this->out('');
            $this->out(sprintf('%s modified', $this->bootstrap));
            return true;
        }
        return false;
    }