CRM-15578 - StaticProvider, etal - Prep for unit-tests of Attachment API
[civicrm-core.git] / xml / templates / listAll.tpl
CommitLineData
6b5ff8c9
ARW
1<?php
2
3/*
4 +--------------------------------------------------------------------+
811982aa 5 | CiviCRM version 4.5 |
6b5ff8c9 6 +--------------------------------------------------------------------+
811982aa 7 | Copyright CiviCRM LLC (c) 2004-2014 |
6b5ff8c9
ARW
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
811982aa 32 * @copyright CiviCRM LLC (c) 2004-2014
6b5ff8c9
ARW
33 * $Id$
34 *
35 */
36
4d1d7aca 37class CRM_Core_DAO_AllCoreTables {ldelim}
6b5ff8c9 38
fed67e4d
TO
39 static private $tables = null;
40 static private $daoToClass = null;
41
17b9f7be 42 static public function init($fresh = FALSE) {ldelim}
fed67e4d 43 static $init = FALSE;
95a90cba 44 if ($init && !$fresh) return;
fed67e4d
TO
45
46 $entityTypes = array(
6b5ff8c9 47{foreach from=$tables key=tableName item=table}
fed67e4d
TO
48 '{$table.className}' => array(
49 'name' => '{$table.objectName}',
50 'class' => '{$table.className}',
51 'table' => '{$tableName}',
52 ),
53{/foreach}
54 );
6b5ff8c9 55
fed67e4d 56 CRM_Utils_Hook::entityTypes($entityTypes);
58d8ecd0 57
fed67e4d
TO
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}
6b5ff8c9 63
fed67e4d
TO
64 $init = TRUE;
65 {rdelim}
66
17b9f7be
TO
67 /**
68 * (Quasi-Private) Do not call externally (except for unit-testing)
69 */
70 static public function registerEntityType($daoName, $className, $tableName) {ldelim}
fed67e4d
TO
71 self::$daoToClass[$daoName] = $className;
72 self::$tables[$tableName] = $className;
73 {rdelim}
74
75 static public function tables() {ldelim}
76 self::init();
6b5ff8c9
ARW
77 return self::$tables;
78 {rdelim}
79
fed67e4d
TO
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
6b5ff8c9 89 static public function isCoreTable($tableName) {ldelim}
fed67e4d 90 return FALSE !== array_search($tableName, self::tables());
6b5ff8c9
ARW
91 {rdelim}
92
a6c6fe56
TO
93 static public function getCanonicalClassName($className) {ldelim}
94 return str_replace('_BAO_', '_DAO_', $className);
95 {rdelim}
96
439a6148 97 static public function getClasses() {ldelim}
fed67e4d 98 return array_values(self::daoToClass());
439a6148
TO
99 {rdelim}
100
101 static public function getClassForTable($tableName) {ldelim}
fed67e4d 102 return CRM_Utils_Array::value($tableName, self::tables());
439a6148
TO
103 {rdelim}
104
6b5ff8c9 105 static public function getFullName($daoName) {ldelim}
fed67e4d 106 return CRM_Utils_Array::value($daoName, self::daoToClass());
6b5ff8c9
ARW
107 {rdelim}
108
edc091f1 109 static public function getBriefName($className) {ldelim}
fed67e4d 110 return CRM_Utils_Array::value($className, array_flip(self::daoToClass()));
edc091f1
ARW
111 {rdelim}
112
a6c6fe56
TO
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
95a90cba
N
121 static public function reinitializeCache($fresh = FALSE) {ldelim}
122 self::init($fresh);
123 {rdelim}
a6c6fe56 124
6b5ff8c9 125{rdelim}