+++ /dev/null
-<?php
-
-/**
- * Class CRM_Contact_DAO_Factory
- */
-class CRM_Contact_DAO_Factory {
-
- public static $_classes = [
- 'Address' => 'data',
- 'Contact' => 'data',
- 'Email' => 'data',
- 'Household' => 'data',
- 'IM' => 'data',
- 'Individual' => 'data',
- 'Location' => 'data',
- 'LocationType' => 'data',
- 'Organization' => 'data',
- 'Phone' => 'data',
- 'Relationship' => 'data',
- ];
-
- public static $_prefix = [
- 'business' => 'CRM_Contact_BAO_',
- 'data' => 'CRM_Contact_DAO_',
- ];
-
- /**
- * @param string $className
- *
- * @return mixed
- */
- public static function create($className) {
- $type = self::$_classes[$className] ?? NULL;
- if (!$type) {
- return CRM_Core_DAO_Factory::create($className);
- }
-
- $class = self::$_prefix[$type] . $className;
-
- if ($type == 'singleton') {
- $newObj = $class::singleton();
- }
- else {
- // this is either 'business' or 'data'
- $newObj = new $class();
- }
-
- return $newObj;
- }
-
-}
* @var array
*/
public static $_testEntitiesToSkip = [];
- /**
- * The factory class for this application.
- * @var object
- */
- public static $_factory = NULL;
/**
* https://issues.civicrm.org/jira/browse/CRM-17748
if (defined('CIVICRM_DAO_DEBUG')) {
self::DebugLevel(CIVICRM_DAO_DEBUG);
}
- $factory = new CRM_Contact_DAO_Factory();
- CRM_Core_DAO::setFactory($factory);
CRM_Core_DAO::executeQuery('SET NAMES utf8mb4');
CRM_Core_DAO::executeQuery('SET @uniqueID = %1', [1 => [CRM_Utils_Request::id(), 'String']]);
}
return $ret;
}
- /**
- * Static function to set the factory instance for this class.
- *
- * @param object $factory
- * The factory application object.
- */
- public static function setFactory(&$factory) {
- self::$_factory = &$factory;
- }
-
- /**
- * Factory method to instantiate a new object from a table name.
- *
- * @param string $table
- * @return \DataObject|\PEAR_Error
- */
- public function factory($table = '') {
- if (!isset(self::$_factory)) {
- return parent::factory($table);
- }
-
- return self::$_factory->create($table);
- }
-
/**
* Initialization for all DAO objects. Since we access DB_DO programatically
* we need to set the links manually.