<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
* Component stores all the static and dynamic information of the various
*/
class CRM_Core_Component {
- /*
- * End part (filename) of the component information class'es name
- * that needs to be present in components main directory.
- */
- CONST COMPONENT_INFO_CLASS = 'Info';
+ /**
+ * End part (filename) of the component information class'es name
+ * that needs to be present in components main directory.
+ */
+ const COMPONENT_INFO_CLASS = 'Info';
private static $_info = NULL;
static $_contactSubTypes = NULL;
+ /**
+ * @param bool $force
+ *
+ * @return array|null
+ */
private static function &_info($force = FALSE) {
if (self::$_info == NULL || $force) {
self::$_info = array();
return self::$_info;
}
- static function get($name, $attribute = NULL) {
+ /**
+ * @param string $name
+ * @param null $attribute
+ *
+ * @return mixed
+ */
+ public static function get($name, $attribute = NULL) {
$comp = CRM_Utils_Array::value($name, self::_info());
if ($attribute) {
return CRM_Utils_Array::value($attribute, $comp->info);
return $comp;
}
+ /**
+ * @param bool $force
+ *
+ * @return array
+ * @throws Exception
+ */
public static function &getComponents($force = FALSE) {
static $_cache = NULL;
$cr->find(FALSE);
while ($cr->fetch()) {
$infoClass = $cr->namespace . '_' . self::COMPONENT_INFO_CLASS;
- require_once (str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php');
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php';
$infoObject = new $infoClass($cr->name, $cr->namespace, $cr->id);
if ($infoObject->info['name'] !== $cr->name) {
CRM_Core_Error::fatal("There is a discrepancy between name in component registry and in info file ({$cr->name}).");
return $_cache;
}
+ /**
+ * @param bool $force
+ *
+ * @return array|null
+ */
static public function &getEnabledComponents($force = FALSE) {
return self::_info($force);
}
self::getEnabledComponents(TRUE);
}
+ /**
+ * @param bool $translated
+ *
+ * @return array
+ */
public static function &getNames($translated = FALSE) {
$allComponents = self::getComponents();
return $names;
}
- static function invoke(&$args, $type) {
+ /**
+ * @param $args
+ * @param $type
+ *
+ * @return bool
+ */
+ public static function invoke(&$args, $type) {
$info = self::_info();
$config = CRM_Core_Config::singleton();
return FALSE;
}
- static function xmlMenu() {
+ /**
+ * @return array
+ */
+ public static function xmlMenu() {
// lets build the menu for all components
$info = self::getComponents(TRUE);
return $files;
}
- static function &menu() {
+ /**
+ * @return array
+ */
+ public static function &menu() {
$info = self::_info();
$items = array();
foreach ($info as $name => $comp) {
return $items;
}
- static function addConfig(&$config, $oldMode = FALSE) {
+ /**
+ * @param $config
+ * @param bool $oldMode
+ */
+ public static function addConfig(&$config, $oldMode = FALSE) {
$info = self::_info();
foreach ($info as $name => $comp) {
$cfg = $comp->getConfigObject();
$cfg->add($config, $oldMode);
}
- return;
+ return NULL;
}
- static function getComponentID($componentName) {
+ /**
+ * @param string $componentName
+ *
+ * @return mixed
+ */
+ public static function getComponentID($componentName) {
$info = self::_info();
-
- return $info[$componentName]->componentID;
+ if (!empty($info[$componentName])) {
+ return $info[$componentName]->componentID;
+ }
+ else {
+ return;
+ }
}
- static function getComponentName($componentID) {
+ /**
+ * @param int $componentID
+ *
+ * @return int|null|string
+ */
+ public static function getComponentName($componentID) {
$info = self::_info();
$componentName = NULL;
return $componentName;
}
- static function &getQueryFields() {
+ /**
+ * @return array
+ */
+ public static function &getQueryFields() {
$info = self::_info();
$fields = array();
foreach ($info as $name => $comp) {
if ($comp->usesSearch()) {
- $bqr = $comp->getBAOQueryObject();
- $flds = $bqr->getFields();
+ $bqr = $comp->getBAOQueryObject();
+ $flds = $bqr->getFields();
$fields = array_merge($fields, $flds);
}
}
return $fields;
}
- static function alterQuery(&$query, $fnName) {
+ /**
+ * @param $query
+ * @param string $fnName
+ */
+ public static function alterQuery(&$query, $fnName) {
$info = self::_info();
foreach ($info as $name => $comp) {
}
}
- static function from($fieldName, $mode, $side) {
+ /**
+ * @param string $fieldName
+ * @param $mode
+ * @param $side
+ *
+ * @return null
+ */
+ public static function from($fieldName, $mode, $side) {
$info = self::_info();
$from = NULL;
return $from;
}
- static function &defaultReturnProperties($mode,
+ /**
+ * @param $mode
+ * @param bool $includeCustomFields
+ *
+ * @return null
+ */
+ public static function &defaultReturnProperties(
+ $mode,
$includeCustomFields = TRUE
) {
$info = self::_info();
return $properties;
}
- static function &buildSearchForm(&$form) {
+ /**
+ * @param CRM_Core_Form $form
+ */
+ public static function &buildSearchForm(&$form) {
$info = self::_info();
foreach ($info as $name => $comp) {
}
}
- static function searchAction(&$row, $id) {
+ /**
+ * @param $row
+ * @param int $id
+ */
+ public static function searchAction(&$row, $id) {
$info = self::_info();
foreach ($info as $name => $comp) {
}
}
- static function &contactSubTypes() {
+ /**
+ * @return array|null
+ */
+ public static function &contactSubTypes() {
if (self::$_contactSubTypes == NULL) {
self::$_contactSubTypes = array();
}
}
- static function &contactSubTypeProperties($subType, $op) {
+ /**
+ * @param $subType
+ * @param $op
+ *
+ * @return null
+ */
+ public static function &contactSubTypeProperties($subType, $op) {
$properties = self::contactSubTypes();
if (array_key_exists($subType, $properties) &&
array_key_exists($op, $properties[$subType])
/**
* FIXME: This function does not appear to do anything. The is_array() check runs on a bunch of objects and (always?) returns false
*/
- static function &taskList() {
+ public static function &taskList() {
$info = self::_info();
$tasks = array();
}
/**
- * Function to handle table dependencies of components
+ * Handle table dependencies of components
*
- * @param array $tables array of tables
+ * @param array $tables
+ * Array of tables.
*
- * @return null
- * @access public
- * @static
*/
- static function tableNames(&$tables) {
+ public static function tableNames(&$tables) {
$info = self::_info();
foreach ($info as $name => $comp) {
}
/**
- * Function to get components info from info file
- *
+ * Get components info from info file
*/
- static function getComponentsFromFile($crmFolderDir) {
+ public static function getComponentsFromFile($crmFolderDir) {
$components = array();
//traverse CRM folder and check for Info file
- if (is_dir($crmFolderDir)) {
- $dir = opendir($crmFolderDir);
+ if (is_dir($crmFolderDir) && $dir = opendir($crmFolderDir)) {
while ($subDir = readdir($dir)) {
// skip the extensions diretory since it has an Info.php file also
if ($subDir == 'Extension') {
$infoFile = $crmFolderDir . "/{$subDir}/" . self::COMPONENT_INFO_CLASS . '.php';
if (file_exists($infoFile)) {
$infoClass = 'CRM_' . $subDir . '_' . self::COMPONENT_INFO_CLASS;
- require_once (str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php');
+ require_once str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php';
$infoObject = new $infoClass(NULL, NULL, NULL);
$components[$infoObject->info['name']] = $infoObject;
unset($infoObject);
return $components;
}
-}
+}