2 namespace Civi\Angular\Page
;
5 * This page is simply a container; any Angular modules defined by CiviCRM (or by CiviCRM extensions)
6 * will be activated on this page.
8 * @link https://issues.civicrm.org/jira/browse/CRM-14479
10 class Main
extends \CRM_Core_Page
{
13 * The weight to assign to any Angular JS module files.
15 const DEFAULT_MODULE_WEIGHT
= 200;
18 * The resource manager.
20 * Do not use publicly. Inject your own copy!
22 * @var \CRM_Core_Resources
28 * The Angular module manager.
30 * Do not use publicly. Inject your own copy!
32 * @var \Civi\Angular\Manager
38 * The region of the page into which JavaScript will be loaded.
46 * @param string $title
50 * @param \CRM_Core_Resources|null $res
53 public function __construct($title = NULL, $mode = NULL, $res = NULL) {
54 parent
::__construct($title, $mode);
55 $this->res
= \CRM_Core_Resources
::singleton();
56 $this->angular
= \Civi
::service('angular');
57 $this->region
= \CRM_Utils_Request
::retrieve('snippet', 'String') ?
'ajax-snippet' : 'html-header';
61 * This function takes care of all the things common to all
62 * pages. This typically involves assigning the appropriate
66 * The content generated by running this page
68 public function run() {
69 $this->registerResources();
74 * Register resources required by Angular.
76 public function registerResources() {
77 $loader = new \Civi\Angular\
AngularLoader();
78 $loader->setPageName('civicrm/a');
79 $loader->setModules(array('crmApp'));
82 // If trying to load an Angular page via AJAX, the route must be passed as a
83 // URL parameter, since the server doesn't receive information about
84 // URL fragments (i.e, what comes after the #).
85 \CRM_Core_Resources
::singleton()->addSetting(array(
87 'defaultRoute' => NULL,
89 'angularRoute' => \CRM_Utils_Request
::retrieve('route', 'String'),
96 public function getTemplateFileName() {
97 return 'Civi/Angular/Page/Main.tpl';