forked from ambta/DoctrineEncryptBundle
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathDoctrineEncryptStatusCommand.php
More file actions
59 lines (50 loc) · 1.91 KB
/
DoctrineEncryptStatusCommand.php
File metadata and controls
59 lines (50 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Ambta\DoctrineEncryptBundle\Command;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Get status of doctrine encrypt bundle and the database.
*
* @author Marcel van Nuil <marcel@ambta.com>
* @author Michael Feinbier <michael@feinbier.net>
*/
class DoctrineEncryptStatusCommand extends AbstractCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('doctrine:encrypt:status')
->setDescription('Get status of doctrine encrypt bundle and the database');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$metaDataArray = $this->entityManager->getMetadataFactory()->getAllMetadata();
$totalCount = 0;
foreach ($metaDataArray as $metaData) {
if ($metaData instanceof ClassMetadataInfo and $metaData->isMappedSuperclass) {
continue;
}
$count = 0;
$encryptedPropertiesCount = count($this->getEncryptionableProperties($metaData));
if ($encryptedPropertiesCount > 0) {
$totalCount += $encryptedPropertiesCount;
$count += $encryptedPropertiesCount;
}
if ($count > 0) {
$output->writeln(sprintf('<info>%s</info> has <info>%d</info> properties which are encrypted.', $metaData->name, $count));
} else {
$output->writeln(sprintf('<info>%s</info> has no properties which are encrypted.', $metaData->name));
}
}
$output->writeln('');
$output->writeln(sprintf('<info>%d</info> entities found which are containing <info>%d</info> encrypted properties.', count($metaDataArray), $totalCount));
return AbstractCommand::SUCCESS;
}
}