本文整理汇总了PHP中SugarBean::call_custom_logic方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::call_custom_logic方法的具体用法?PHP SugarBean::call_custom_logic怎么用?PHP SugarBean::call_custom_logic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarBean
的用法示例。
在下文中一共展示了SugarBean::call_custom_logic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
//.........这里部分代码省略.........
// update rhs_table set rhs_key = null, relation_column_name = null where rhs_key= this_bean_id
$query = 'UPDATE ' . $_relationship->rhs_table . ' SET ' . $_relationship->rhs_key . "=NULL, date_modified='" . $GLOBALS['timedate']->nowDb() . "'";
if (!empty($_relationship->relationship_role_column) && !empty($_relationship->relationship_role_column_value)) {
$query .= ',' . $_relationship->relationship_role_column . "= NULL ";
$query .= ' WHERE ' . $_relationship->relationship_role_column . "= '" . $_relationship->relationship_role_column_value . "' AND ";
} else {
$query .= ' WHERE ';
}
$query .= $_relationship->rhs_key . "= '" . $id . "' ";
// restrict to one row if related_id is passed.
if (!empty($related_id)) {
$query .= " AND " . $_relationship->rhs_table . ".id='" . $related_id . "'";
}
} else {
// do nothing because the row that stores the relationship keys is being deleted.
// todo log an error message here.
// if this is the case and related_id is passed then log a message asking the user
// to clear the relationship using the bean.
}
}
if ($_relationship->relationship_type == 'many-to-one') {
// do nothing because the row that stores the relationship keys is being deleted.
// todo log an error message here.
// if this is the case and related_id is passed then log a message asking the user
// to clear the relationship using the bean.
}
if ($_relationship->relationship_type == 'many-to-many') {
$use_bean_is_lhs = isset($_REQUEST['ajaxSubpanel']) || $this->_swap_sides !== true;
$query = 'UPDATE ' . $_relationship->join_table . " SET deleted=1, date_modified='" . $GLOBALS['timedate']->nowDb() . "'";
if ($bean_is_lhs && $use_bean_is_lhs) {
if (!empty($this->_relationship->reverse) && ($this->_relationship->reverse == true or $this->_relationship->reverse == 1)) {
if (empty($related_id)) {
$query .= " WHERE (" . $_relationship->join_key_lhs . "= '" . $id . "' or " . $_relationship->join_key_rhs . "='" . $id . "')";
} else {
$query .= " WHERE (" . $_relationship->join_key_lhs . "= '" . $id . "' AND " . $_relationship->join_key_rhs . "='" . $related_id . "') OR (" . $_relationship->join_key_rhs . "='" . $id . "' AND " . $_relationship->join_key_lhs . "='" . $related_id . "')";
}
} else {
if (empty($related_id)) {
$query .= " WHERE " . $_relationship->join_key_lhs . "= '" . $id . "'";
} else {
$query .= " WHERE " . $_relationship->join_key_lhs . "= '" . $id . "' AND " . $_relationship->join_key_rhs . "= '" . $related_id . "'";
}
}
} else {
if (!empty($this->_relationship->reverse) && ($this->_relationship->reverse == true or $this->_relationship->reverse == 1)) {
if (empty($related_id)) {
$query .= " WHERE (" . $_relationship->join_key_rhs . "= '" . $id . "' or " . $_relationship->join_key_lhs . "='" . $id . "')";
} else {
$query .= " WHERE (" . $_relationship->join_key_rhs . "= '" . $id . "' AND " . $_relationship->join_key_lhs . "='" . $related_id . "') OR (" . $_relationship->join_key_lhs . "='" . $id . "' AND " . $_relationship->join_key_rhs . "='" . $related_id . "')";
}
} else {
if (empty($related_id)) {
$query .= " WHERE " . $_relationship->join_key_rhs . "= '" . $id . "'";
} else {
$query .= " WHERE " . $_relationship->join_key_rhs . "= '" . $id . "' AND " . $_relationship->join_key_lhs . "= '" . $related_id . "'";
}
}
if (!empty($_relationship->relationship_role_column) && !empty($_relationship->relationship_role_column_value)) {
$query .= ' AND ' . $_relationship->relationship_role_column . "= '" . $_relationship->relationship_role_column_value . "'";
}
}
}
// if query string is not empty execute it.
if (isset($query)) {
Log::fatal('Link.Delete:Delete Query: ' . $query);
$this->_db->query($query, true);
}
$custom_logic_arguments = [];
$custom_logic_arguments['id'] = $id;
$custom_logic_arguments['related_id'] = $related_id;
$custom_reverse_arguments = [];
$custom_reverse_arguments['related_id'] = $id;
$custom_reverse_arguments['id'] = $related_id;
if ($bean_is_lhs) {
$custom_logic_arguments['module'] = $this->_relationship->lhs_module;
$custom_logic_arguments['related_module'] = $this->_relationship->rhs_module;
$custom_reverse_arguments['module'] = $this->_relationship->lhs_module;
$custom_reverse_arguments['related_module'] = $this->_relationship->rhs_module;
} else {
$custom_logic_arguments['module'] = $this->_relationship->rhs_module;
$custom_logic_arguments['related_module'] = $this->_relationship->lhs_module;
$custom_reverse_arguments['module'] = $this->_relationship->lhs_module;
$custom_reverse_arguments['related_module'] = $this->_relationship->rhs_module;
}
if (empty($this->_bean->id)) {
$this->_bean->retrieve($id);
}
$this->_bean->call_custom_logic('after_relationship_delete', $custom_logic_arguments);
// NOW THE REVERSE WAY SINCE A RELATIONSHIP TAKES TWO
global $beanList;
if (isset($beanList[$custom_logic_arguments['related_module']])) {
$class = $beanList[$custom_logic_arguments['related_module']];
if (!empty($class)) {
/** @var SugarBean $rbean */
$rbean = new $class();
$rbean->retrieve(empty($related_id) ? $id : $related_id);
$rbean->call_custom_logic('after_relationship_delete', $custom_reverse_arguments);
}
}
}
示例2: runQuery
protected function runQuery(ServiceBase $api, array $args, SugarQuery $q, array $options, SugarBean $seed)
{
$seed->call_custom_logic("before_filter", array($q, $options));
if (empty($args['fields'])) {
$fields = array();
} else {
$fields = $options['select'];
}
$queryOptions = array('returnRawRows' => true, 'compensateDistinct' => true);
$fetched = $seed->fetchFromQuery($q, $fields, $queryOptions);
list($beans, $rows, $distinctCompensation) = $this->parseQueryResults($fetched);
$data = array();
$data['next_offset'] = -1;
$i = $distinctCompensation;
foreach ($beans as $bean_id => $bean) {
if ($i == $options['limit']) {
if (count($beans) > $options['limit']) {
unset($beans[$bean_id]);
}
$data['next_offset'] = (int) ($options['limit'] + $options['offset']);
continue;
}
$i++;
$this->populateRelatedFields($bean, $rows[$bean_id]);
}
$data['records'] = $this->formatBeans($api, $args, $beans);
return $data;
}