-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathMenuHelper.php
More file actions
32 lines (26 loc) · 811 Bytes
/
MenuHelper.php
File metadata and controls
32 lines (26 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Snowdog\Menu\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\EntityManager\MetadataPool;
use Snowdog\Menu\Api\Data\MenuInterface;
class MenuHelper extends AbstractHelper
{
private MetadataPool $metadataPool;
public function __construct(
MetadataPool $metadataPool,
Context $context
) {
$this->metadataPool = $metadataPool;
parent::__construct($context);
}
public function getLinkField(): string
{
$metadata = $this->metadataPool->getMetadata(MenuInterface::class);
return $metadata->getLinkField();
}
public function getLinkValue(MenuInterface $menu): string
{
return (string) $menu->getData($this->getLinkField());
}
}