Merge pull request #11838 from mfb/ses-smtp-support
[civicrm-core.git] / Civi / Angular / Page / Main.php
1 <?php
2 namespace Civi\Angular\Page;
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 */
10 class Main extends \CRM_Core_Page {
11
12 /**
13 * The weight to assign to any Angular JS module files.
14 */
15 const DEFAULT_MODULE_WEIGHT = 200;
16
17 /**
18 * The resource manager.
19 *
20 * Do not use publicly. Inject your own copy!
21 *
22 * @var \CRM_Core_Resources
23 * @deprecated
24 */
25 public $res;
26
27 /**
28 * The Angular module manager.
29 *
30 * Do not use publicly. Inject your own copy!
31 *
32 * @var \Civi\Angular\Manager
33 * @deprecated
34 */
35 public $angular;
36
37 /**
38 * The region of the page into which JavaScript will be loaded.
39 *
40 * @var String
41 * @deprecated
42 */
43 public $region;
44
45 /**
46 * @param string $title
47 * Title of the page.
48 * @param int $mode
49 * Mode of the page.
50 * @param \CRM_Core_Resources|null $res
51 * Resource manager.
52 */
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';
58 }
59
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 *
65 * @return string
66 * The content generated by running this page
67 */
68 public function run() {
69 $this->registerResources();
70 return parent::run();
71 }
72
73 /**
74 * Register resources required by Angular.
75 */
76 public function registerResources() {
77 $loader = new \Civi\Angular\AngularLoader();
78 $loader->setPageName('civicrm/a');
79 $loader->useApp(array(
80 'activeRoute' => \CRM_Utils_Request::retrieve('route', 'String'),
81 'defaultRoute' => NULL,
82 ));
83 $loader->load();
84
85 }
86
87 }