ProductUrlPathValidatorObserver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 22
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 4 1
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\Observer\PathValidatorObserver;
8
9
class ProductUrlPathValidatorObserver extends PathValidatorObserver
10
{
11
    protected function getCurrentEntityType()
12
    {
13
        return 'product';
14
    }
15
16
    protected function getEntity(Observer $observer)
17
    {
18
        return $observer->getEvent()->getProduct();
19
    }
20
21
    protected function getEntityStoreIds(AbstractModel $entity)
22
    {
23
        return $entity->getStoreIds();
24
    }
25
26
    protected function getEntityUrlPath(AbstractModel $entity, int $storeId)
27
    {
28
        return $this->urlPathProvider->getProductUrlPath($entity->getId(), $storeId);
29
    }
30
}
31