Подписка amoCRM на получение Web Hook от B2BFamily

@return array
768015
public function subscribe()
    {
        if ($this->apikey === null) {
            $this->login();
        }

        return $this->request(self::METHOD_PUT, '/subscribers/add', [
            'apikey' => $this->apikey,
            'path' => 'http://b2bf.cloudapp.net/post/',
        ]);
    }
712861
public function behaviors() {

		return [
			'rbac' => [
				'class' => Yii::$app->core->getRbacFilterClass(),
				'actions' => [
					// Avatar
					'assign-avatar' => [ 'permission' => $this->crudPermission ],
					'clear-avatar' => [ 'permission' => $this->crudPermission ],
					// Banner
					'assign-banner' => [ 'permission' => $this->crudPermission ],
					'clear-banner' => [ 'permission' => $this->crudPermission ],
					// Model
					'bulk' => [ 'permission' => $this->crudPermission ],
					'generic' => [ 'permission' => $this->crudPermission ],
					'delete' => [ 'permission' => $this->crudPermission ]
				]
			],
			'verbs' => [
				'class' => VerbFilter::class,
				'actions' => [
					// Avatar
					'assign-avatar' => [ 'post' ],
					'clear-avatar' => [ 'post' ],
					// Banner
					'assign-banner' => [ 'post' ],
					'clear-banner' => [ 'post' ],
					// Model
					'bulk' => [ 'post' ],
					'generic' => [ 'post' ],
					'delete' => [ 'post' ]
				]
			]
		];
	}
1352967
public function getFunctions () {
		return [
			//==============================================
			//base
			//==============================================
			new \Twig_Function('asset',					[$this, 'asset']),
			new \Twig_Function('asset_common',			[$this, 'assetCommon']),
			new \Twig_Function('asset_cdn',				[$this, 'assetCdn']),
			new \Twig_Function('make_url',				[$this, 'makeUrl']),
			new \Twig_Function('make_domain_url',		[$this, 'makeDomainUrl']),
			new \Twig_Function('make_force_domain_url',	[$this, 'makeForceDomainUrl']),
			new \Twig_Function('current_url',			[$this, 'currentUrl']),
			new \Twig_Function('current_full_url',		[$this, 'currentFullUrl']),
			new \Twig_Function('filter',				[$this, 'filter'], ['needs_environment' => true]),
			new \Twig_Function('replace_sub_domain',	[$this, 'replaceSubDomain']),
			new \Twig_Function('action_switch',			[$this, 'actionSwitch']),

			//==============================================
			//var type
			//==============================================
			new \Twig_Function('var_dump',		'var_dump'),

			new \Twig_Function('empty',			[$this, 'isEmpty']),

			new \Twig_Function('adjust_array',	'\ickx\fw2\vartype\arrays\Arrays::AdjustArray'),
			new \Twig_Function('array_unshift',	[$this, 'arrayUnshift']),
			new \Twig_Function('array_push',	[$this, 'arrayPush']),
			new \Twig_Function('array_add',		[$this, 'arrayAdd']),
			new \Twig_Function('array_merge',	[$this, 'merge']),
			new \Twig_Function('implode',		'implode'),
			new \Twig_Function('explode',		'explode'),
			new \Twig_Function('array_filter',	'array_filter'),

			new \Twig_Function('merge',			[$this, 'merge']),

			new \Twig_Function('late_array_bind',	[$this, 'lateArrayBind']),

			//==============================================
			//Native Functions
			//==============================================
			new \Twig_Function('time',	'time'),
			new \Twig_Function('date',	'date'),

			//==============================================
			//disp support
			//==============================================
			new \Twig_Function('adjust',		[$this, 'adjust']),
			new \Twig_Function('params_adjust',	[$this, 'paramsAdjust']),
			new \Twig_Function('sprintf',		'sprintf'),
			new \Twig_Function('has_validator',	[$this, 'hasValidator']),
			new \Twig_Function('elvis',			[$this, 'elvis']),
			new \Twig_Function('switch',		[$this, 'elvis']),

			new \Twig_Function('make_id',		[$this, 'makeId']),

			new \Twig_Function('json_encode',	[$this, 'jsonEncode']),
			new \Twig_Function('json_decode',	[$this, 'jsonDecode']),

			//==============================================
			//form data set
			//==============================================
			//form status
			new \Twig_Function('form_open',				[$this, 'formOpen']),
			new \Twig_Function('form_status',			[$this, 'formStatus']),
			new \Twig_Function('is_post_form',			[$this, 'isPostForm']),
			new \Twig_Function('form_close',			[$this, 'formClose']),
			//file upload
			new \Twig_Function('file_upload',			[$this, 'fileUpload']),
			//CURRENT REQUEST data
			new \Twig_Function('exist_request_data',	[$this, 'existRequestData']),
			new \Twig_Function('request_data',			[$this, 'getRequestData']),
			new \Twig_Function('request_data_set',		[$this, 'getRequestDataSet']),
			//GET parameter
			new \Twig_Function('exist_parameter',		[$this, 'existParameter']),
			new \Twig_Function('parameter',				[$this, 'getParameter']),
			new \Twig_Function('parameters',			[$this, 'getParameters']),
			//POST data
			new \Twig_Function('exist_form_data',		[$this, 'existFormData']),
			new \Twig_Function('form_data',				[$this, 'getFormData']),
			new \Twig_Function('form_data_set',			[$this, 'getFormDataSet']),
			//message
			//error
			new \Twig_Function('exist_errors',			[$this, 'existError']),
			new \Twig_Function('errors',				[$this, 'getError']),
			new \Twig_Function('errors_set',			[$this, 'getErrorSet']),
			//warn
			new \Twig_Function('exist_warns',			[$this, 'existWarn']),
			new \Twig_Function('warns',					[$this, 'getWarn']),
			new \Twig_Function('warns_set',				[$this, 'getWarnSet']),
			//info
			new \Twig_Function('exist_infos',			[$this, 'existInfo']),
			new \Twig_Function('infos',					[$this, 'getInfo']),
			new \Twig_Function('infos_set',				[$this, 'getInfoSet']),
		];
	}
