Completed
Push — master ( 939392...921edc )
by Christian
02:21 queued 18s
created

AbstractMviewIndexerCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 4 1
A getMetaDataCollection() 0 5 1
A getIndexers() 0 18 4
A getMviewClient() 0 4 1
1
<?php
2
3
namespace N98\Magento\Command\Indexer;
4
5
use N98\Magento\Command\AbstractMagentoCommand;
6
7
class AbstractMviewIndexerCommand extends AbstractMagentoCommand
8
{
9
    /**
10
     * @return bool
11
     */
12
    public function isEnabled()
13
    {
14
        return $this->getApplication()->isMagentoEnterprise();
15
    }
16
17
    /**
18
     * @return \Enterprise_Mview_Model_Resource_Metadata_Collection
19
     */
20
    public function getMetaDataCollection()
21
    {
22
        $collection = $this->_getModel('enterprise_mview/metadata', '\Enterprise_Mview_Model_Resource_Metadata_Collection')->getCollection();
23
        return $collection;
24
    }
25
26
    /**
27
     * @return array[]
28
     */
29
    protected function getIndexers()
30
    {
31
        /** @var \Enterprise_Index_Helper_Data $helper */
32
        $helper = $this->_getHelper('enterprise_index', '\Enterprise_Index_Helper_Data');
33
34
        $indexers = array();
35
        foreach ($helper->getIndexers(true) as $indexer) {
36
            $indexers[(string) $indexer->index_table] = $indexer;
37
        }
38
39
        foreach ($indexers as $indexerKey => $indexerData) {
40
            if (!isset($indexerData->action_model->changelog)) {
41
                unset($indexers[$indexerKey]);
42
            }
43
        }
44
45
        return $indexers;
46
    }
47
48
    /**
49
     * @return \Enterprise_Mview_Model_Client
50
     */
51
    protected function getMviewClient()
52
    {
53
        return $this->_getModel('enterprise_mview/client', '\Enterprise_Mview_Model_Client');
54
    }
55
}
56