當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_Resources::addSettingsFactory方法代碼示例

本文整理匯總了PHP中CRM_Core_Resources::addSettingsFactory方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_Resources::addSettingsFactory方法的具體用法?PHP CRM_Core_Resources::addSettingsFactory怎麽用?PHP CRM_Core_Resources::addSettingsFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_Resources的用法示例。


在下文中一共展示了CRM_Core_Resources::addSettingsFactory方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: registerResources

 /**
  * Register resources required by Angular.
  */
 public function registerResources()
 {
     $modules = $this->angular->getModules();
     $page = $this;
     // PHP 5.3 does not propagate $this to inner functions.
     $this->res->addSettingsFactory(function () use(&$modules, $page) {
         // TODO optimization; client-side caching
         return array_merge($page->angular->getResources(array_keys($modules), 'settings', 'settings'), array('resourceUrls' => \CRM_Extension_System::singleton()->getMapper()->getActiveModuleUrls(), 'angular' => array('modules' => array_merge(array('ngRoute'), array_keys($modules)), 'cacheCode' => $page->res->getCacheCode())));
     });
     $this->res->addScriptFile('civicrm', 'bower_components/angular/angular.min.js', 100, $this->region, FALSE);
     $headOffset = 0;
     $config = \CRM_Core_Config::singleton();
     if ($config->debug) {
         foreach ($modules as $moduleName => $module) {
             foreach ($this->angular->getResources($moduleName, 'css', 'cacheUrl') as $url) {
                 $this->res->addStyleUrl($url, self::DEFAULT_MODULE_WEIGHT + ++$headOffset, $this->region);
             }
             foreach ($this->angular->getResources($moduleName, 'js', 'cacheUrl') as $url) {
                 $this->res->addScriptUrl($url, self::DEFAULT_MODULE_WEIGHT + ++$headOffset, $this->region);
                 // addScriptUrl() bypasses the normal string-localization of addScriptFile(),
                 // but that's OK because all Angular strings (JS+HTML) will load via crmResource.
             }
         }
     } else {
         // Note: addScriptUrl() bypasses the normal string-localization of addScriptFile(),
         // but that's OK because all Angular strings (JS+HTML) will load via crmResource.
         $aggScriptUrl = \CRM_Utils_System::url('civicrm/ajax/angular-modules', 'format=js&r=' . $page->res->getCacheCode(), FALSE, NULL, FALSE);
         $this->res->addScriptUrl($aggScriptUrl, 120, $this->region);
         // FIXME: The following CSS aggregator doesn't currently handle path-adjustments - which can break icons.
         //$aggStyleUrl = \CRM_Utils_System::url('civicrm/ajax/angular-modules', 'format=css&r=' . $page->res->getCacheCode(), FALSE, NULL, FALSE);
         //$this->res->addStyleUrl($aggStyleUrl, 120, $this->region);
         foreach ($this->angular->getResources(array_keys($modules), 'css', 'cacheUrl') as $url) {
             $this->res->addStyleUrl($url, self::DEFAULT_MODULE_WEIGHT + ++$headOffset, $this->region);
         }
     }
     // 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 #).
     \CRM_Core_Resources::singleton()->addSetting(array('angularRoute' => \CRM_Utils_Request::retrieve('route', 'String')));
 }
開發者ID:nganivet,項目名稱:civicrm-core,代碼行數:43,代碼來源:Main.php

示例2: registerResources

 /**
  * Register resources required by Angular.
  */
 public function registerResources()
 {
     $modules = $this->angular->getModules();
     $page = $this;
     // PHP 5.3 does not propagate $this to inner functions.
     $this->res->addSettingsFactory(function () use(&$modules, $page) {
         // TODO optimization; client-side caching
         return array_merge($page->angular->getResources(array_keys($modules), 'settings', 'settings'), array('resourceUrls' => \CRM_Extension_System::singleton()->getMapper()->getActiveModuleUrls(), 'angular' => array('modules' => array_merge(array('ngRoute'), array_keys($modules)), 'cacheCode' => $page->res->getCacheCode())));
     });
     $this->res->addScriptFile('civicrm', 'bower_components/angular/angular.min.js', 100, 'html-header', FALSE);
     // FIXME: crmUi depends on loading ckeditor, but ckeditor doesn't work with this aggregation.
     $this->res->addScriptFile('civicrm', 'packages/ckeditor/ckeditor.js', 100, 'page-header', FALSE);
     $headOffset = 0;
     $config = \CRM_Core_Config::singleton();
     if ($config->debug) {
         foreach ($modules as $moduleName => $module) {
             foreach ($this->angular->getResources($moduleName, 'css', 'cacheUrl') as $url) {
                 $this->res->addStyleUrl($url, self::DEFAULT_MODULE_WEIGHT + ++$headOffset, 'html-header');
             }
             foreach ($this->angular->getResources($moduleName, 'js', 'cacheUrl') as $url) {
                 $this->res->addScriptUrl($url, self::DEFAULT_MODULE_WEIGHT + ++$headOffset, 'html-header');
                 // addScriptUrl() bypasses the normal string-localization of addScriptFile(),
                 // but that's OK because all Angular strings (JS+HTML) will load via crmResource.
             }
         }
     } else {
         // Note: addScriptUrl() bypasses the normal string-localization of addScriptFile(),
         // but that's OK because all Angular strings (JS+HTML) will load via crmResource.
         $aggScriptUrl = \CRM_Utils_System::url('civicrm/ajax/angular-modules', 'format=js&r=' . $page->res->getCacheCode(), FALSE, NULL, FALSE);
         $this->res->addScriptUrl($aggScriptUrl, 120, 'html-header');
         // FIXME: The following CSS aggregator doesn't currently handle path-adjustments - which can break icons.
         //$aggStyleUrl = \CRM_Utils_System::url('civicrm/ajax/angular-modules', 'format=css&r=' . $page->res->getCacheCode(), FALSE, NULL, FALSE);
         //$this->res->addStyleUrl($aggStyleUrl, 120, 'html-header');
         foreach ($this->angular->getResources(array_keys($modules), 'css', 'cacheUrl') as $url) {
             $this->res->addStyleUrl($url, self::DEFAULT_MODULE_WEIGHT + ++$headOffset, 'html-header');
         }
     }
 }
