/** * 2016-01-08 * @param AE $e * @param string $uidSuffix [optional] * @return array(string => string) */ function df_fe_attrs(AE $e, $uidSuffix = null) { return ['id' => $e->getHtmlId(), 'name' => $e->getName()] + df_fe_uid($e, $uidSuffix) + dfa_select($e->getData(), $e->getHtmlAttributes()); }
/** * 2016-07-04 * @param Store $store * @param Order $order * @param string[] $keys * @return array(string => string) */ public static function select(Store $store, Order $order, array $keys) { return array_combine(dfa_select(self::s()->map(), $keys), dfa_select(self::vars($store, $order), $keys)); }
/** * Этот метод возвращает объект-одиночку, * потому что параметры запроса у нас неизменны в течение всей жизни запроса. * @return Params */ public static function fromRequest() { /** @var array(string => string|int) $params */ $params = [self::$P__WIDTH => 400, self::$P__HEIGHT => 50, self::$P__FONT_SIZE => 14, self::$P__FONT_COLOR => '0|0|0|0', self::$P__BG_COLOR => '255|255|255|127', self::$P__MARGIN_LEFT => 0]; static $r; return $r ? $r : ($r = new self(dfa_select(df_request() + $params, array_keys($params)))); }
/** * @used-by execute() * @return MC|null * 2016-12-01 * Отныне метод может (и будет) возвращать null в том случае, * когда учётная запись покупателя отсутствует в Magento, * а метод @see canRegister() вернул false (случай Blackbaud NetCommunity). */ private function mc() { return dfc($this, function () { /** @var MCR $resource */ $resource = df_customer_resource(); /** @var \Magento\Framework\DB\Select $select */ $select = df_db_from($resource, $resource->getEntityIdField()); /** * 2015-10-10 * 1) Полученный нами от браузера идентификатор пользователя Facebook * не является глобальным: он разный для разных приложений. * 2) Я так понял, что нельзя использовать одно и то же приложение Facebook * сразу на нескольких доменах. * 3) Из пунктов 1 и 2 следует, что нам нельзя идентифицировать пользователя Facebook * по его идентификатору: ведь Magento — многодоменная система. * * Есть выход: token_for_business * https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids * https://developers.facebook.com/docs/apps/for-business * https://business.facebook.com/ */ // 2016-11-21 // Добавил возможность идентификации покупателей по email. // Вроде бы Discourse поступает аналогично. $select->where(df_db_or(df_db_quote_into("? = {$this->fId()}", $this->c()->id()), !$this->c()->email() ? null : ['? = email', $this->c()->email()])); /** * @see \Magento\Customer\Model\ResourceModel\Customer::loadByEmail() * https://github.com/magento/magento2/blob/2e2785cc6a78dc073a4d5bb5a88bd23161d3835c/app/code/Magento/Customer/Model/Resource/Customer.php#L215 */ if (!df_are_customers_global()) { /** * @see \Magento\Customer\Model\CustomerRegistry::retrieveByEmail() * https://github.com/magento/magento2/blob/2e2785cc6a78dc073a4d5bb5a88bd23161d3835c/app/code/Magento/Customer/Model/CustomerRegistry.php#L104 * @see \Magento\Customer\Model\ResourceModel\Customer::loadByEmail() * https://github.com/magento/magento2/blob/2e2785cc6a78dc073a4d5bb5a88bd23161d3835c/app/code/Magento/Customer/Model/Resource/Customer.php#L222 */ $select->where('? = website_id', df_store_m()->getStore()->getWebsiteId()); } /** * 2016-03-01 * @uses \Zend_Db_Adapter_Abstract::fetchOne() возвращает false при пустом результате запроса. * https://mage2.pro/t/853 * @var int|false $customerId */ $customerId = df_conn()->fetchOne($select); /** @var MC|null $result */ if ($result = !$customerId && !$this->canRegister() ? null : df_om()->create(MC::class)) { if (!$customerId) { $this->register($result); } else { $resource->load($result, $customerId); // Обновляем в нашей БД полученую от сервиса авторизации информацию о покупателе. $result->addData(dfa_select($this->customerData(), $this->customerFieldsToSync())); $result->save(); } /** * 2015-10-08 * Ядро здесь делает так: * $customerModel = $this->customerFactory->create()->updateData($customer); * @see \Magento\Customer\Model\AccountManagement::authenticate() * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Customer/Model/AccountManagement.php#L381 * Я так понимаю, ядро так делает потому, что выше там код: * $customer = $this->customerRepository->get($username); * и этот код необязательно возвращает объект класса @see \Magento\Customer\Model\Customer * а может вернуть что-то другое, поддерживающее интерфейс * @see \Magento\Customer\Api\Data\CustomerInterface * @see \Magento\Customer\Api\CustomerRepositoryInterface::get() */ /** * По аналогии с @see \Magento\Customer\Model\AccountManagement::authenticate() * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Customer/Model/AccountManagement.php#L382-L385 */ df_dispatch('customer_customer_authenticated', ['model' => $result, 'password' => '']); /** * 2015-10-08 * Не знаю, нужно ли это на самом деле. * Сделал по аналогии с @see \Magento\Customer\Model\CustomerRegistry::retrieveByEmail() * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Customer/Model/CustomerRegistry.php#L133-L134 * * 2016-12-01 * Однозначно нужно. */ df_customer_registry()->push($result); // 2015-12-10 // Иначе новый покупатель не попадает в таблицу «customer_grid_flat». $result->reindex(); } return $result; }); }