本文整理汇总了PHP中Bitrix\Main\Event::getParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getParameters方法的具体用法?PHP Event::getParameters怎么用?PHP Event::getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Event
的用法示例。
在下文中一共展示了Event::getParameters方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onExecuteStartWriting
function onExecuteStartWriting(\Bitrix\Main\Event $event)
{
$parameters = $event->getParameters();
$userId = $parameters[0];
$dialogId = $parameters[1] . $parameters[2];
if ($userId > 0) {
if (!\Bitrix\Main\Loader::includeModule('pull')) {
return;
}
\CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS');
if (intval($dialogId) > 0) {
\CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
} elseif (substr($dialogId, 0, 4) == 'chat') {
$chatId = substr($dialogId, 4);
$arRelation = \CIMChat::GetRelationById($chatId);
unset($arRelation[$userId]);
$pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId));
\CPullStack::AddByUsers(array_keys($arRelation), $pullMessage);
$orm = \Bitrix\Im\ChatTable::getById($chatId);
$chat = $orm->fetch();
if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
\CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage);
}
}
}
}
示例2: handleEvent
/**
* @param \Bitrix\Main\Event $event
* @return mixed
*/
public static function handleEvent(Event $event)
{
$eventData = $event->getParameters();
$eventData = $eventData[0];
$eventName = $eventData['EVENT_NAME'];
$fields = is_array($eventData['C_FIELDS']) ? $eventData['C_FIELDS'] : array();
if (static::isPreventable($eventName, $fields)) {
// error
$result = new EventResult(EventResult::ERROR);
} else {
// success
$result = new EventResult(EventResult::SUCCESS);
}
return $result;
}
示例3: onStartUserReplication
public function onStartUserReplication(\Bitrix\Main\Event $event)
{
$parameters = $event->getParameters();
$userId = $parameters[0];
$domain = $parameters[2];
$domainId = getNameByDomain($domain);
if (!$domainId) {
return;
}
$mapper = \Bitrix\Replica\Mapper::getInstance();
$map = $mapper->getByPrimaryValue("b_user.ID", false, $userId);
if (!$map) {
return;
}
$guid = key($map);
$event = array("operation" => "im_status_bind", "guid" => $guid);
\Bitrix\Replica\Log\Client::getInstance()->write(array($domainId), $event);
\Bitrix\Replica\Mapper::getInstance()->add("b_im_status.USER_ID", $userId, $domainId, $event["guid"]);
}
示例4: onExecuteStartWriting
function onExecuteStartWriting(\Bitrix\Main\Event $event)
{
$parameters = $event->getParameters();
$userId = $parameters[0];
$dialogId = $parameters[1] . $parameters[2];
if ($userId > 0) {
if (!\Bitrix\Main\Loader::includeModule('pull')) {
return;
}
\CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS');
if (intval($dialogId) > 0) {
\CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
} elseif (substr($dialogId, 0, 4) == 'chat') {
$arRelation = \CIMChat::GetRelationById(substr($dialogId, 4));
foreach ($arRelation as $rel) {
if ($rel['USER_ID'] == $userId) {
continue;
}
\CPullStack::AddByUser($rel['USER_ID'], array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
}
}
}
}
示例5: onBasketItemChange
/**
* @param Main\Event $event
*
* @return Main\EventResult
*/
public static function onBasketItemChange(Main\Event $event)
{
$parameters = $event->getParameters();
/** @var Sale\BasketItem $basketItem */
$basketItem = $parameters[0];
if (!$basketItem instanceof Sale\BasketItem) {
return new Main\EventResult(Main\EventResult::ERROR, new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_BASKET_ITEM_CHANGE_WRONG_BASKET'), 'SALE_EVENT_COMPATIBILITY_BASKET_ITEM_CHANGE_WRONG_BASKET'), 'sale');
}
$currentBasketFields = $basketFields = BasketCompatibility::convertBasketItemToArray($basketItem);
if ($basketItem->getId() == 0) {
foreach (GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_BASKET_ITEM_ADD, true) as $oldEvent) {
if (ExecuteModuleEventEx($oldEvent, array(&$basketFields)) === false) {
continue;
}
}
} else {
foreach (GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_BASKET_ITEM_UPDATE, true) as $oldEvent) {
if (ExecuteModuleEventEx($oldEvent, array($basketItem->getId(), &$basketFields)) === false) {
continue;
}
}
}
foreach ($currentBasketFields as $key => $value) {
if (isset($basketFields[$key]) && $basketFields[$key] != $value) {
$basketItem->setFieldNoDemand($key, $basketFields[$key]);
}
}
return new Main\EventResult(Main\EventResult::SUCCESS, null, 'sale');
}
示例6: sendToEventHandler
private function sendToEventHandler(array $handler, Event $event)
{
try {
$result = true;
$event->addDebugInfo($handler);
if (isset($handler["TO_MODULE_ID"]) && !empty($handler["TO_MODULE_ID"]) && $handler["TO_MODULE_ID"] != 'main') {
$result = Loader::includeModule($handler["TO_MODULE_ID"]);
} elseif (isset($handler["TO_PATH"]) && !empty($handler["TO_PATH"])) {
$path = ltrim($handler["TO_PATH"], "/");
if (($path = Loader::getLocal($path)) !== false) {
$result = (include_once $path);
}
} elseif (isset($handler["FULL_PATH"]) && !empty($handler["FULL_PATH"]) && IO\File::isFileExists($handler["FULL_PATH"])) {
$result = (include_once $handler["FULL_PATH"]);
}
$event->addDebugInfo($result);
if (isset($handler["TO_METHOD_ARG"]) && is_array($handler["TO_METHOD_ARG"]) && !empty($handler["TO_METHOD_ARG"])) {
$args = $handler["TO_METHOD_ARG"];
} else {
$args = array();
}
if ($handler["VERSION"] > 1) {
$args[] = $event;
} else {
$args = array_merge($args, array_values($event->getParameters()));
}
$callback = null;
if (isset($handler["CALLBACK"])) {
$callback = $handler["CALLBACK"];
} elseif (!empty($handler["TO_CLASS"]) && !empty($handler["TO_METHOD"]) && class_exists($handler["TO_CLASS"])) {
$callback = array($handler["TO_CLASS"], $handler["TO_METHOD"]);
}
if ($callback != null) {
$result = call_user_func_array($callback, $args);
}
if ($result != null && !$result instanceof EventResult) {
$result = new EventResult(EventResult::UNDEFINED, $result, $handler["TO_MODULE_ID"]);
}
$event->addDebugInfo($result);
if ($result != null) {
$event->addResult($result);
}
} catch (\Exception $ex) {
if ($event->isDebugOn()) {
$event->addException($ex);
} else {
throw $ex;
}
}
}
示例7: onSaleBeforeStatusOrderChange
/**
* @param Main\Event $event
*
* @return Main\EventResult
* @throws Main\ObjectNotFoundException
*/
public static function onSaleBeforeStatusOrderChange(Main\Event $event)
{
$parameters = $event->getParameters();
/** @var Sale\Order $basketItem */
$order = $parameters['ENTITY'];
$value = $parameters['VALUE'];
$oldValue = $parameters['OLD_VALUE'];
if (!$order instanceof Sale\Order) {
return new Main\EventResult(Main\EventResult::ERROR, new Sale\ResultError(Main\Localization\Loc::getMessage('SALE_EVENT_COMPATIBILITY_BEFORE_ORDER_STATUS_CHANGE_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_BEFORE_ORDER_STATUS_CHANGE_WRONG_ORDER'), 'sale');
}
foreach (GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_BEFORE_ORDER_STATUS_CHANGE, true) as $oldEvent) {
ExecuteModuleEventEx($oldEvent, array($order->getId(), $value));
}
return new Main\EventResult(Main\EventResult::SUCCESS, null, 'sale');
}