開發者ID:kidaa30,項目名稱:yes,代碼行數:41,代碼來源:Main.php

示例3: testAddSettingAndSettingFactory

 public function testAddSettingAndSettingFactory()
 {
     $this->res->addSetting(array('fruit' => array('mine' => 'apple')));
     $muckableValue = array('fruit' => array('yours' => 'orange', 'theirs' => 'apricot'));
     $this->res->addSettingsFactory(function () use(&$muckableValue) {
         return $muckableValue;
     });
     $actual = $this->res->getSettings();
     $expected = array('fruit' => array('mine' => 'apple', 'yours' => 'orange', 'theirs' => 'apricot'));
     $this->assertTreeEquals($expected, $actual);
     // note: the setting is not fixed based on what the factory returns when registered; it's based
     // on what the factory returns when getSettings is called
     $muckableValue = array('fruit' => array('yours' => 'banana'));
     $actual = $this->res->getSettings();
     $expected = array('fruit' => array('mine' => 'apple', 'yours' => 'banana'));
     $this->assertTreeEquals($expected, $actual);
 }
開發者ID:FundingWorks,項目名稱:civicrm-core,代碼行數:17,代碼來源:ResourcesTest.php

示例4: registerResources

 /**
  * @param CRM_Core_Resources $res
  */
 public function registerResources(CRM_Core_Resources $res)
 {
     $weight = self::DEFAULT_MODULE_WEIGHT;
     $res->addSettingsFactory(function () {
         // inorder to use ext resource url in JS - e.g CRM.resourceUrls
         $jsvar = array('resourceUrls' => CRM_Extension_System::singleton()->getMapper()->getActiveModuleUrls());
         return $jsvar;
     });
     $res->addStyleFile('uk.co.vedaconsulting.mosaico', 'packages/mosaico/dist/mosaico-material.min.css', $weight++, 'html-header', TRUE);
     $res->addStyleFile('uk.co.vedaconsulting.mosaico', 'packages/mosaico/dist/vendor/notoregular/stylesheet.css', $weight++, 'html-header', TRUE);
     $res->addScriptFile('uk.co.vedaconsulting.mosaico', 'packages/mosaico/dist/vendor/knockout.js', $weight++, 'html-header', TRUE);
     // civi already has jquery.min
     //$res->addScriptFile('uk.co.vedaconsulting.mosaico', 'packages/mosaico/dist/vendor/jquery.min.js', $weight++, 'html-header', TRUE);
     $res->addScriptFile('uk.co.vedaconsulting.mosaico', 'js/index.js', $weight++, 'html-header', FALSE);
     $res->addStyleFile('uk.co.vedaconsulting.mosaico', 'css/index.css', $weight++, 'html-header', TRUE);
     $res->addScriptFile('uk.co.vedaconsulting.mosaico', 'js/index2.js', $weight++, 'html-header', TRUE);
 }
開發者ID:Kajakaran,項目名稱:uk.co.vedaconsulting.mosaico,代碼行數:20,代碼來源:Index.php

示例5: registerResources

 /**
  * @param CRM_Core_Resources $res
  */
 public function registerResources(CRM_Core_Resources $res)
 {
     $modules = self::getAngularModules();
     $res->addSettingsFactory(function () use(&$modules) {
         // TODO optimization; client-side caching
         return array('resourceUrls' => CRM_Extension_System::singleton()->getMapper()->getActiveModuleUrls(), 'angular' => array('modules' => array_merge(array('ngRoute'), array_keys($modules))));
     });
     $res->addScriptFile('civicrm', 'packages/bower_components/angular/angular.min.js', 100, 'html-header', FALSE);
     $res->addScriptFile('civicrm', 'packages/bower_components/angular-route/angular-route.min.js', 110, 'html-header', FALSE);
     foreach ($modules as $module) {
         if (!empty($module['css'])) {
             foreach ($module['css'] as $file) {
                 $res->addStyleFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE);
             }
         }
         if (!empty($module['js'])) {
             foreach ($module['js'] as $file) {
                 $res->addScriptFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT, 'html-header', TRUE);
             }
         }
     }
 }
開發者ID:prashantgajare,項目名稱:civicrm-core,代碼行數:25,代碼來源:Angular.php


注:本文中的CRM_Core_Resources::addSettingsFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。