Skip to content

Instantly share code, notes, and snippets.

@dmitryburov
Created February 22, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitryburov/c0623ccaedd6115c744d703f194b6c2c to your computer and use it in GitHub Desktop.
Save dmitryburov/c0623ccaedd6115c744d703f194b6c2c to your computer and use it in GitHub Desktop.
Реализация своих сущностей в Соглашениях. Результат - http://joxi.ru/V2VZwx1TdE7gP2
<?php
namespace Burov\Handlers;
/**
* Class ConsentProviders
* @package Burov\Handlers
*
* В данном примере показано добавление своих сущностей в Соглашениях (\Bitrix\Main\UserConsent)
*
* Добавление события для служб (в init.php, например)
* \Bitrix\Main\EventManager::getInstance()->addEventHandler('main', 'OnUserConsentProviderList', array('\\Burov\\Handlers\\ConsentProviders', 'OnUserConsentProviderSender');
*
* И регистрируем наш класс
* \Bitrix\Main\Loader::registerAutoLoadClasses(null, array('\\Burov\\Handlers\\ConsentProviders' => '/bitrix/php_interface/classes/consent_providers.php'));
*/
class ConsentProviders
{
function OnUserConsentProviderSender(\Bitrix\Main\Event $event)
{
$params = array(
// пользователи-подписчики
array(
"CODE" => "burov/subs",
"NAME" => "Element",
"DATA" => function($id)
{
return array(
'NAME' => "Подписчик #{$id}",
'URL' => str_replace('%id%', $id, '/bitrix/admin/burov_dev_subscribers.php?ID=%id%'),
);
}
),
// пользователи-партнеры
array(
"CODE" => "burov/partners",
"NAME" => "Element",
"DATA" => function($id)
{
return array(
'NAME' => "Партнер #{$id}",
'URL' => str_replace('%id%', $id, '/bitrix/admin/burov_partner_users.php?ID=%id%'),
);
}
)
);
$result = new \Bitrix\Main\EventResult(\Bitrix\Main\EventResult::SUCCESS, $params, null);
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment