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

CmsPageUrlPathValidatorObserver::getEntity()   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 1
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 CmsPageUrlPathValidatorObserver extends PathValidatorObserver
11
{
12
    protected function getCurrentEntityType()
13
    {
14
        return 'cms page';
15
    }
16
17
    protected function getEntity(Observer $observer)
18
    {
19
        return $observer->getEvent()->getObject();
20
    }
21
22
    protected function getEntityStoreIds(AbstractModel $entity)
23
    {
24
        $stores = $entity->getStores();
25
26
        if ($stores == [0]) {
27
            $stores = array_keys($this->storeManager->getStores());
28
        }
29
30
        return $stores;
31
    }
32
33
    protected function getEntityUrlPath(AbstractModel $entity, int $storeId)
34
    {
35
        return new UrlPath($entity->getIdentifier());
36
    }
37
}
38