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.

AbstractUrlRewriteCommand::setupProgress()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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