1010use Drupal \Console \Core \Command \Command ;
1111use Drupal \Console \Extension \Manager ;
1212use Drupal \Console \Utils \DrupalApi ;
13- use Drupal \Core \Entity \Query \QueryFactory ;
1413use Drupal \Core \Extension \ModuleHandlerInterface ;
1514use Symfony \Component \Console \Input \InputInterface ;
1615use Symfony \Component \Console \Output \OutputInterface ;
16+ use Drupal \Core \Entity \EntityTypeManagerInterface ;
1717
1818/**
1919 * Class StatisticsCommand
@@ -27,11 +27,6 @@ class StatisticsCommand extends Command
2727 */
2828 protected $ drupalApi ;
2929
30- /**
31- * @var QueryFactory
32- */
33- protected $ entityQuery ;
34-
3530 /**
3631 * @var Manager
3732 */
@@ -42,22 +37,26 @@ class StatisticsCommand extends Command
4237 */
4338 protected $ moduleHandler ;
4439
40+ /**
41+ * @var EntityTypeManagerInterface
42+ */
43+ protected $ entityTypeManager ;
44+
4545 /**
4646 * StatisticsCommand constructor.
4747 *
4848 * @param DrupalApi $drupalApi
49- * @param QueryFactory $entityQuery ;
5049 * @param Manager $extensionManager
5150 * @param ModuleHandlerInterface $moduleHandler
5251 */
5352 public function __construct (
5453 DrupalApi $ drupalApi ,
55- QueryFactory $ entityQuery ,
54+ EntityTypeManagerInterface $ entityTypeManager ,
5655 Manager $ extensionManager ,
5756 ModuleHandlerInterface $ moduleHandler
5857 ) {
5958 $ this ->drupalApi = $ drupalApi ;
60- $ this ->entityQuery = $ entityQuery ;
59+ $ this ->entityTypeManager = $ entityTypeManager ;
6160 $ this ->extensionManager = $ extensionManager ;
6261 $ this ->moduleHandler = $ moduleHandler ;
6362 parent ::__construct ();
@@ -131,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
131130
132131 private function getEntitiesCount ($ entity_type , $ condition = [])
133132 {
134- $ entityQuery = $ this ->entityQuery -> get ($ entity_type )->count ();
133+ $ entityQuery = $ this ->entityTypeManager -> getStorage ($ entity_type)-> getQuery ( )->count ();
135134 if (!empty ($ condition )) {
136135 $ entityQuery ->condition ($ condition ['name ' ], $ condition ['value ' ], $ condition ['condition ' ]);
137136 }
0 commit comments