startup() public method

Allows for checking and configuring prior to command or main execution Override this method if you want to remove the welcome information, or otherwise modify the pre-command flow.
public startup ( ) : void
return void
Example #1
1
 /**
  * Override startup of the Shell
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     if (isset($this->params['connection'])) {
         $this->connection = $this->params['connection'];
     }
     $class = Configure::read('Acl.classname');
     if (strpos($class, '\\') === false && strpos($class, '.') === false) {
         $className = App::classname('Acl.' . $class, 'Adapter');
     } else {
         $className = App::classname($class, 'Adapter');
     }
     if ($class !== 'DbAcl' && !is_subclass_of($className, 'Acl\\Adapter\\DbAcl')) {
         $out = "--------------------------------------------------\n";
         $out .= __d('cake_acl', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n";
         $out .= __d('cake_acl', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
         $out .= "--------------------------------------------------\n";
         $out .= __d('cake_acl', 'Current ACL Classname: {0}', [$class]) . "\n";
         $out .= "--------------------------------------------------\n";
         $this->err($out);
         $this->_stop();
     }
     if ($this->command) {
         if (Configure::check('Datasource') === null) {
             $this->out(__d('cake_acl', 'Your database configuration was not found. Take a moment to create one.'));
             $this->args = null;
             $this->DbConfig->execute();
             return;
         }
         try {
             TableRegistry::get('Aros')->schema();
             TableRegistry::remove('Aros');
         } catch (\Cake\Database\Exception $e) {
             $this->out(__d('cake_acl', 'Acl database tables not found. To create them, run:'));
             $this->out();
             $this->out('  bin/cake Migrations.migrations migrate -p Acl');
             $this->out();
             $this->_stop();
             return;
         }
         $registry = new ComponentRegistry();
         $this->Acl = new AclComponent($registry);
     }
 }
 /**
  * Create the configuration object used in other classes.
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     $configFinder = new ConfigFinder();
     $this->setConfig($configFinder->loadAll());
     $this->out();
 }
Example #3
0
 /**
  * Shell startup, prints info message about dry run.
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     if (!empty($this->params['dry-run'])) {
         $this->out('<warning>Dry-run mode enabled!</warning>', 1, Shell::QUIET);
     }
 }
Example #4
0
 /**
  * Override startup of the Shell
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     if (isset($this->params['connection'])) {
         $this->connection = $this->params['connection'];
     }
     $class = Configure::read('Acl.classname');
     $className = App::classname('Acl.' . $class, 'Adapter');
     if ($class !== 'DbAcl' && !is_subclass_of($className, 'Acl\\Adapter\\DbAcl')) {
         $out = "--------------------------------------------------\n";
         $out .= __d('cake_acl', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n";
         $out .= __d('cake_acl', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
         $out .= "--------------------------------------------------\n";
         $out .= __d('cake_acl', 'Current ACL Classname: %s', $class) . "\n";
         $out .= "--------------------------------------------------\n";
         $this->err($out);
         return $this->_stop();
     }
     if ($this->command) {
         if (Configure::check('Datasource') === null) {
             $this->out(__d('cake_acl', 'Your database configuration was not found. Take a moment to create one.'));
             $this->args = null;
             return $this->DbConfig->execute();
         }
         if (!in_array($this->command, ['initdb'])) {
             $registry = new ComponentRegistry();
             $this->Acl = new AclComponent($registry);
             $controller = new Controller();
         }
     }
 }
 /**
  * Assign $this->connection to the active task if a connection param is set.
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     Configure::write('debug', true);
     Cache::disable();
     if (isset($this->params['connection'])) {
         $this->connection = $this->params['connection'];
     }
 }
 /**
  * @return void
  */
 public function startup()
 {
     parent::startup();
     $settings = ['debug' => !empty($this->params['debug']) ? $this->params['debug'] : false];
     if (!empty($this->params['project'])) {
         $settings['project'] = $this->params['project'];
     }
     $this->Transifex = new TransifexLib($settings);
 }
 /**
  * Assign $this->connection to the active task if a connection param is set.
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     Cache::disable();
     $this->UserTable = TableRegistry::get($this->param('model'), ['connection' => ConnectionManager::get($this->param('connection'))]);
     if (!$this->UserTable->hasBehavior('Burzum/UserTools.User')) {
         $this->UserTable->addBehavior('Burzum/UserTools.User');
     }
     try {
         $this->UserTable->schema();
     } catch (\Exception $e) {
         $this->err($e->getMessage());
         $this->_stop(1);
     }
 }
Example #8
0
 /**
  * Assign $this->connection to the active task if a connection param is set.
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     Configure::write('debug', true);
     Cache::disable();
     $task = $this->_camelize($this->command);
     if (isset($this->{$task}) && !in_array($task, ['Project'])) {
         if (isset($this->params['connection'])) {
             $this->{$task}->connection = $this->params['connection'];
         }
     }
     if (isset($this->params['connection'])) {
         $this->connection = $this->params['connection'];
     }
 }
 /**
  * @inheritDoc
  */
 public function startup()
 {
     parent::startup();
     $storageTable = 'Burzum/FileStorage.ImageStorage';
     if (isset($this->params['storageTable'])) {
         $storageTable = $this->params['storageTable'];
     }
     $this->Table = TableRegistry::get($storageTable);
     if (isset($this->params['limit'])) {
         if (!is_numeric($this->params['limit'])) {
             $this->out(__d('file_storage', '--limit must be an integer!'));
             $this->_stop();
         }
         $this->limit = $this->params['limit'];
     }
 }
Example #10
0
 /**
  * Start up And load Acl Component / Aco model
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     $this->AclExtras->startup();
     $this->AclExtras->Shell = $this;
     if ($this->command) {
         try {
             \Cake\ORM\TableRegistry::get('Aros')->schema();
         } catch (\Cake\Database\Exception $e) {
             $this->out(__d('cake_acl', 'Acl database tables not found. To create them, run:'));
             $this->out();
             $this->out('  bin/cake Migrations.migrations migrate -p Acl');
             $this->out();
             return $this->_stop();
         }
     }
 }
Example #11
0
 /**
  * Starts up the Shell and displays the welcome message.
  * Allows for checking and configuring prior to command or main execution
  *
  * Override this method if you want to remove the welcome information,
  * or otherwise modify the pre-command flow.
  *
  * @return void
  * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::startup
  */
 public function startup()
 {
     if (!empty($this->params['host'])) {
         $this->_host = $this->params['host'];
     }
     if (!empty($this->params['port'])) {
         $this->_port = $this->params['port'];
     }
     if (!empty($this->params['document_root'])) {
         $this->_documentRoot = $this->params['document_root'];
     }
     // for windows
     if (substr($this->_documentRoot, -1, 1) === DIRECTORY_SEPARATOR) {
         $this->_documentRoot = substr($this->_documentRoot, 0, strlen($this->_documentRoot) - 1);
     }
     if (preg_match("/^([a-z]:)[\\\\]+(.+)\$/i", $this->_documentRoot, $m)) {
         $this->_documentRoot = $m[1] . '\\' . $m[2];
     }
     parent::startup();
 }
Example #12
0
 /**
  * startup
  *
  * @return void
  */
 public function startup()
 {
     if (!$this->param('xml') && !$this->param('version')) {
         parent::startup();
     }
 }
 /**
  * startup
  *
  * @return void
  */
 public function startup()
 {
     if (empty($this->params['xml'])) {
         parent::startup();
     }
 }
 /**
  * Initialize connection.
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     $this->connection = ConnectionManager::get($this->params['connection']);
 }
 /**
  * Starts up the Shell and displays the welcome message.
  * Allows for checking and configuring prior to command or main execution
  *
  * Override this method if you want to remove the welcome information,
  * or otherwise modify the pre-command flow.
  *
  * @return void
  * @link http://book.cakephp.org/3.0/en/console-and-shells.html#hook-methods
  */
 public function startup()
 {
     if (!empty($this->params['host'])) {
         $this->_host = $this->params['host'];
     }
     if (!empty($this->params['port'])) {
         $this->_port = $this->params['port'];
     }
     if (!empty($this->params['document_root'])) {
         $this->_documentRoot = $this->params['document_root'];
     }
     if (!empty($this->params['ini_file'])) {
         $this->_iniFile = ROOT . DS . $this->params['ini_file'];
     }
     // For Windows
     if (substr($this->_documentRoot, -1, 1) === DS) {
         $this->_documentRoot = substr($this->_documentRoot, 0, strlen($this->_documentRoot) - 1);
     }
     if (preg_match("/^([a-z]:)[\\\\]+(.+)\$/i", $this->_documentRoot, $m)) {
         $this->_documentRoot = $m[1] . '\\' . $m[2];
     }
     parent::startup();
 }
 public function startup()
 {
     parent::startup();
     $this->Maintenance = new Maintenance();
 }