Проверка соединения.

@throws B2BApiException

@return B2BResponse
354135
public function ping()
    {
        return new B2BResponse($this->client->apiRequest(
            'get',
            'dev/ping',
            [
                'value' => $test_value = 'pong',
            ],
            [],
            $this->client->isTest() ? new Response(
                200, $this->getTestingResponseHeaders(), \json_encode([
                'value' => $test_value,
                'in'    => 0,
                'out'   => $ts = Carbon::now()->addSeconds(mt_rand(0, 1))->getTimestamp(),
                'delay' => $ts + mt_rand(0, 2),
            ])) : null
        ));
    }
181906
private function getClientBrowserAccepted()
    {
        $this->autoPopulateSuperGlobals();
        $sReturn = [
            'accept'          => $this->brServerGlobals->server->get('HTTP_ACCEPT'),
            'accept_encoding' => $this->brServerGlobals->server->get('HTTP_ACCEPT_ENCODING'),
        ];
        if (!is_null($this->brServerGlobals->server->get('HTTP_ACCEPT_LANGUAGE'))) {
            $sReturn['accept_language']     = $this->brServerGlobals->server->get('HTTP_ACCEPT_LANGUAGE');
            $prfd                           = null;
            preg_match_all('/([a-z]{2})(?:-[a-zA-Z]{2})?/', $sReturn['accept_language'], $prfd);
            $sReturn['preferred locale']    = $prfd[0];
            $sReturn['preferred languages'] = array_values(array_unique(array_values($prfd[1])));
        }
        return $sReturn;
    }
623002
public function main()
    {
        $mainPageHTML = '';
        $dbMaterials = array();

        // Получим все материалы
        if (
        dbQuery('samsoncms\api\Material')
            ->join('user')
            ->cond('Active', 1)
            ->cond('Draft', 0)
            ->order_by('Created', 'DESC')
            ->cond('Name', "", dbRelation::NOT_EQUAL)
            ->limit(5)
            ->exec($dbMaterials)
        ) {
            // Render material rows
            $rowsHTML = '';
            foreach ($dbMaterials as $dbMaterial) {
                $rowsHTML .= $this->view('main/row')
                    ->set($dbMaterial, 'material')
                    ->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
                    ->output();
            }

            for ($i = sizeof($dbMaterials); $i < 5; $i++) {
                $rowsHTML .= $this->view('main/row')->output();
            }

            // Render main template
            $mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
        }

        // Return material block HTML on main page
        return $mainPageHTML;
    }
109738
public function newAction()
    {
        $breadcumbs = $this->container->get('bacon_breadcrumbs');

        $breadcumbs->addItem(array(
            'title' => 'Language',
            'route' => 'admin_language',
        ));

        $breadcumbs->addItem(array(
            'title' => 'New',
            'route' => '',
        ));

        $form = $this->createForm(new LanguageFormType(), new Language());

        return array(
            'form'   => $form->createView(),
        );
    }
