crmExample - Hidden Angular module for testing custom widgets in various configs.
[civicrm-core.git] / xml / templates / listAll.tpl
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2014
33 * $Id$
34 *
35 */
36
37 class CRM_Core_DAO_AllCoreTables {ldelim}
38
39 static private $tables = null;
40 static private $daoToClass = null;
41
42 static public function init($fresh = FALSE) {ldelim}
43 static $init = FALSE;
44 if ($init && !$fresh) return;
45
46 $entityTypes = array(
47 {foreach from=$tables key=tableName item=table}
48 '{$table.className}' => array(
49 'name' => '{$table.objectName}',
50 'class' => '{$table.className}',
51 'table' => '{$tableName}',
52 ),
53 {/foreach}
54 );
55
56 CRM_Utils_Hook::entityTypes($entityTypes);
57
58 self::$tables = array();
59 self::$daoToClass = array();
60 foreach ($entityTypes as $entityType) {ldelim}
61 self::registerEntityType($entityType['name'], $entityType['class'], $entityType['table']);
62 {rdelim}
63
64 $init = TRUE;
65 {rdelim}
66
67 /**
68 * (Quasi-Private) Do not call externally (except for unit-testing)
69 */
70 static public function registerEntityType($daoName, $className, $tableName) {ldelim}
71 self::$daoToClass[$daoName] = $className;
72 self::$tables[$tableName] = $className;
73 {rdelim}
74
75 static public function tables() {ldelim}
76 self::init();
77 return self::$tables;
78 {rdelim}
79
80 static public function daoToClass() {ldelim}
81 self::init();
82 return self::$daoToClass;
83 {rdelim}
84
85 static public function getCoreTables() {ldelim}
86 return self::tables();
87 {rdelim}
88
89 static public function isCoreTable($tableName) {ldelim}
90 return FALSE !== array_search($tableName, self::tables());
91 {rdelim}
92
93 static public function getCanonicalClassName($className) {ldelim}
94 return str_replace('_BAO_', '_DAO_', $className);
95 {rdelim}
96
97 static public function getClasses() {ldelim}
98 return array_values(self::daoToClass());
99 {rdelim}
100
101 static public function getClassForTable($tableName) {ldelim}
102 return CRM_Utils_Array::value($tableName, self::tables());
103 {rdelim}
104
105 static public function getFullName($daoName) {ldelim}
106 return CRM_Utils_Array::value($daoName, self::daoToClass());
107 {rdelim}
108
109 static public function getBriefName($className) {ldelim}
110 return CRM_Utils_Array::value($className, array_flip(self::daoToClass()));
111 {rdelim}
112
113 /**
114 * @param string $className DAO or BAO name
115 * @return string|FALSE SQL table name
116 */
117 static public function getTableForClass($className) {ldelim}
118 return array_search(self::getCanonicalClassName($className), self::tables());
119 {rdelim}
120
121 static public function reinitializeCache($fresh = FALSE) {ldelim}
122 self::init($fresh);
123 {rdelim}
124
125 {rdelim}