Created
February 22, 2019 19:52
-
-
Save dmitryburov/c0623ccaedd6115c744d703f194b6c2c to your computer and use it in GitHub Desktop.
Реализация своих сущностей в Соглашениях. Результат - http://joxi.ru/V2VZwx1TdE7gP2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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