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

CmsPageUrlPathValidatorObserver   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentEntityType() 0 4 1
A getEntity() 0 4 1
A getEntityStoreIds() 0 10 2
A getEntityUrlPath() 0 4 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