GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 297b0c...d24cbd )
by Daniel
05:47
created

AbstractUrlRewriteCommand::getStoreManager()   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 0
1
<?php
2
/**
3
 * Rebuild Url Rewrite for magento 2
4
 * Copyright (C) 2017
5
 *
6
 * This file is part of DanielSousa/UrlRewrite.
7
 *
8
 * DanielSousa/UrlRewrite is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
namespace DanielSousa\UrlRewrite\Console\Command;
23
24
use Magento\Backend\App\Area\FrontNameResolver;
25
use Symfony\Component\Console\Command\Command;
26
use Symfony\Component\Console\Input\InputInterface;
27
use Symfony\Component\Console\Output\OutputInterface;
28
29
class AbstractUrlRewriteCommand extends Command
30
{
31
32
    /**
33
     * @var \Symfony\Component\Console\Helper\ProgressBar
34
     */
35
    protected $progressBar;
36
37
    /**
38
     * @var \Magento\Framework\ObjectManagerInterface
39
     */
40
    protected $objectManager;
41
    /**
42
     * @var \Symfony\Component\Console\Output\OutputInterface
43
     */
44
    protected $output;
45
    /**
46
     * @var \Magento\Framework\App\ObjectManagerFactory
47
     */
48
    private $objectManagerFactory;
0 ignored issues
show
Unused Code introduced by
The property $objectManagerFactory is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    protected function execute(InputInterface $input, OutputInterface $output)
54
    {
55
        $this->output = $output;
56
        $this->setupProgress();
57
    }
58
59
    /**
60
     * Setup progress bar
61
     */
62
    private function setupProgress()
63
    {
64
        $this->progressBar = new \Symfony\Component\Console\Helper\ProgressBar($this->output);
65
        $this->progressBar->setFormat(
66
            '<info>Product ID: %message%</info> %current%/%max% [%bar%] %percent:3s%%'
67
        );
68
    }
69
70
    /**
71
     * Replace data with new product urls
72
     *
73
     * @param $urls
74
     */
75
    protected function replaceUrls(array $urls)
76
    {
77
        if (empty($urls)) {
78
            return;
79
        }
80
81
        $this->getUrlPersist()->replace(
82
            $urls
83
        );
84
    }
85
86
    /**
87
     * Get Url UrlPersist
88
     * @return \Magento\UrlRewrite\Model\UrlPersistInterface
89
     */
90
    protected function getUrlPersist()
91
    {
92
        /** @var \Magento\UrlRewrite\Model\UrlPersistInterface $urlPersist */
93
        return $this->getObjectManager()->get('\Magento\UrlRewrite\Model\UrlPersistInterface');
94
    }
95
96
    /**
97
     * Gets initialized object manager
98
     *
99
     * @return \Magento\Framework\ObjectManagerInterface
100
     */
101
    protected function getObjectManager()
102
    {
103
        if (null == $this->objectManager) {
104
            $area = FrontNameResolver::AREA_CODE;
105
            $this->objectManager = \Magento\Framework\App\ObjectManager::getInstance();
106
            /** @var \Magento\Framework\App\State $appState */
107
            $appState = $this->objectManager->get('Magento\Framework\App\State');
108
            $appState->setAreaCode($area);
109
            $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface');
110
            $this->objectManager->configure($configLoader->load($area));
111
        }
112
        return $this->objectManager;
113
    }
114
115
    /**
116
     * @return \Magento\Framework\Model\ResourceModel\Iterator
117
     */
118
    public function getIterator()
119
    {
120
        return $this->getObjectManager()->create('\Magento\Framework\Model\ResourceModel\Iterator');
121
    }
122
123
124
    /**
125
     * @return  \Magento\Store\Model\StoreManagerInterface
126
     */
127
    public function getStoreManager()
128
    {
129
        return $this->getObjectManager()->get('\Magento\Store\Model\StoreManagerInterface');
130
    }
131
132
}