223654
public function getModularInfo() : array
    {
        return [
            static::NAME        => $this->getModularName(),
            static::VERSION     => $this->getModularVersion(),
            static::URI         => $this->getModularUri(),
            static::AUTHOR      => $this->getModularAuthor(),
            static::AUTHOR_URI  => $this->getModularAuthorUri(),
            static::DESCRIPTION => $this->getModularDescription(),
            static::CLASS_NAME  => get_class($this),
            static::FILE_PATH   => $this->getModularRealPath(),
            static::SELECTOR    => $this->getModularNameSelector(),
        ];
    }
685429
protected function getActivePlugins(): array
    {
        if ($this->activePlugins) {
            return $this->activePlugins;
        }

        $this->activePlugins = (array) get_option('active_mu_plugins', []);

        return $this->activePlugins;
    }
138764
protected function getItemsFromDatabase()
    {
        $brandId = $this->repository->make('antares.memory')->make('primary')->get('brand.default');
        if (auth()->guest()) {
            return [];
        }
        $roleId = auth()->user()->roles->first()->id;
        $items  = $this->resolver()->where(['brand_id' => $brandId, 'role_id' => $roleId])->get();
        $return = [];

        foreach ($items as $item) {
            $form       = $item->form;
            $attributes = array_merge($item->getAttributes(), ['action_id' => $form->action_id, 'name' => $form->name]);
            array_push($return, $attributes);
        }
        return $return;
    }
1144395
public function getAttributes(): array
    {
        $attributes = [];
        $attributes['message_id'] = $this->messageId;
        if ($this->blockId) {
            $attributes['block'] = $this->blockId;
        }
        return $attributes;
    }
1127423
public function behaviors() {

        return [
            'rbac' => [
                'class' => Yii::$app->cmgCore->getRbacFilterClass(),
                'actions' => [
	                'invite' => [ 'permission' => CoreGlobal::PERM_USER ],
	                'activate' => [ 'permission' => CoreGlobal::PERM_USER ],
	                'deactivate' => [ 'permission' => CoreGlobal::PERM_USER ],
	                'join' => [ 'permission' => CoreGlobal::PERM_USER ],
	                'update-role' => [ 'permission' => CoreGlobal::PERM_USER ],
	                'delete' => [ 'permission' => CoreGlobal::PERM_USER ]
                ]
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'invite' => [ 'post' ],
                    'activate' => [ 'post' ],
                    'deactivate' => [ 'post' ],
                    'join' => [ 'post' ],
                    'update-role' => [ 'post' ],
                    'delete' => [ 'post' ]
                ]
            ]
        ];
    }
