Skip to content

Commit

Permalink
CRM_CivixBundle_Command - Enable verbose output during bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Jan 2, 2017
1 parent cebbb7a commit 78f5db8
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/AddApiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected function configure() {

protected function execute(InputInterface $input, OutputInterface $output) {
// load Civi to get access to civicrm_api_get_function_name
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if (!$civicrm_api3 || !$civicrm_api3->local) {
$output->writeln("<error>--copy requires access to local CiviCRM source tree. Configure civicrm_api3_conf_path.</error>");
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/AddCaseTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected function configure() {

protected function execute(InputInterface $input, OutputInterface $output) {
// load Civi to get access to civicrm_api_get_function_name
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if (!$civicrm_api3 || !$civicrm_api3->local) {
$output->writeln("Requires access to local CiviCRM source tree. Configure civicrm_api3_conf_path.</error>");
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/AddCustomDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protected function configure() {

protected function execute(InputInterface $input, OutputInterface $output) {
// load Civi to get access to civicrm_api_get_function_name
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if (!$civicrm_api3 || !$civicrm_api3->local) {
$output->writeln("<error>generate:custom-xml requires access to local CiviCRM instance. Configure civicrm_api3_conf_path.</error>");
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/AddEntityCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected function configure() {

protected function execute(InputInterface $input, OutputInterface $output) {
// load Civi to get access to civicrm_api_get_function_name
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if (!$civicrm_api3 || !$civicrm_api3->local) {
$output->writeln("<error>Require access to local CiviCRM source tree. Configure civicrm_api3_conf_path.</error>");
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/AddReportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// Create .php & .tpl by either copying from core source tree or using a civix template
if ($srcClassName = $input->getOption('copy')) {
// To locate the original file, we need to bootstrap Civi and search the include path
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if (!$civicrm_api3 || !$civicrm_api3->local) {
$output->writeln("<error>--copy requires access to local CiviCRM source tree. Configure civicrm_api3_conf_path.</error>");
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/AddSearchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {

if ($srcClassName = $input->getOption('copy')) {
// we need bootstrap to set up include path to locate file -- but that's it
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if (!$civicrm_api3 || !$civicrm_api3->local) {
$output->writeln("<error>--copy requires access to local CiviCRM source tree. Configure civicrm_api3_conf_path.</error>");
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
* @return bool TRUE on success; FALSE if there's no site or if there's an error
*/
protected function tryEnable(InputInterface $input, OutputInterface $output, $key) {
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if ($civicrm_api3 && $civicrm_api3->local && version_compare(\CRM_Utils_System::version(), '4.3.dev', '>=')) {
$siteName = \CRM_Utils_System::baseURL(); // \CRM_Core_Config::singleton()->userSystem->cmsRootPath();
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/PingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protected function configure() {
}

protected function execute(InputInterface $input, OutputInterface $output) {
Services::boot(array('output' => $output));
$civicrm_api3 = Services::api3();
if ($civicrm_api3->Contact->Get(array('option.limit' => 1))) {
if (empty($civicrm_api3->result->values[0]->contact_type)) {
Expand Down
1 change: 1 addition & 0 deletions src/CRM/CivixBundle/Command/TestRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function configure() {
}

protected function execute(InputInterface $input, OutputInterface $output) {
Services::boot(array('output' => $output));
$basedir = new Path(getcwd());

// Find extension metadata
Expand Down
12 changes: 7 additions & 5 deletions src/CRM/CivixBundle/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ class Services {

protected static $cache;

public static function boot() {
public static function boot($options = array()) {
if (!isset(self::$cache['boot'])) {
$cwd = getcwd();
Bootstrap::singleton()->boot(array(
'prefetch' => FALSE,
));
$options = array_merge(array('prefetch' => FALSE), $options);
Bootstrap::singleton()->boot($options);
\CRM_Core_Config::singleton();
\CRM_Utils_System::loadBootStrap(array(), FALSE);
chdir($cwd);
Expand All @@ -28,11 +27,14 @@ public static function boot() {
}

/**
* Get a reference to the API class.
*
* Pre-requisite: call boot() to startup CiviCRM.
*
* @return \civicrm_api3
*/
public static function api3() {
if (!isset(self::$cache['civicrm_api3'])) {
self::boot();
if (!stream_resolve_include_path('api/class.api.php')) {
throw new \RuntimeException("Booted CiviCRM, but failed to find 'api/class.api.php'");
}
Expand Down

0 comments on commit 78f5db8

Please sign in to comment.