/**
* @deprecated
+ *
* @param array $params
* @return CRM_Core_BAO_Email
+ * @throws CRM_Core_Exception
*/
public static function create($params) {
// FIXME: switch CRM_Core_BAO_Block::create to call writeRecord (once Address, IM, Phone create functions go through it)
// then this can be uncommented:
- // CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
+ CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
return self::writeRecord($params);
}
*/
public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
if (in_array($event->action, ['create', 'edit'])) {
- CRM_Core_BAO_Block::handlePrimary($event->params, get_class());
+ CRM_Core_BAO_Block::handlePrimary($event->params, __CLASS__);
if (!empty($event->params['email'])) {
// lower case email field to optimize queries
/**
* @deprecated
+ *
* @param array $params
* @return CRM_Core_BAO_Email
+ * @throws CRM_Core_Exception
*/
public static function add($params) {
CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
/**
* This class contain function for IM handling
*/
-class CRM_Core_BAO_IM extends CRM_Core_DAO_IM {
+class CRM_Core_BAO_IM extends CRM_Core_DAO_IM implements Civi\Core\HookInterface {
use CRM_Contact_AccessTrait;
/**
- * Create or update IM record.
+ * @deprecated
*
* @param array $params
- *
- * @return \CRM_Core_DAO|\CRM_Core_DAO_IM
- * @throws \CRM_Core_Exception
+ * @return CRM_Core_DAO_IM
+ * @throws CRM_Core_Exception
*/
public static function create($params) {
- CRM_Core_BAO_Block::handlePrimary($params, __CLASS__);
+ CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
return self::writeRecord($params);
}
/**
- * Create or update IM record.
- *
+ * Event fired before modifying an IM.
+ * @param \Civi\Core\Event\PreEvent $event
+ */
+ public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
+ if (in_array($event->action, ['create', 'edit'])) {
+ CRM_Core_BAO_Block::handlePrimary($event->params, __CLASS__);
+ }
+ }
+
+ /**
* @deprecated
*
* @param array $params
- *
- * @return \CRM_Core_DAO|\CRM_Core_DAO_IM
- * @throws \CRM_Core_Exception
+ * @return CRM_Core_DAO_IM
+ * @throws CRM_Core_Exception
*/
public static function add($params) {
- CRM_Core_Error::deprecatedFunctionWarning('use the v4 api');
return self::create($params);
}
/**
* This class contains function for Open Id
*/
-class CRM_Core_BAO_OpenID extends CRM_Core_DAO_OpenID {
+class CRM_Core_BAO_OpenID extends CRM_Core_DAO_OpenID implements Civi\Core\HookInterface {
use CRM_Contact_AccessTrait;
/**
- * Create or update OpenID record.
+ * @deprecated
*
* @param array $params
- *
* @return CRM_Core_DAO_OpenID
- *
- * @throws \CRM_Core_Exception
+ * @throws CRM_Core_Exception
*/
public static function create($params) {
- CRM_Core_BAO_Block::handlePrimary($params, __CLASS__);
+ CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
return self::writeRecord($params);
}
/**
- * Create or update OpenID record.
- *
+ * Event fired before modifying an OpenID.
+ * @param \Civi\Core\Event\PreEvent $event
+ */
+ public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
+ if (in_array($event->action, ['create', 'edit'])) {
+ CRM_Core_BAO_Block::handlePrimary($event->params, __CLASS__);
+ }
+ }
+
+ /**
* @deprecated
*
* @param array $params
- *
- * @return \CRM_Core_DAO|\CRM_Core_DAO_IM
- * @throws \CRM_Core_Exception
+ * @return CRM_Core_DAO_OpenID
+ * @throws CRM_Core_Exception
*/
public static function add($params) {
- CRM_Core_Error::deprecatedFunctionWarning('use the v4 api');
return self::create($params);
}
/**
* Class contains functions for phone.
*/
-class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone {
+class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone implements Civi\Core\HookInterface {
use CRM_Contact_AccessTrait;
/**
- * Create phone object - note that the create function calls 'add' but
- * has more business logic
+ * @deprecated
*
* @param array $params
- *
- * @return \CRM_Core_DAO_Phone
- *
- * @throws \CRM_Core_Exception
+ * @return CRM_Core_DAO_Phone
+ * @throws CRM_Core_Exception
*/
public static function create($params) {
- CRM_Core_BAO_Block::handlePrimary($params, get_class());
+ CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
return self::writeRecord($params);
}
/**
- * Takes an associative array and adds phone.
- *
- * @deprecated use create.
+ * Event fired before modifying a Phone.
+ * @param \Civi\Core\Event\PreEvent $event
+ */
+ public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
+ if (in_array($event->action, ['create', 'edit'])) {
+ CRM_Core_BAO_Block::handlePrimary($event->params, __CLASS__);
+ }
+ }
+
+ /**
+ * @deprecated
*
* @param array $params
- * (reference ) an assoc array of name/value pairs.
- *
- * @return object
- * CRM_Core_BAO_Phone object on success, null otherwise
- *
+ * @return CRM_Core_DAO_Phone
* @throws \CRM_Core_Exception
*/
public static function add($params) {
- CRM_Core_Error::deprecatedFunctionWarning('Use the v4 api');
return self::create($params);
}
use CRM_Contact_AccessTrait;
/**
- * Create or update Website record.
+ * @deprecated
*
* @param array $params
- *
- * @deprecated
* @return CRM_Core_DAO_Website
- * @throws \CRM_Core_Exception
+ * @throws CRM_Core_Exception
*/
public static function create($params) {
CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
}
/**
- * Create website.
+ * @deprecated
*
* @param array $params
- *
* @return CRM_Core_DAO_Website
- * @throws \CRM_Core_Exception
- * @deprecated
+ * @throws CRM_Core_Exception
*/
public static function add($params) {
- CRM_Core_Error::deprecatedFunctionWarning('use apiv4');
+ CRM_Core_Error::deprecatedFunctionWarning('writeRecord');
return self::writeRecord($params);
}
'location_type_id' => 1,
'contact_id' => $contactId,
];
- CRM_Core_BAO_Phone::create($params);
+ CRM_Core_BAO_Phone::writeRecord($params);
$test->assertDBQuery('202-555-1000',
'SELECT phone FROM civicrm_phone WHERE contact_id = %1 ORDER BY id DESC LIMIT 1',
[1 => [$contactId, 'Integer']]
public function testAdd() {
$contactId = $this->individualCreate();
- $params = [];
$params = [
'phone' => '(415) 222-1011 x 221',
'is_primary' => 1,
'contact_id' => $contactId,
];
- CRM_Core_BAO_Phone::create($params);
+ CRM_Core_BAO_Phone::writeRecord($params);
$phoneId = $this->assertDBNotNull('CRM_Core_DAO_Phone', $contactId, 'id', 'contact_id',
'Database check for created phone record.'
'phone' => '(415) 222-5432',
];
- CRM_Core_BAO_Phone::create($params);
+ CRM_Core_BAO_Phone::writeRecord($params);
$this->assertDBCompareValue('CRM_Core_DAO_Phone', $phoneId, 'phone', 'id', '(415) 222-5432',
"Check if phone field has expected value in updated record ( civicrm_phone.id={$phoneId} )."
$this->contactDelete($contactId);
}
- /**
- * AllEntityPhones() method - get all Phones for a location block, with primary Phone first
- * @todo FIXME: Fixing this test requires add helper functions in CiviTest to create location block and phone and link them to an event. Punting to 3.1 cycle. DGG
- */
- public function SKIPPED_testAllEntityPhones() {
- }
-
}