INFRA-132 - CRM/Core - phpcbf
[civicrm-core.git] / CRM / Core / Component / Info.php
index 24bef08f9d9a54b18c75da9f64ec6a4e922f136c..17f128817264fdc7c74190cd1681475b03605dfb 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 
 abstract class CRM_Core_Component_Info {
 
-  /*
-     * Name of the class (minus component namespace path)
-     * of the component invocation class'es name.
-     */
-  CONST COMPONENT_INVOKE_CLASS = 'Invoke';
+  /**
+   * Name of the class (minus component namespace path)
+   * of the component invocation class'es name.
+   */
+  const COMPONENT_INVOKE_CLASS = 'Invoke';
 
-  /*
-     * Name of the class (minus component namespace path)
-     * of the component configuration class'es name.
-     */
-  CONST COMPONENT_CONFIG_CLASS = 'Config';
+  /**
+   * Name of the class (minus component namespace path)
+   * of the component configuration class'es name.
+   */
+  const COMPONENT_CONFIG_CLASS = 'Config';
 
-  /*
-     * Name of the class (minus component namespace path)
-     * of the component BAO Query class'es name.
-     */
-  CONST COMPONENT_BAO_QUERY_CLASS = 'BAO_Query';
+  /**
+   * Name of the class (minus component namespace path)
+   * of the component BAO Query class'es name.
+   */
+  const COMPONENT_BAO_QUERY_CLASS = 'BAO_Query';
 
-  /*
-     * Name of the class (minus component namespace path)
-     * of the component user dashboard plugin.
-     */
-  CONST COMPONENT_USERDASHBOARD_CLASS = 'Page_UserDashboard';
+  /**
+   * Name of the class (minus component namespace path)
+   * of the component user dashboard plugin.
+   */
+  const COMPONENT_USERDASHBOARD_CLASS = 'Page_UserDashboard';
 
-  /*
-     * Name of the class (minus component namespace path)
-     * of the component tab offered to contact record view.
-     */
-  CONST COMPONENT_TAB_CLASS = 'Page_Tab';
+  /**
+   * Name of the class (minus component namespace path)
+   * of the component tab offered to contact record view.
+   */
+  const COMPONENT_TAB_CLASS = 'Page_Tab';
 
-  /*
-     * Name of the class (minus component namespace path)
-     * of the component tab offered to contact record view.
-     */
-  CONST COMPONENT_ADVSEARCHPANE_CLASS = 'Form_Search_AdvancedSearchPane';
+  /**
+   * Name of the class (minus component namespace path)
+   * of the component tab offered to contact record view.
+   */
+  const COMPONENT_ADVSEARCHPANE_CLASS = 'Form_Search_AdvancedSearchPane';
 
-  /*
-     * Name of the directory (assumed in component directory)
-     * where xml resources used by this component live.
-     */
-  CONST COMPONENT_XML_RESOURCES = 'xml';
+  /**
+   * Name of the directory (assumed in component directory)
+   * where xml resources used by this component live.
+   */
+  const COMPONENT_XML_RESOURCES = 'xml';
 
-  /*
-     * Name of the directory (assumed in xml resources path)
-     * containing component menu definition XML file names.
-     */
-  CONST COMPONENT_MENU_XML = 'Menu';
+  /**
+   * Name of the directory (assumed in xml resources path)
+   * containing component menu definition XML file names.
+   */
+  const COMPONENT_MENU_XML = 'Menu';
 
-  /*
+  /**
    * Stores component information.
    * @var array component settings as key/value pairs
    */
@@ -97,15 +97,12 @@ abstract class CRM_Core_Component_Info {
    */
   protected $keyword;
 
-  /*
-   * Class constructor, sets name and namespace (those are stored
-   * in the component registry (database) and no need to duplicate
-   * them here, as well as populates the info variable.
-   *
-   * @param string $name name of the component
-   * @param string $namespace namespace prefix for component's files
-   * @access public
-   *
+  /**
+   * @param string $name
+   *   Name of the component.
+   * @param string $namespace
+   *   Namespace prefix for component's files.
+   * @param int $componentID
    */
   public function __construct($name, $namespace, $componentID) {
     $this->name        = $name;
@@ -115,13 +112,22 @@ abstract class CRM_Core_Component_Info {
     $this->info['url'] = $this->getKeyword();
   }
 
+  /**
+   * EXPERIMENTAL: Get a list of AngularJS modules
+   *
+   * @return array list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
+   * @see CRM_Utils_Hook::angularModules
+   */
+  public function getAngularModules() {
+    return array();
+  }
+
   /**
    * Provides base information about the component.
    * Needs to be implemented in component's information
    * class.
    *
    * @return array collection of required component settings
-   * @access public
    *
    */
   abstract public function getInfo();
@@ -157,17 +163,29 @@ abstract class CRM_Core_Component_Info {
    * @param bool $getAllUnconditionally
    *
    * @return array|null collection of permissions, null if none
-   * @access public
    */
   abstract public function getPermissions($getAllUnconditionally = FALSE);
 
+  /**
+   * Determine how many other records refer to a given record
+   *
+   * @param CRM_Core_DAO $dao
+   *   The item for which we want a reference count.
+   * @return array each item in the array is an array with keys:
+   *   - name: string, eg "sql:civicrm_email:contact_id"
+   *   - type: string, eg "sql"
+   *   - count: int, eg "5" if there are 5 email addresses that refer to $dao
+   */
+  public function getReferenceCounts($dao) {
+    return array();
+  }
+
   /**
    * Provides information about user dashboard element
    * offered by this component.
    *
    * @return array|null collection of required dashboard settings,
    *                    null if no element offered
-   * @access public
    *
    */
   abstract public function getUserDashboardElement();
@@ -178,7 +196,6 @@ abstract class CRM_Core_Component_Info {
    *
    * @return array|null collection of required dashboard settings,
    *                    null if no element offered
-   * @access public
    *
    */
   abstract public function registerTab();
@@ -189,7 +206,6 @@ abstract class CRM_Core_Component_Info {
    *
    * @return array|null collection of required pane settings,
    *                    null if no element offered
-   * @access public
    *
    */
   abstract public function registerAdvancedSearchPane();
@@ -201,7 +217,6 @@ abstract class CRM_Core_Component_Info {
    * class.
    *
    * @return array|null collection of activity types
-   * @access public
    *
    */
   abstract public function getActivityTypes();
@@ -211,7 +226,6 @@ abstract class CRM_Core_Component_Info {
    * marked as enabled in configuration.
    *
    * @return boolean true if component is enabled, false if not
-   * @access public
    *
    */
   public function isEnabled() {
@@ -226,7 +240,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's configuration object.
    *
    * @return mixed component's configuration object
-   * @access public
    *
    */
   public function getConfigObject() {
@@ -237,7 +250,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's menu definition object.
    *
    * @return mixed component's menu definition object
-   * @access public
    *
    */
   public function getMenuObject() {
@@ -248,7 +260,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's invocation object.
    *
    * @return mixed component's invocation object
-   * @access public
    *
    */
   public function getInvokeObject() {
@@ -259,7 +270,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's BAO Query object.
    *
    * @return mixed component's BAO Query object
-   * @access public
    *
    */
   public function getBAOQueryObject() {
@@ -269,7 +279,6 @@ abstract class CRM_Core_Component_Info {
   /**
    * Builds advanced search form's component specific pane.
    *
-   * @access public
    *
    */
   public function buildAdvancedSearchPaneForm(&$form) {
@@ -281,7 +290,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's user dashboard page object.
    *
    * @return mixed component's User Dashboard applet object
-   * @access public
    *
    */
   public function getUserDashboardObject() {
@@ -292,7 +300,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's contact record tab object.
    *
    * @return mixed component's contact record tab object
-   * @access public
    *
    */
   public function getTabObject() {
@@ -303,7 +310,6 @@ abstract class CRM_Core_Component_Info {
    * Provides component's advanced search pane's template path.
    *
    * @return string component's advanced search pane's template path
-   * @access public
    *
    */
   public function getAdvancedSearchPaneTemplatePath() {
@@ -315,7 +321,6 @@ abstract class CRM_Core_Component_Info {
    * Provides information whether given component uses system wide search.
    *
    * @return boolean true if component needs search integration
-   * @access public
    *
    */
   public function usesSearch() {
@@ -326,7 +331,6 @@ abstract class CRM_Core_Component_Info {
    * Provides the xml menu files
    *
    * @return array array of menu files
-   * @access public
    *
    */
   public function menuFiles() {
@@ -339,7 +343,6 @@ abstract class CRM_Core_Component_Info {
    * FIXME: accessed from beyond component infrastructure.
    *
    * @return string component keyword
-   * @access public
    *
    */
   public function getKeyword() {
@@ -350,7 +353,6 @@ abstract class CRM_Core_Component_Info {
    * Helper for figuring out menu XML file location.
    *
    * @return mixed component's element as class instance
-   * @access private
    *
    */
   private function _getMenuXMLPath() {
@@ -365,12 +367,10 @@ abstract class CRM_Core_Component_Info {
    * @param $cl
    *
    * @return mixed component's element as class instance
-   * @access private
    */
   private function _instantiate($cl) {
     $className = $this->namespace . '_' . $cl;
-    require_once (str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php');
+    require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
     return new $className();
   }
 }
-