1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* integer_net Magento Module |
4
|
|
|
* |
5
|
|
|
* @category IntegerNet |
6
|
|
|
* @package |
7
|
|
|
* @copyright Copyright (c) 2015 integer_net GmbH (http://www.integer-net.de/) |
8
|
|
|
* @author Fabian Schmengler <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace IntegerNet\Anonymizer; |
12
|
|
|
|
13
|
|
|
use N98\Magento\Command\AbstractMagentoCommand; |
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
use Symfony\Component\Console\Output\StreamOutput; |
17
|
|
|
|
18
|
|
|
class AnonymizeCommand extends AbstractMagentoCommand |
19
|
|
|
{ |
20
|
|
|
protected function configure() |
21
|
|
|
{ |
22
|
|
|
$this |
23
|
|
|
->setName('db:anonymize') |
24
|
|
|
->setDescription('Anonymize customer data'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
29
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
30
|
|
|
* @return int|void |
31
|
|
|
*/ |
32
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
33
|
|
|
{ |
34
|
|
|
$this->detectMagento($output, true); |
35
|
|
|
if ($this->initMagento()) { |
36
|
|
|
$this->registerPsr0Autoloader(); |
37
|
|
|
/** @var \IntegerNet_Anonymizer_Model_Anonymizer $anonymizer */ |
38
|
|
|
$anonymizer = \Mage::getModel('integernet_anonymizer/anonymizer'); |
39
|
|
|
if ($output instanceof StreamOutput) { |
|
|
|
|
40
|
|
|
$anonymizer->setOutputStream($output->getStream()); |
41
|
|
|
} else { |
42
|
|
|
//TODO allow OutputInterface in Anonymizer? |
43
|
|
|
//TODO pass ansi/no-ansi configuration to Anonymizer and use colors |
44
|
|
|
ob_start(); |
45
|
|
|
$anonymizer->setOutputStream(STDOUT); |
|
|
|
|
46
|
|
|
$output->write(ob_get_clean()); |
47
|
|
|
} |
48
|
|
|
$anonymizer->anonymizeAll(); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
private function registerPsr0Autoloader() |
52
|
|
|
{ |
53
|
|
|
\Mage::getConfig()->init()->loadEventObservers('global'); |
54
|
|
|
\Mage::app()->addEventArea('global'); |
55
|
|
|
\Mage::dispatchEvent('add_spl_autoloader'); |
56
|
|
|
} |
57
|
|
|
} |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.