protected function execute(InputInterface $input, OutputInterface $output) { $this->boot($input, $output); switch ($input->getOption('level')) { case 'classloader': $code = sprintf('require_once %s . "/CRM/Core/ClassLoader.php";', var_export(rtrim($GLOBALS["civicrm_root"], '/'), 1)) . '\\CRM_Core_ClassLoader::singleton()->register();'; break; case 'settings': $code = \Civi\Cv\Bootstrap::singleton()->generate() . '\\CRM_Core_Config::singleton(FALSE);'; break; case 'full': $code = \Civi\Cv\Bootstrap::singleton()->generate() . '\\CRM_Core_Config::singleton();' . '\\CRM_Utils_System::loadBootStrap(array(), FALSE);'; break; default: break; } $output->writeln('/*BEGINPHP*/'); $output->writeln($code); $output->writeln('/*ENDPHP*/'); }
protected function boot(InputInterface $input, OutputInterface $output) { if ($input->hasOption('test') && $input->getOption('test')) { putenv('CIVICRM_UF=UnitTests'); $_ENV['CIVICRM_UF'] = 'UnitTests'; } if ($input->hasOption('level') && $input->getOption('level') !== 'full') { \Civi\Cv\Bootstrap::singleton()->boot(array('prefetch' => FALSE)); } else { \Civi\Cv\Bootstrap::singleton()->boot(); \CRM_Core_Config::singleton(); \CRM_Utils_System::loadBootStrap(array(), FALSE); if ($input->getOption('user')) { if (is_callable(array(\CRM_Core_Config::singleton()->userSystem, 'loadUser'))) { \CRM_Utils_System::loadUser($input->getOption('user')); } else { $output->writeln("<error>Failed to set user. Feature not supported by UF (" . CIVICRM_UF . ")</error>"); } } } }