Passed
Push — master ( fc7dfd...a70edc )
by Tibor
02:21
created

getEntityUrlPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Tkotosz\CatalogRouter\Observer;
4
5
use Magento\Framework\Event\Observer;
6
use Magento\Framework\Model\AbstractModel;
7
use Tkotosz\CatalogRouter\Model\UrlPath;
8
use Tkotosz\CatalogRouter\Observer\PathValidatorObserver;
9
10
class CategoryUrlPathValidatorObserver extends PathValidatorObserver
11
{
12
    protected function getCurrentEntityType()
13
    {
14
        return 'category';
15
    }
16
17
    protected function getEntity(Observer $observer)
18
    {
19
        return $observer->getEvent()->getCategory();
20
    }
21
22
    protected function getEntityStoreIds(AbstractModel $entity)
23
    {
24
        $storeIds = [];
25
26
        foreach ($entity->getStoreIds() as $storeId) {
27
            if ($storeId == 0) {
28
                continue;
29
            }
30
31
            $storeIds[] = $storeId;
32
        }
33
34
        return $storeIds;
35
    }
36
37
    protected function getEntityUrlPath(AbstractModel $entity, int $storeId)
38
    {
39
        return $this->urlPathProvider->getCategoryUrlPath($entity->getId(), $storeId);
40
    }
41
}
42