PHP code example of dized / module-front-acl
1. Go to this page and download the library: Download dized/module-front-acl library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dized / module-front-acl example snippets
/**
* Add custom logic to identify customer role.
*
* @param \DiZed\FrontAcl\Plugin\Customer\Api\AccountManagement $subject
* @param string $result
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @return string
* @see \DiZed\FrontAcl\Plugin\Customer\Api\AccountManagement::getDetectedRole
*/
public function afterGetDetectedRole(
\DiZed\FrontAcl\Plugin\Customer\Api\AccountManagement $subject,
string $result,
CustomerInterface $customer
): string {
// @todo Need to add custom logic here...
return $result;
}
namespace Name\Space\Sample\Action;
use DiZed\FrontAcl\Controller\App\HttpAclActionInterface;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Sample implements HttpGetActionInterface, HttpAclActionInterface
{
/**
* Front ACL Role.
*/
const FRONT_ACL_ROLE = ['FrontAcl_Role::sample'];
/**
* Front ACL Permission.
*/
const FRONT_ACL_PERMISSION = ['FrontAcl_Permission::sample'];
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Action constructor.
*
* @param PageFactory $resultPageFactory
*/
public function __construct(
PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
}
/**
* Is action allowed?
*
* @return bool
*/
public function isFrontClassAllowed(): bool
{
return true;
}
/**
* Execute action.
*
* @return Page
*/
public function execute(): Page
{
return $this->resultPageFactory->create();
}
}
namespace Name\Space\Sample\Block;
use DiZed\FrontAcl\Block\View\Element\AclBlockInterface;
use Magento\Framework\View\Element\Template;
class Sample extends Template implements AclBlockInterface
{
/**
* Front ACL Role.
*/
const FRONT_ACL_ROLE = ['FrontAcl_Role::sample'];
/**
* Front ACL Permission.
*/
const FRONT_ACL_PERMISSION = ['FrontAcl_Permission::sample'];
/**
* Is block allowed?
*
* @return bool
*/
public function isFrontClassAllowed(): bool
{
return true;
}
}