In this section, we will see how to restrict the frontend features for guest users. In our example, the objective is to restrict access to the Details page for logged out users.
First of all, we need to add a new method in our block, which will define whether the user is logged in or not:
Open the
[extension_path]/Block/EventList.php
file and add a new attribute:protected $_customerSession;
Instantiate this new attribute in the constructor:
public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Blackbird\TicketBlaster\Model\ResourceModel\Event\CollectionFactory $eventCollectionFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, array $data = [] ) { parent::__construct($context, $data); $this->_storeManager = $storeManager; $this->_eventCollectionFactory...