X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FAngular%2FAngularLoader.php;h=f74479fb4685360be0be01adbb36a036f309f88f;hb=2cbdf469fa35930800e92960193887064045cd28;hp=e16cab341984d61d4737f024ee513a2349d84b95;hpb=a866838c9b5e04dc08caf43c26ebbbec16243059;p=civicrm-core.git diff --git a/Civi/Angular/AngularLoader.php b/Civi/Angular/AngularLoader.php index e16cab3419..f74479fb46 100644 --- a/Civi/Angular/AngularLoader.php +++ b/Civi/Angular/AngularLoader.php @@ -62,7 +62,7 @@ class AngularLoader { protected $modules; /** - * @var array|NULL + * @var array|null */ protected $crmApp = NULL; @@ -74,7 +74,7 @@ class AngularLoader { $this->angular = \Civi::service('angular'); $this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header'; $this->pageName = isset($_GET['q']) ? $_GET['q'] : NULL; - $this->modules = array(); + $this->modules = []; } /** @@ -89,42 +89,42 @@ class AngularLoader { if ($this->crmApp !== NULL) { $this->addModules($this->crmApp['modules']); $region = \CRM_Core_Region::instance($this->crmApp['region']); - $region->update('default', array('disabled' => TRUE)); - $region->add(array('template' => $this->crmApp['file'], 'weight' => 0)); - $this->res->addSetting(array( - 'crmApp' => array( + $region->update('default', ['disabled' => TRUE]); + $region->add(['template' => $this->crmApp['file'], 'weight' => 0]); + $this->res->addSetting([ + 'crmApp' => [ 'defaultRoute' => $this->crmApp['defaultRoute'], - ), - )); + ], + ]); // If trying to load an Angular page via AJAX, the route must be passed as a // URL parameter, since the server doesn't receive information about // URL fragments (i.e, what comes after the #). - $this->res->addSetting(array( + $this->res->addSetting([ 'angularRoute' => $this->crmApp['activeRoute'], - )); + ]); } $moduleNames = $this->findActiveModules(); if (!$this->isAllModules($moduleNames)) { - $assetParams = array('modules' => implode(',', $moduleNames)); + $assetParams = ['modules' => implode(',', $moduleNames)]; } else { // The module list will be "all modules that the user can see". - $assetParams = array('nonce' => md5(implode(',', $moduleNames))); + $assetParams = ['nonce' => md5(implode(',', $moduleNames))]; } $res->addSettingsFactory(function () use (&$moduleNames, $angular, $res, $assetParams) { // TODO optimization; client-side caching - $result = array_merge($angular->getResources($moduleNames, 'settings', 'settings'), array( + $result = array_merge($angular->getResources($moduleNames, 'settings', 'settings'), [ 'resourceUrls' => \CRM_Extension_System::singleton()->getMapper()->getActiveModuleUrls(), - 'angular' => array( + 'angular' => [ 'modules' => $moduleNames, 'requires' => $angular->getResources($moduleNames, 'requires', 'requires'), 'cacheCode' => $res->getCacheCode(), 'bundleUrl' => \Civi::service('asset_builder')->getUrl('angular-modules.json', $assetParams), - ), - )); + ], + ]); return $result; }); @@ -190,14 +190,14 @@ class AngularLoader { * @return AngularLoader * @link https://code.angularjs.org/1.5.11/docs/guide/bootstrap */ - public function useApp($settings = array()) { - $defaults = array( - 'modules' => array('crmApp'), + public function useApp($settings = []) { + $defaults = [ + 'modules' => ['crmApp'], 'activeRoute' => NULL, 'defaultRoute' => NULL, 'region' => 'page-body', 'file' => 'Civi/Angular/Page/Main.tpl', - ); + ]; $this->crmApp = array_merge($defaults, $settings); return $this; }