/** * takes an associative array and creates a entityTag object * * the function extract all the params it needs to initialize the create a * group object. the params array could contain additional unused name/value * pairs * * @param array $params (reference ) an assoc array of name/value pairs * * @return object CRM_Core_BAO_EntityTag object * @access public * @static */ static function add(&$params) { $dataExists = self::dataExists($params); if (!$dataExists) { return null; } $entityTag = new CRM_Core_BAO_EntityTag(); $entityTag->copyValues($params); // dont save the object if it already exists, CRM-1276 if (!$entityTag->find(true)) { $entityTag->save(); } return $entityTag; }
/** * Takes an associative array and creates a entityTag object. * * the function extract all the params it needs to initialize the create a * group object. the params array could contain additional unused name/value * pairs * * @param array $params * (reference ) an assoc array of name/value pairs. * * @return CRM_Core_BAO_EntityTag */ public static function add(&$params) { $dataExists = self::dataExists($params); if (!$dataExists) { return NULL; } $entityTag = new CRM_Core_BAO_EntityTag(); $entityTag->copyValues($params); // dont save the object if it already exists, CRM-1276 if (!$entityTag->find(TRUE)) { $entityTag->save(); //invoke post hook on entityTag // we are using this format to keep things consistent between the single and bulk operations // so a bit different from other post hooks $object = array(0 => array(0 => $params['entity_id']), 1 => $params['entity_table']); CRM_Utils_Hook::post('create', 'EntityTag', $params['tag_id'], $object); } return $entityTag; }
/** * Function to delete the tag for a contact * * @param array $params (reference ) an assoc array of name/value pairs * * @return object CRM_Core_BAO_EntityTag object * @access public * @static * */ static function del(&$params) { $entityTag = new CRM_Core_BAO_EntityTag(); $entityTag->copyValues($params); if ($entityTag->find(TRUE)) { $entityTag->delete(); //invoke post hook on entityTag $object = array(0 => array(0 => $params['entity_id']), 1 => $params['entity_table']); CRM_Utils_Hook::post('delete', 'EntityTag', $params['tag_id'], $object); } }