Merge pull request #19211 from eileenmcnaughton/form_move
[civicrm-core.git] / CRM / Core / Reference / Basic.php
index 797d5832ab9de9784ecce172c8673f0d4866d8d7..ae8684837bad0d3adba5e09bde87966316b3e9b8 100644 (file)
@@ -71,6 +71,14 @@ class CRM_Core_Reference_Basic implements CRM_Core_Reference_Interface {
     return ($this->getTargetTable() === $tableName);
   }
 
+  /**
+   * @return array
+   *   [table_name => EntityName]
+   */
+  public function getTargetEntities(): array {
+    return [$this->targetTable => CRM_Core_DAO_AllCoreTables::getEntityNameForTable($this->targetTable)];
+  }
+
   /**
    * @param CRM_Core_DAO $targetDao
    *
@@ -83,9 +91,9 @@ class CRM_Core_Reference_Basic implements CRM_Core_Reference_Interface {
     if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($this->getReferenceTable(), 'id')) {
       $select = '*';
     }
-    $params = array(
-      1 => array($targetDao->$targetColumn, 'String'),
-    );
+    $params = [
+      1 => [$targetDao->$targetColumn, 'String'],
+    ];
     $sql = <<<EOS
 SELECT {$select}
 FROM {$this->getReferenceTable()}
@@ -104,22 +112,22 @@ EOS;
    */
   public function getReferenceCount($targetDao) {
     $targetColumn = $this->getTargetKey();
-    $params = array(
-      1 => array($targetDao->$targetColumn, 'String'),
-    );
+    $params = [
+      1 => [$targetDao->$targetColumn, 'String'],
+    ];
     $sql = <<<EOS
 SELECT count(*)
 FROM {$this->getReferenceTable()}
 WHERE {$this->getReferenceKey()} = %1
 EOS;
 
-    return array(
-      'name' => implode(':', array('sql', $this->getReferenceTable(), $this->getReferenceKey())),
+    return [
+      'name' => implode(':', ['sql', $this->getReferenceTable(), $this->getReferenceKey()]),
       'type' => get_class($this),
       'table' => $this->getReferenceTable(),
       'key' => $this->getReferenceKey(),
       'count' => CRM_Core_DAO::singleValueQuery($sql, $params),
-    );
+    ];
   }
 
 }