62593
public function listHooks(): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/hooks',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()));
    }
403765
public function getInputFilterSpecification(): array
    {
        return [
            'api_key' => [
                'required' => false,
                'filters' => [
                    ['name' => StripTags::class],
                    ['name' => StringTrim::class],
                ],
                'validators' => [
                    ['name' => StringLength::class, 'options' => [
                        'encoding' => 'UTF-8',
                        'min'      => 10,
                        'max'      => 20,
                    ]],
                    ['name' => Alnum::class],
                ],
            ],
            'blog' => [
                'required' => false,
                'filters' => [
                    ['name' => StripTags::class],
                    ['name' => StringTrim::class],
                ],
                'validators' => [
                    ['name' => StringLength::class, 'options' => [
                        'encoding' => 'UTF-8',
                        'min'      => 10,
                        'max'      => 255,
                    ]],
                    ['name' => Uri::class, 'options' => [
                        'uriHandler'    => Http::class,
                        'allowRelative' => false,
                    ]],
                ],
            ],
        ];
    }
480183
public function getFilters(): array
    {
        return [
            new TwigFilter('serialize', 'serialize'),
            new TwigFilter('unserialize', 'unserialize'),
            new TwigFilter('md5', 'md5'),
            new TwigFilter('base64_encode', 'base64_encode'),
            new TwigFilter('base64_decode', 'base64_decode'),
            new TwigFilter('nl2br', 'nl2br'),
            new TwigFilter('string', function ($str) {
                return (string)$str;
            }),
        ];
    }
761305
public function GetDependsObjects()
    {
        return array(
            'PaymentType' => array(
                '_property_name' => 'PaymentDetails',
                PayInPaymentType::Card => '\MangoPay\PayInPaymentDetailsCard',
                PayInPaymentType::Preauthorized => '\MangoPay\PayInPaymentDetailsPreAuthorized',
                PayInPaymentType::BankWire => '\MangoPay\PayInPaymentDetailsBankWire',
                PayInPaymentType::DirectDebit => '\MangoPay\PayInPaymentDetailsDirectDebit',
                PayInPaymentType::DirectDebitDirect => '\MangoPay\PayInPaymentDetailsDirectDebitDirect',
                PayInPaymentType::PayPal => '\MangoPay\PayInPaymentDetailsPaypal',
                // ...and more in future...
            ),
            'ExecutionType' => array(
                '_property_name' => 'ExecutionDetails',
                PayInExecutionType::Web => '\MangoPay\PayInExecutionDetailsWeb',
                PayInExecutionType::Direct => '\MangoPay\PayInExecutionDetailsDirect',
                PayInExecutionType::ExternalInstruction => '\MangoPay\PayInExecutionDetailsExternalInstruction',                
                // ...and more in future...
            )
        );
    }
50826
public static function getSubscribedEvents()
    {
        return [
            ContaoEvents::CONTROLLER_ADD_TO_URL                => 'handleAddToUrl',
            ContaoEvents::CONTROLLER_ADD_ENCLOSURE_TO_TEMPLATE => 'handleAddEnclosureToTemplate',
            ContaoEvents::CONTROLLER_ADD_IMAGE_TO_TEMPLATE     => 'handleAddImageToTemplate',
            ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL     => 'handleGenerateFrontendUrl',
            ContaoEvents::CONTROLLER_GET_ARTICLE               => 'handleGetArticle',
            ContaoEvents::CONTROLLER_GET_CONTENT_ELEMENT       => 'handleGetContentElement',
            ContaoEvents::CONTROLLER_GET_PAGE_DETAILS          => 'handleGetPageDetails',
            ContaoEvents::CONTROLLER_GET_TEMPLATE_GROUP        => 'handleGetTemplateGroup',
            ContaoEvents::CONTROLLER_LOAD_DATA_CONTAINER       => 'handleLoadDataContainer',
            ContaoEvents::CONTROLLER_REDIRECT                  => 'handleRedirect',
            ContaoEvents::CONTROLLER_RELOAD                    => 'handleReload',
            ContaoEvents::CONTROLLER_REPLACE_INSERT_TAGS       => 'handleReplaceInsertTags',
        ];
    }
