X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem%2FDrupal8.php;h=e280a40ba76f7db806c9150250eb0b9ea299cbd4;hb=85265311ed16f2a6bdd26bc7c60903dc2cd903c7;hp=b535b0a841bff2481cff3f5fde9f4d7296435dda;hpb=3f7c098fcb6553d0662b9bbf3df2261244a97aa8;p=civicrm-core.git diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index b535b0a841..e280a40ba7 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2018 | + | Copyright CiviCRM LLC (c) 2004-2019 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2018 + * @copyright CiviCRM LLC (c) 2004-2019 */ /** @@ -184,8 +184,8 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { * @inheritDoc */ public function getLoginURL($destination = '') { - $query = $destination ? array('destination' => $destination) : array(); - return \Drupal::url('user.page', array(), array('query' => $query)); + $query = $destination ? ['destination' => $destination] : []; + return \Drupal::url('user.page', [], ['query' => $query]); } /** @@ -229,13 +229,13 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { if ($region != 'html-header') { return FALSE; } - $css = array( + $css = [ '#tag' => 'link', - '#attributes' => array( + '#attributes' => [ 'href' => $url, 'rel' => 'stylesheet', - ), - ); + ], + ]; \Drupal::service('civicrm.page_state')->addCSS($css); return TRUE; } @@ -247,10 +247,10 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { if ($region != 'html-header') { return FALSE; } - $css = array( + $css = [ '#tag' => 'style', '#value' => $code, - ); + ]; \Drupal::service('civicrm.page_state')->addCSS($css); return TRUE; } @@ -304,11 +304,11 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { // Not all links that CiviCRM generates are Drupal routes, so we use the weaker ::fromUri method. try { - $url = \Drupal\Core\Url::fromUri("base:{$url['path']}", array( + $url = \Drupal\Core\Url::fromUri("base:{$url['path']}", [ 'query' => $url['query'], 'fragment' => $fragment, 'absolute' => $absolute, - ))->toString(); + ])->toString(); } catch (Exception $e) { // @Todo: log to watchdog @@ -331,13 +331,13 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { */ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { $system = new CRM_Utils_System_Drupal8(); - $system->loadBootStrap(array(), FALSE); + $system->loadBootStrap([], FALSE); $uid = \Drupal::service('user.auth')->authenticate($name, $password); if ($uid) { if ($this->loadUser($name)) { $contact_id = CRM_Core_BAO_UFMatch::getContactId($uid); - return array($contact_id, $uid, mt_rand()); + return [$contact_id, $uid, mt_rand()]; } } @@ -407,7 +407,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { * @return bool * @Todo Handle setting cleanurls configuration for CiviCRM? */ - public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { + public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { static $run_once = FALSE; if ($run_once) { return TRUE; @@ -427,7 +427,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { $autoloader = ComposerAutoloaderInitDrupal8::getLoader(); } // @Todo: do we need to handle case where $_SERVER has no HTTP_HOST key, ie. when run via cli? - $request = new \Symfony\Component\HttpFoundation\Request(array(), array(), array(), array(), array(), $_SERVER); + $request = new \Symfony\Component\HttpFoundation\Request([], [], [], [], [], $_SERVER); // Create a kernel and boot it. \Drupal\Core\DrupalKernel::createFromRequest($request, $autoloader, 'prod')->prepareLegacyRequest($request); @@ -557,7 +557,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { * @inheritDoc */ public function getModules() { - $modules = array(); + $modules = []; $module_data = system_rebuild_module_data(); foreach ($module_data as $module_name => $extension) { @@ -602,7 +602,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { set_time_limit(300); } - $users = array(); + $users = []; $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(); $uf = $config->userFramework; @@ -627,11 +627,11 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { } } - return array( + return [ 'contactCount' => $contactCount, 'contactMatching' => $contactMatching, 'contactCreated' => $contactCreated, - ); + ]; } /** @@ -667,10 +667,10 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { /** * Append Drupal8 js to coreResourcesList. * - * @param array $list + * @param \Civi\Core\Event\GenericHookEvent $e */ - public function appendCoreResources(&$list) { - $list[] = 'js/crm.drupal8.js'; + public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) { + $e->list[] = 'js/crm.drupal8.js'; } }