1340434
private function newCard() {return dfc($this, function() {
		$m = $this->m(); /** @var Method $m */
		$isCard = $m->isCard(); /** @var bool $isCard */
		df_assert(!$isCard || $this->tokenIsNew());
		$customer = null; /** @var object|null $customer */
		$cardId = null; /** @var string $cardId */
		$fc = FCustomer::s($m); /** @var FCustomer $fc */
		if ($customerId = $this->customerIdSaved() /** @var string $customerId */) {
			// 2016-08-23 https://stripe.com/docs/api/php#retrieve_customer
			// 2017-02-10 Зарегистрированный в ПС покупатель с незарегистрированной в ПС картой.
			// 2017-07-16 We ensure here that the customer with the ID given is really exist in the PSP.
			$customer = $fc->get($customerId);
			// 2017-02-24
			// We can get here, for example, if the store's administrator has switched
			// his Stripe account in the extension's settings: https://mage2.pro/t/3337
			if (!$customer) {
				df_ci_save($this->m(), null);
				$customerId = null;
			}
		}
		if ($customer) {
			if ($isCard) {
				// 2016-08-23
				// Зарегистрированный в ПС покупатель с незарегистрированной в ПС картой.
				// Сохраняем её: https://stripe.com/docs/api#create_card
				/**
				 * 2017-07-16
				 * If a PSP does not support the «cardAdd» operation for a token (like Moip and Spryng),
				 * then the facade should just return the token.
				 * @see \Dfe\Moip\Facade\Customer::cardAdd()
				 * https://github.com/mage2pro/moip/blob/0.7.2/Facade/Customer.php#L37-L55
				 * @see \Dfe\Spryng\Facade\Customer::cardAdd()
				 * https://github.com/mage2pro/spryng/blob/1.1.10/Facade/Customer.php#L18-L27
				 */
				$cardId = $fc->cardAdd($customer, $this->token());
				df_assert_sne($cardId);
			}
		}
		else {
			// 2017-06-11 It registers the customer in the PSP.
			// 2016-08-22 Stripe: https://stripe.com/docs/api/php#create_customer
			// 2016-11-15 Omise: https://www.omise.co/customers-api#customers-create
			// 2017-02-11 Paymill: https://developers.paymill.com/API/index#create-new-client-
			$customer = $fc->create(Reg::request($m));
			df_ci_save($this->m(), $customerId = $fc->id($customer));
			if ($isCard) {
				// 2017-02-18 Вторая часть условия — для ПС (Spryng), которые не поддерживают сохранение карт.
				$cardId =
					// 2017-10-10 Square supports a card saving, but requires an additional step to do it.
					$fc->addCardInASeparateStepForNewCustomers()
					? $fc->cardAdd($customer, $this->token())
					// 2017-07-16
					// Moip supports a card saving, but does not allow to do it on the customer's registration.
					// The card is saved in Moip only on a payment request.
					// https://github.com/mage2pro/moip/blob/0.7.0/P/Reg.php#L24-L29
					// https://github.com/mage2pro/moip/blob/0.7.0/T/CaseT/Customer.php#L94-#L106
					: ($fc->cardIdForJustCreated($customer) ?: $this->token())
				;
			}
		}
		if ($cardId) {
			Token::exchangedSet($this->m()->getCode(), $cardId);
		}
		return [$customerId, $cardId];
	});}
1221641
private function step2b()
    {
        // é   ée   ées   és   èrent   er   era   erai   eraIent   erais   erait   eras   erez   eriez   erions   erons   eront   ez   iez
        //      delete
        if ( ($position = $this->searchIfInRv(array(
            'ées', 'èrent', 'erais', 'erait', 'erai', 'eraIent', 'eras', 'erez', 'eriez',
            'erions', 'erons', 'eront', 'era', 'er', 'iez', 'ez','és', 'ée', 'é'))) !== false) {

            $this->word = Utf8::substr($this->word, 0, $position);

            return true;
        }

        // âmes   ât   âtes   a   ai   aIent   ais   ait   ant   ante   antes   ants   as   asse   assent   asses   assiez   assions
        //      delete
        //      if preceded by e, delete
        if ( ($position = $this->searchIfInRv(array(
            'âmes', 'âtes', 'ât', 'aIent', 'ais', 'ait', 'antes', 'ante', 'ants', 'ant',
            'assent', 'asses', 'assiez', 'assions', 'asse', 'as', 'ai', 'a'))) !== false) {

            $before = $position - 1;
            $letter = Utf8::substr($this->word, $before, 1);
            if ( $this->inRv($before) && ($letter == 'e') ) {
                $this->word = Utf8::substr($this->word, 0, $before);

            } else {
                $this->word = Utf8::substr($this->word, 0, $position);
            }

            return true;
        }

        // ions
        //      delete if in R2
        if ( ($position = $this->searchIfInRv(array('ions'))) !== false) {
            if ($this->inR2($position)) {
                $this->word = Utf8::substr($this->word, 0, $position);
            }

            return true;
        }

        return false;
    }
