3 // AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file
6 * The ExtensionUtil class provides small stubs for accessing resources of this
9 class CRM_Payflowpro_ExtensionUtil
{
10 const SHORT_NAME
= 'payflowpro';
11 const LONG_NAME
= 'payflowpro';
12 const CLASS_PREFIX
= 'CRM_Payflowpro';
15 * Translate a string using the extension's domain.
17 * If the extension doesn't have a specific translation
18 * for the string, fallback to the default translations.
21 * Canonical message text (generally en_US).
22 * @param array $params
27 public static function ts($text, $params = []) {
28 if (!array_key_exists('domain', $params)) {
29 $params['domain'] = [self
::LONG_NAME
, NULL];
31 return ts($text, $params);
35 * Get the URL of a resource file (in this extension).
37 * @param string|NULL $file
41 * Ex: 'http://example.org/sites/default/ext/org.example.foo'.
42 * Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
44 public static function url($file = NULL) {
46 return rtrim(CRM_Core_Resources
::singleton()->getUrl(self
::LONG_NAME
), '/');
48 return CRM_Core_Resources
::singleton()->getUrl(self
::LONG_NAME
, $file);
52 * Get the path of a resource file (in this extension).
54 * @param string|NULL $file
58 * Ex: '/var/www/example.org/sites/default/ext/org.example.foo'.
59 * Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'.
61 public static function path($file = NULL) {
62 // return CRM_Core_Resources::singleton()->getPath(self::LONG_NAME, $file);
63 return __DIR__
. ($file === NULL ?
'' : (DIRECTORY_SEPARATOR
. $file));
67 * Get the name of a class within this extension.
69 * @param string $suffix
70 * Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'.
72 * Ex: 'CRM_Foo_Page_HelloWorld'.
74 public static function findClass($suffix) {
75 return self
::CLASS_PREFIX
. '_' . str_replace('\\', '_', $suffix);
80 use CRM_Payflowpro_ExtensionUtil
as E
;
83 * (Delegated) Implements hook_civicrm_config().
85 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config
87 function _payflowpro_civix_civicrm_config(&$config = NULL) {
88 static $configured = FALSE;
94 $template = CRM_Core_Smarty
::singleton();
97 . DIRECTORY_SEPARATOR
;
98 $extDir = $extRoot . 'templates';
100 if (is_array($template->template_dir
)) {
101 array_unshift($template->template_dir
, $extDir);
104 $template->template_dir
= [$extDir, $template->template_dir
];
107 $include_path = $extRoot . PATH_SEPARATOR
. get_include_path();
108 set_include_path($include_path);
112 * Implements hook_civicrm_install().
114 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
116 function _payflowpro_civix_civicrm_install() {
117 _payflowpro_civix_civicrm_config();
118 if ($upgrader = _payflowpro_civix_upgrader()) {
119 $upgrader->onInstall();
124 * Implements hook_civicrm_postInstall().
126 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
128 function _payflowpro_civix_civicrm_postInstall() {
129 _payflowpro_civix_civicrm_config();
130 if ($upgrader = _payflowpro_civix_upgrader()) {
131 if (is_callable([$upgrader, 'onPostInstall'])) {
132 $upgrader->onPostInstall();
138 * Implements hook_civicrm_uninstall().
140 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
142 function _payflowpro_civix_civicrm_uninstall() {
143 _payflowpro_civix_civicrm_config();
144 if ($upgrader = _payflowpro_civix_upgrader()) {
145 $upgrader->onUninstall();
150 * (Delegated) Implements hook_civicrm_enable().
152 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
154 function _payflowpro_civix_civicrm_enable() {
155 _payflowpro_civix_civicrm_config();
156 if ($upgrader = _payflowpro_civix_upgrader()) {
157 if (is_callable([$upgrader, 'onEnable'])) {
158 $upgrader->onEnable();
164 * (Delegated) Implements hook_civicrm_disable().
166 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
169 function _payflowpro_civix_civicrm_disable() {
170 _payflowpro_civix_civicrm_config();
171 if ($upgrader = _payflowpro_civix_upgrader()) {
172 if (is_callable([$upgrader, 'onDisable'])) {
173 $upgrader->onDisable();
179 * (Delegated) Implements hook_civicrm_upgrade().
181 * @param $op string, the type of operation being performed; 'check' or 'enqueue'
182 * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
185 * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
186 * for 'enqueue', returns void
188 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
190 function _payflowpro_civix_civicrm_upgrade($op, CRM_Queue_Queue
$queue = NULL) {
191 if ($upgrader = _payflowpro_civix_upgrader()) {
192 return $upgrader->onUpgrade($op, $queue);
197 * @return CRM_Payflowpro_Upgrader
199 function _payflowpro_civix_upgrader() {
200 if (!file_exists(__DIR__
. '/CRM/Payflowpro/Upgrader.php')) {
204 return CRM_Payflowpro_Upgrader_Base
::instance();
209 * Inserts a navigation menu item at a given place in the hierarchy.
211 * @param array $menu - menu hierarchy
212 * @param string $path - path to parent of this item, e.g. 'my_extension/submenu'
213 * 'Mailing', or 'Administer/System Settings'
214 * @param array $item - the item to insert (parent/child attributes will be
219 function _payflowpro_civix_insert_navigation_menu(&$menu, $path, $item) {
220 // If we are done going down the path, insert menu
223 'attributes' => array_merge([
224 'label' => CRM_Utils_Array
::value('name', $item),
231 // Find an recurse into the next level down
233 $path = explode('/', $path);
234 $first = array_shift($path);
235 foreach ($menu as $key => &$entry) {
236 if ($entry['attributes']['name'] == $first) {
237 if (!isset($entry['child'])) {
238 $entry['child'] = [];
240 $found = _payflowpro_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item);
248 * (Delegated) Implements hook_civicrm_navigationMenu().
250 function _payflowpro_civix_navigationMenu(&$nodes) {
251 if (!is_callable(['CRM_Core_BAO_Navigation', 'fixNavigationMenu'])) {
252 _payflowpro_civix_fixNavigationMenu($nodes);
257 * Given a navigation menu, generate navIDs for any items which are
260 function _payflowpro_civix_fixNavigationMenu(&$nodes) {
262 array_walk_recursive($nodes, function($item, $key) use (&$maxNavID) {
263 if ($key === 'navID') {
264 $maxNavID = max($maxNavID, $item);
267 _payflowpro_civix_fixNavigationMenuItems($nodes, $maxNavID, NULL);
270 function _payflowpro_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $parentID) {
271 $origKeys = array_keys($nodes);
272 foreach ($origKeys as $origKey) {
273 if (!isset($nodes[$origKey]['attributes']['parentID']) && $parentID !== NULL) {
274 $nodes[$origKey]['attributes']['parentID'] = $parentID;
276 // If no navID, then assign navID and fix key.
277 if (!isset($nodes[$origKey]['attributes']['navID'])) {
278 $newKey = ++
$maxNavID;
279 $nodes[$origKey]['attributes']['navID'] = $newKey;
280 $nodes[$newKey] = $nodes[$origKey];
281 unset($nodes[$origKey]);
284 if (isset($nodes[$origKey]['child']) && is_array($nodes[$origKey]['child'])) {
285 _payflowpro_civix_fixNavigationMenuItems($nodes[$origKey]['child'], $maxNavID, $nodes[$origKey]['attributes']['navID']);
291 * (Delegated) Implements hook_civicrm_entityTypes().
293 * Find any *.entityType.php files, merge their content, and return.
295 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
297 function _payflowpro_civix_civicrm_entityTypes(&$entityTypes) {
298 $entityTypes = array_merge($entityTypes, []);