{@inheritdoc}

@return Facebook
497747
public static function create(UrlGenerator $generator, SessionInterface $session, array $options)
    {
        $config['app_id'] = $options['app-id'];
        $config['app_secret'] = $options['secret'];
        $config['default_graph_version'] = $options['default-graph-version'];

        $facebook = new \Facebook\Facebook($config);

        return new static($facebook, $generator, $session);
    }
703725
public function unserialize(string $context): GraphQLContext
    {
        [
            'request' => $rawRequest,
            'user' => $rawUser
        ] = unserialize($context);

        $request = new Request(
            $rawRequest['query'],
            $rawRequest['request'],
            $rawRequest['attributes'],
            $rawRequest['cookies'],
            $rawRequest['files'],
            $rawRequest['server'],
            $rawRequest['content']
        );

        $request->setUserResolver(
            function () use ($rawUser) {
                return unserialize($rawUser);
            }
        );

        return $this->createsContext->generate($request);
    }
1265137
public function api(FacebookSession $fbsession, $method, $call)
	{
		try 
		{
		  $facebookResponse = (new FacebookRequest($fbsession, $method, $call))->execute();

		  return $graphObject = $facebookResponse->getGraphObject();
		} 
		catch (FacebookRequestException $ex)
		{
		  throw new FacebookException($ex->getMessage());
		}
		catch (\Exception $ex)
		{
		  throw new FacebookException($ex->getMessage());
		}
	}
518087
public function load($id = null)
    {
        if(is_null($id) && Mage::getSingleton('customer/session')->isLoggedIn()) {
            $this->customer = Mage::getSingleton('customer/session')->getCustomer();
        } else if(is_int($id)){
            $this->customer = Mage::getModel('customer/customer')->load($id);
            
            // TODO: Implement
        }

        if(!$this->customer->getId()) {
            return $this;
        }

        if(!($socialconnectGid = $this->customer->getInchooSocialconnectGid()) ||
                !($socialconnectGtoken = $this->customer->getInchooSocialconnectGtoken())) {
            return $this;
        }

        $this->setAccessToken($socialconnectGtoken);
        $this->_load();

        return $this;
    }
448993
private function mc() {return dfc($this, function() {
		$resource = df_customer_resource(); /** @var MCR $resource */
		$c = $this->c(); /** @var DC $c */
		$select = df_db_from($resource, $resource->getEntityIdField()); /** @var Select $select */
		/**
		 * 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()}", $c->id()), !$c->email() ? null : ['? = email', $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_new_om(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()
			 */
			/**
			 * By analogy with @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;
	});}
1270021
public function getFacebookLikeButton($parameters = array())
    {
        // default values, you can override the values by setting them
        $parameters = $parameters + array(
            'url' => null,
            'locale' => 'en_US',
            'send' => false,
            'width' => 60,
            'showFaces' => false,
            'layout' => 'box_count',
        );

        return $this->container->get('dacorp.socialBarHelper')->facebookButton($parameters);
    }
168958
public static function mapResult(callable $f)
    {
        return function (callable $handler) use ($f) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($handler, $f) {
                return $handler($command, $request)->then($f);
            };
        };
    }
976056
public static function getInstance() {

		if( !isset( self::$instance ) ) {

			self::$instance	= new FacebookMetaProperties();

			self::$instance->init( 'facebook-meta' );
		}

		return self::$instance;
	}
1254061
public static function send()
    {
        $instance = FirePHP::getInstance(true);
        $args = func_get_args();
        return call_user_func_array(array($instance,'fb'),$args);
    }
809750
public function load($id = null)
    {
        if(is_null($id) && Mage::getSingleton('customer/session')->isLoggedIn()) {
            $this->customer = Mage::getSingleton('customer/session')->getCustomer();
        } else if(is_int($id)) {
            $this->customer = Mage::getModel('customer/customer')->load($id);
            
            // TODO: Implement
        }

        if(!$this->customer->getId()) {
            return $this;
        }

        if(!($socialconnectLid = $this->customer->getInchooSocialconnectTid()) ||
                !($socialconnectTtoken = $this->customer->getInchooSocialconnectTtoken())) {
            return $this;
        }

        $this->setAccessToken($socialconnectTtoken);
        $this->_load();

        return $this;
    }
719089
public function getSocialPage(){
		$result = null;
		if (isset($this->userInfo[$this->socialFieldsMap['socialPage']])) {
			$result = $this->userInfo[$this->socialFieldsMap['socialPage']];
			}
		return $result;
		}
272308
public function build(): DisposeBrowserContextRequest
	{
		$instance = new DisposeBrowserContextRequest();
		if ($this->browserContextId === null) {
			throw new BuilderException('Property [browserContextId] is required.');
		}
		$instance->browserContextId = $this->browserContextId;
		return $instance;
	}
392367
public static function simple()
    {
        return new static(
            new DetailFactory(new PhotoFactory()),
            new CategoryFactory(),
            new ContactFactory(),
            new LocationFactory(),
            new TipGroupFactory(new TipFactory()),
            new PhotoGroupFactory(new PhotoFactory())
        );
    }
1256976
public function facebookAction()
    {

        error_log("APPEL RECU");
        if ($this->getRequest()->isPost()) {
            $in = file_get_contents('php://input');
            error_log($in);
            $in = json_decode($in);
            error_log($in->entry[0]->changes[0]->field);
            error_log($in->entry[0]->changes[0]->value->post_id);
        }

        $mode = $this->params()->fromQuery('hub_mode');
        $challenge = $this->params()->fromQuery('hub_challenge');
        $token = $this->params()->fromQuery('hub_verify_token');

        $response = $this->getResponse();
        $response->setContent($challenge);

        file_get_contents('php://input');

        return $response;
    }
400218
private function executeFacebookRequest($method, $endpoint, array $parameters = [], $token = null)
    {
        if (is_callable($this->logCallback)) {
            //used only for debugging:
            call_user_func($this->logCallback, 'Facebook API request', func_get_args());
        }

        if (!$token) {
            $token = $this->appToken;
        }

        switch ($method) {
            case 'GET':
                $response = $this->fb->get($endpoint, $token);
                break;
            case 'POST':
                $response = $this->fb->post($endpoint, $parameters, $token);
                break;
            case 'DELETE':
                $response = $this->fb->delete($endpoint, $parameters, $token);
                break;
            default:
                throw new \Exception("Facebook driver exception, please add support for method: " . $method);
                break;
        }

        if (is_callable($this->logCallback)) {
            call_user_func($this->logCallback, 'Facebook API response', $response->getDecodedBody());
        }

        return $response;
    }
235350
public function exposed(): MapInterface
    {
        return $this->exposed->reduce(
            new Map(Name::class, Constructor::class),
            static function(Map $exposed, string $name, Service $service): Map {
                return $exposed->put(
                    $service->exposedAs(),
                    $service->constructor()
                );
            }
        );
    }
1246116
public function facebookShare($url = '', $text = '')
    {
        $facebook = new Facebook();

        return $facebook
            ->setAppId($this->data['facebook']['appId'])
            ->setAdminId($this->data['facebook']['adminId'])
            ->setRedirectUrl($this->data['facebook']['redirectUrl'])
            ->createShareLink($url, $text)
            ->getLink();
    }