Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AuthorizationLink.php
Go to the documentation of this file.
1 <?php
7 
10 
19 {
25  protected $httpContext;
26 
30  protected $_customerUrl;
31 
35  protected $_postDataHelper;
36 
44  public function __construct(
45  \Magento\Framework\View\Element\Template\Context $context,
46  \Magento\Framework\App\Http\Context $httpContext,
48  \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
49  array $data = []
50  ) {
51  parent::__construct($context, $data);
52  $this->httpContext = $httpContext;
53  $this->_customerUrl = $customerUrl;
54  $this->_postDataHelper = $postDataHelper;
55  }
56 
60  public function getHref()
61  {
62  return $this->isLoggedIn()
63  ? $this->_customerUrl->getLogoutUrl()
64  : $this->_customerUrl->getLoginUrl();
65  }
66 
70  public function getLabel()
71  {
72  return $this->isLoggedIn() ? __('Sign Out') : __('Sign In');
73  }
74 
80  public function getPostParams()
81  {
82  return $this->_postDataHelper->getPostData($this->getHref());
83  }
84 
90  public function isLoggedIn()
91  {
92  return $this->httpContext->getValue(Context::CONTEXT_AUTH);
93  }
94 
99  public function getSortOrder()
100  {
101  return $this->getData(self::SORT_ORDER);
102  }
103 }
getData($key='', $index=null)
Definition: DataObject.php:119
$customerUrl
Definition: info.phtml:28
__()
Definition: __.php:13