Commit | Line | Data |
---|---|---|
e7ff7042 | 1 | <?php |
39c3d5e9 | 2 | namespace Civi\Angular\Page; |
e7ff7042 TO |
3 | |
4 | /** | |
5 | * This page is simply a container; any Angular modules defined by CiviCRM (or by CiviCRM extensions) | |
6 | * will be activated on this page. | |
7 | * | |
8 | * @link https://issues.civicrm.org/jira/browse/CRM-14479 | |
9 | */ | |
39c3d5e9 | 10 | class Main extends \CRM_Core_Page { |
b20ea913 | 11 | |
e7ff7042 | 12 | /** |
fe482240 | 13 | * The weight to assign to any Angular JS module files. |
e7ff7042 TO |
14 | */ |
15 | const DEFAULT_MODULE_WEIGHT = 200; | |
16 | ||
2f6c50d5 | 17 | /** |
4d93c42f TO |
18 | * The resource manager. |
19 | * | |
20 | * Do not use publicly. Inject your own copy! | |
21 | * | |
39c3d5e9 | 22 | * @var \CRM_Core_Resources |
b20ea913 | 23 | * @deprecated |
2f6c50d5 | 24 | */ |
4d93c42f | 25 | public $res; |
2f6c50d5 | 26 | |
16072ce1 | 27 | /** |
4d93c42f TO |
28 | * The Angular module manager. |
29 | * | |
30 | * Do not use publicly. Inject your own copy! | |
31 | * | |
39c3d5e9 | 32 | * @var \Civi\Angular\Manager |
b20ea913 | 33 | * @deprecated |
16072ce1 | 34 | */ |
4d93c42f | 35 | public $angular; |
16072ce1 | 36 | |
2c60bace FG |
37 | /** |
38 | * The region of the page into which JavaScript will be loaded. | |
39 | * | |
9f266042 | 40 | * @var string |
b20ea913 | 41 | * @deprecated |
2c60bace FG |
42 | */ |
43 | public $region; | |
44 | ||
2f6c50d5 TO |
45 | /** |
46 | * @param string $title | |
47 | * Title of the page. | |
48 | * @param int $mode | |
49 | * Mode of the page. | |
39c3d5e9 | 50 | * @param \CRM_Core_Resources|null $res |
2f6c50d5 TO |
51 | * Resource manager. |
52 | */ | |
53 | public function __construct($title = NULL, $mode = NULL, $res = NULL) { | |
54 | parent::__construct($title, $mode); | |
39c3d5e9 | 55 | $this->res = \CRM_Core_Resources::singleton(); |
048222df | 56 | $this->angular = \Civi::service('angular'); |
6aeeacaf | 57 | $this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header'; |
2f6c50d5 TO |
58 | } |
59 | ||
b5c2afd0 EM |
60 | /** |
61 | * This function takes care of all the things common to all | |
62 | * pages. This typically involves assigning the appropriate | |
63 | * smarty variable :) | |
64 | * | |
a6c01b45 CW |
65 | * @return string |
66 | * The content generated by running this page | |
b5c2afd0 | 67 | */ |
00be9182 | 68 | public function run() { |
6aeeacaf | 69 | $this->registerResources(); |
4b07d5bd TO |
70 | return parent::run(); |
71 | } | |
72 | ||
a0ee3941 | 73 | /** |
2f6c50d5 | 74 | * Register resources required by Angular. |
a0ee3941 | 75 | */ |
6aeeacaf | 76 | public function registerResources() { |
b20ea913 TO |
77 | $loader = new \Civi\Angular\AngularLoader(); |
78 | $loader->setPageName('civicrm/a'); | |
c64f69d9 | 79 | $loader->useApp([ |
3e8823e3 TO |
80 | 'activeRoute' => \CRM_Utils_Request::retrieve('route', 'String'), |
81 | 'defaultRoute' => NULL, | |
c64f69d9 | 82 | ]); |
3e8823e3 | 83 | $loader->load(); |
e807a9a6 | 84 | |
fe158128 TO |
85 | } |
86 | ||
b5c2afd0 | 87 | } |