989620
public function getOxcomAdminSearchResults()
    {
        $aData = [];
        if (strlen($this->_sQueryName) > 2) {
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowArticles")) {
                $aData["articles"] = $this->_getOxcomAdminSearchArticles();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowCategories")) {
                $aData["categories"] = $this->_getOxcomAdminSearchCategories();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowCmsPages")) {
                $aData["cmspages"] = $this->_getOxcomAdminSearchCmsPages();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowOrders")) {
                $aData["orders"] = $this->_getOxcomAdminSearchOrders();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowUsers")) {
                $aData["users"] = $this->_getOxcomAdminSearchUsers();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowCompanies")) {
                $aData["companies"] = $this->_getOxcomAdminSearchCompanies();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowVendors")) {
                $aData["vendors"] = $this->_getOxcomAdminSearchVendors();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowManufacturers")) {
                $aData["manufacturers"] = $this->_getOxcomAdminSearchManufacturers();
            }
            if ($this->getOxcomAdminSearchConfigParam("blOxComAdminSearchShowModules")) {
                $aData["modules"] = $this->_getOxcomAdminSearchModules();
            }
        }
        echo json_encode($aData);
        exit;
    }
892123
protected function getBulkMailFromOptions()
    {
        $results['O'] = $this->_('Use organizational from address');

        if (isset($project->email['site']) && $project->email['site']) {
            $results['S'] = sprintf($this->_('Use site %s address'), $project->email['site']);
        }

        $results['U'] = $this->_("Use the 'By staff member' address");
        $results['F'] = $this->_('Other');

        return $results;
    }
1263833
public function getCMSFields()
    {
        $fields = new FieldList(new TabSet('Root'));
        $fields->addFieldToTab('Root.Main', new TextField('Title', $this->fieldLabel('Title')));

        $filter = '';

        $reqParent = isset($_REQUEST['ParentID']) ? (int) $_REQUEST['ParentID'] : 0;
        $attachTo = $this->ActionID ? $this->ActionID : $reqParent;

        if ($attachTo) {
            $action = DataObject::get_by_id(WorkflowAction::class, $attachTo);
            if ($action && $action->ID) {
                $filter = '"WorkflowDefID" = '.((int) $action->WorkflowDefID);
            }
        }

        $actions = DataObject::get(WorkflowAction::class, $filter);
        $options = array();
        if ($actions) {
            $options = $actions->map();
        }

        $defaultAction = $action ? $action->ID : "";

        $typeOptions = array(
            'Active' => _t('WorkflowTransition.Active', 'Active'),
            'Passive' => _t('WorkflowTransition.Passive', 'Passive'),
        );

        $fields->addFieldToTab('Root.Main', new DropdownField(
            'ActionID',
            $this->fieldLabel('ActionID'),
            $options,
            $defaultAction
        ));
        $fields->addFieldToTab('Root.Main', $nextActionDropdownField = new DropdownField(
            'NextActionID',
            $this->fieldLabel('NextActionID'),
            $options
        ));
        $nextActionDropdownField->setEmptyString(_t('WorkflowTransition.SELECTONE', '(Select one)'));
        $fields->addFieldToTab('Root.Main', new DropdownField(
            'Type',
            _t('WorkflowTransition.TYPE', 'Type'),
            $typeOptions
        ));

        $members = Member::get();
        $fields->findOrMakeTab(
            'Root.RestrictToUsers',
            _t('WorkflowTransition.TabTitle', 'Restrict to users')
        );
        $fields->addFieldToTab(
            'Root.RestrictToUsers',
            new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Restrict to Users'), $members)
        );
        $fields->addFieldToTab(
            'Root.RestrictToUsers',
            new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Restrict to Groups'), Group::class)
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
343438
public function getNumberActiveModules(){
		if(HookProvider::getInstance()->isModuleOperational()){
			$sqlquery = '';
			$sqlparams = array($this->hook_function);
			if($this->hook_context != 'all') {
				$sqlparams = array($this->hook_function, $this->hook_context);
				$sqlquery = " OR majh_hook_context=?";
			}
			$module_names=Database::prepare(
					"SELECT majh_module_name AS modules FROM `##maj_hooks`".
					" WHERE majh_hook_function = ? AND (majh_hook_context='all'".$sqlquery.") AND majh_status='enabled'"
			)->execute($sqlparams)->fetchOneColumn();
			return count($module_names);
		}
		return 0;
	}