1352892
public function endpoint()
	{
		/**
		 * @var Processor $processor
		 */

		$type = Type::ENDPOINT;
		$input = $this->getVerifiedInput('endpoint', $type, Input::all());


		$errorMessage = 'Request error';
		$urlBack = '';

		if ($input) {

			$errorMessage = '';
			$urlBack = $input['back'];
			$opType = new Type($type, $input);

			try {
				$opType->validate();
			} catch (ProcessorException $e) {
				$errorMessage = $e->getMessage();
			}

		}

		if ($errorMessage) {
			return Redirect::route('ff-bank-em-error')->with(array(
				'errorMessage' => $errorMessage,
				'errorUrl'     => Views::url($urlBack, array('resultBankEmulatorPayment' => 'error')),
				'errorUrlName' => 'вернуться в магазин',
			));
		}

		$term = Terminal::find($input['term']);
		$paymentParams = $this->getPaymentFields($input);
		Secure::sign($paymentParams, $type, $term->secret);

		$this->layout = View::make('ff-bank-em::layouts.endpoint');

		return $this->layout->nest('content', 'ff-bank-em::demo.endpoint', compact('paymentParams'));

	}
492525
final protected function _process() {
		/**
		 * 2016-08-22
		 * Помимо добавления поля в таблицу «customer_entity» надо ещё добавить атрибут,
		 * иначе данные не будут сохраняться:
		 *		$attribute = $this->getAttribute($k);
		 *		if (empty($attribute)) {
		 *			continue;
		 *		}
		 * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Eav/Model/Entity/AbstractEntity.php#L1262-L1265
		 */
		if ($this->v('1.7.4')) {
			df_eav_setup()->addAttribute('customer', UpgradeSchema::F__DF, [
				'input' => 'text'
				,'label' => 'Mage2.PRO'
				,'position' => 1000
				,'required' => false
				,'sort_order' => 1000
				,'system' => false
				,'type' => 'static'
				,'visible' => false
			]);
		}
	}
248744
public function _insert()
    {
        //data dodania
        $this->dateAdd = date('Y-m-d H:i:s');
        //adres IP
        $this->ip = \Mmi\App\FrontController::getInstance()->getEnvironment()->remoteAddress;
        $this->active = 1;
        //zapis znanego użytkownika
        if (\App\Registry::$auth->hasIdentity()) {
            $this->cmsAuthId = \App\Registry::$auth->getId();
        }
        //namespace w sesji
        $namespace = new \Mmi\Session\SessionSpace('contact');
        $this->uri = $namespace->referer;
        //wysyłka do maila zdefiniowanego w opcjach
        $option = (new CmsContactOptionQuery)->findPk($this->cmsContactOptionId);
        //niepoprawna opcja
        if (!$option) {
            return false;
        }
        //wysyłka maila
        if ($option->sendTo) {
            \Cms\Model\Mail::pushEmail('admin_cms_contact', $option->sendTo, ['contact' => $this, 'option' => $option], null, $this->email);
        }
        return parent::_insert();
    }
703768
public function forDebug()
    {
        return tap(new PrettyPageHandler, function ($handler) {
            $handler->handleUnconditionally(true);

            $this->registerApplicationPaths($handler)
                 ->registerBlacklist($handler)
                 ->registerEditor($handler);
        });
    }
165378
public static function createContact()
    {
        $person = self::getPerson();

        // New person check
        if (isset($person->resourceName)) {
            throw new Exception("You should use newPeron() before create", 500);
        }
        
        return self::getService()->people->createContact($person);
    }
1175783
protected function createPage()
    {
        /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
        $resultPage = $this->resultPageFactory->create();

        $resultPage->setActiveMenu('Smile_ElasticsuiteCatalogOptimizer::optimizer')
            ->addBreadcrumb(__('Optimizer'), __('Optimizer'));

        return $resultPage;
    }
