Skip to content

Commit

Permalink
Fix [Drupal\Component\Plugin\Exception\PluginNotFoundException] error (
Browse files Browse the repository at this point in the history
  • Loading branch information
kabanon authored and LOBsTerr committed Oct 23, 2018
1 parent 912508f commit f79dab4
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/Command/Site/StatisticsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ public function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$bundles = $this->drupalApi->getBundles();
foreach ($bundles as $bundleType => $bundleName) {
$key = sprintf(
$this->trans('commands.site.statistics.messages.node-type'),
$bundleName
);
$statistics[$key] = $this->getNodeTypeCount($bundleType);
if ($this->moduleHandler->moduleExists('node'))
{
$bundles = $this->drupalApi->getBundles();
foreach ($bundles as $bundleType => $bundleName) {
$key = sprintf(
$this->trans('commands.site.statistics.messages.node-type'),
$bundleName
);
$statistics[$key] = $this->getNodeTypeCount($bundleType);
}
}
$statistics[$this->trans('commands.site.statistics.messages.comments')] = $this->getCommentCount();
$statistics[$this->trans('commands.site.statistics.messages.vocabulary')] = $this->getTaxonomyVocabularyCount();
Expand Down Expand Up @@ -136,6 +139,10 @@ private function getCommentCount()
*/
private function getTaxonomyVocabularyCount()
{
if (!$this->moduleHandler->moduleExists('taxonomy')) {
return 0;
}

$entityQuery = $this->entityQuery->get('taxonomy_vocabulary')->count();
$vocabularies = $entityQuery->execute();

Expand All @@ -147,6 +154,10 @@ private function getTaxonomyVocabularyCount()
*/
private function getTaxonomyTermCount()
{
if (!$this->moduleHandler->moduleExists('taxonomy')) {
return 0;
}

$entityQuery = $this->entityQuery->get('taxonomy_term')->count();
$terms = $entityQuery->execute();

Expand All @@ -158,6 +169,10 @@ private function getTaxonomyTermCount()
*/
private function getFileCount()
{
if (!$this->moduleHandler->moduleExists('file')) {
return 0;
}

$entityQuery = $this->entityQuery->get('file')->count();
$files = $entityQuery->execute();

Expand All @@ -169,6 +184,10 @@ private function getFileCount()
*/
private function getUserCount()
{
if (!$this->moduleHandler->moduleExists('user')) {
return 0;
}

$entityQuery = $this->entityQuery->get('user')->count();
$users = $entityQuery->execute();

Expand Down Expand Up @@ -206,6 +225,10 @@ private function getThemeCount($status = true)
*/
private function getViewCount($status = true, $tag = 'default')
{
if (!$this->moduleHandler->moduleExists('views')) {
return 0;
}

$entityQuery = $this->entityQuery->get('view')->condition('tag', 'default', '<>')->count();
$views = $entityQuery->execute();

Expand Down Expand Up @@ -233,3 +256,4 @@ private function statisticsList($statistics)
$this->getIo()->table($tableHeader, $tableRows);
}
}

0 comments on commit f79dab4

Please sign in to comment.