1317221
private function step2b()
    {
        //      delete
        if ( ($position = $this->searchIfInRv(array(
            'iésemos', 'iéramos', 'ábamos', 'iríamos', 'eríamos', 'aríamos', 'áramos', 'ásemos', 'eríais',
            'aremos', 'eremos', 'iremos', 'asteis', 'ieseis', 'ierais', 'isteis', 'aríais',
            'irían', 'aréis', 'erían', 'erías', 'eréis', 'iréis', 'irías', 'ieran', 'iesen', 'ieron', 'iendo', 'ieras',
            'iríais', 'arían', 'arías',
            'amos', 'imos', 'ados', 'idos', 'irán', 'irás', 'erán', 'erás', 'ería', 'iría', 'íais', 'arán', 'arás', 'aría',
            'iera', 'iese', 'aste', 'iste', 'aban', 'aran', 'asen', 'aron', 'ando', 'abas', 'adas', 'idas', 'ases', 'aras',
            'aré', 'erá', 'eré', 'áis', 'ías', 'irá', 'iré', 'aba', 'ían', 'ada', 'ara', 'ase', 'ida', 'ado', 'ido', 'ará',
            'ad', 'ed', 'id', 'ís', 'ió', 'ar', 'er', 'ir', 'as', 'ía', 'an'
        ))) != false) {
            $this->word = Utf8::substr($this->word, 0, $position);
            return true;
        }

        // en   es   éis   emos
        //      delete, and if preceded by gu delete the u (the gu need not be in RV)
        if ( ($position = $this->searchIfInRv(array('éis', 'emos', 'en', 'es'))) != false) {
            $this->word = Utf8::substr($this->word, 0, $position);

            if ( ($position2 = $this->search(array('gu'))) != false) {
                $this->word = Utf8::substr($this->word, 0, ($position2+1));
            }


            return true;
        }
    }
840556
protected function getValue()
    {
        if (isset($this->_maker, $this->_name)){
            $parent = $this->_maker->getValue(); // Берется значения родителя (родитель, возможно, берет значения у своего родителя..)
            return isset($parent[$this->_name])? $parent[$this->_name] : null; // Из него выбирается своё
        }else{
            return $this->_value;
        }
    }
178604
public function actionForget()
    {
        $rr = new RequestResponse();
        $model = new PasswordResetRequestFormEmailOrLogin();
        //Не админка
        $model->isAdmin = false;

        //Запрос на валидацию ajax формы
        if ($rr->isRequestOnValidateAjaxForm()) {
            return $rr->ajaxValidateForm($model);
        }
        //Запрос ajax post
        if ($rr->isRequestAjaxPost()) {
            if ($model->load(\Yii::$app->request->post()) && $model->sendEmail()) {
                $rr->success = true;
                $rr->message = 'Проверьте ваш email, дальнейшие инструкции мы отправили туда';
            } else {
                $rr->message = 'Не удалось выполнить запрос на восстановление пароля';
            }

            return (array)$rr;

        } else {
            if (\Yii::$app->request->isPost) {
                if ($model->load(\Yii::$app->request->post()) && $model->sendEmail()) {
                    if ($ref = UrlHelper::getCurrent()->getRef()) {
                        return $this->redirect($ref);
                    } else {
                        return $this->goBack();
                    }
                }
            }
        }

        return $this->render('forget', [
            'model' => $model,
        ]);
    }
1319456
public function getMWDBO()
	{
		static $instance;

		if (!is_object($instance))
		{
			$config = $this->getParams('com_tools');

			$options['driver']   = 'pdo';
			$options['host']     = $config->get('mwDBHost');
			$options['port']     = $config->get('mwDBPort');
			$options['user']     = $config->get('mwDBUsername');
			$options['password'] = $config->get('mwDBPassword');
			$options['database'] = $config->get('mwDBDatabase');
			$options['prefix']   = $config->get('mwDBPrefix');

			if ((!isset($options['password']) || $options['password'] == '')
			 && (!isset($options['user'])     || $options['user'] == '')
			 && (!isset($options['database']) || $options['database'] == ''))
			{
				$instance = $this->db;
			}
			else
			{
				try
				{
					$instance = Driver::getInstance($options);
				}
				catch (\PDOException $e)
				{
					$instance = null;
					return false;
				}
			}

			// Test the connection
			if (!$instance->connected())
			{
				$instance = null;
				return false;
			}
		}

		return $instance;
	}
648717
public function build(): ResolveBlobRequest
	{
		$instance = new ResolveBlobRequest();
		if ($this->objectId === null) {
			throw new BuilderException('Property [objectId] is required.');
		}
		$instance->objectId = $this->objectId;
		return $instance;
	}