Skip to content

Commit 54bd2fb

Browse files
committed
content_moderation: WIP.
1 parent cb8d3e1 commit 54bd2fb

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/Workflows/ContentModerationGraph.php

+13-11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
namespace Drupal\qa\Workflows;
44

55
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
6-
use Drupal\Core\Entity\EntityStorageInterface;
6+
use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
7+
use Drupal\Core\Entity\ContentEntityStorageInterface;
78
use Drupal\Core\Entity\EntityTypeManagerInterface;
89
use Drupal\Core\StringTranslation\StringTranslationTrait;
10+
use Drupal\qa\Workflows\ContentModerationReportBase;
911
use Grafizzi\Graph\Attribute;
1012
use Grafizzi\Graph\Edge;
1113
use Grafizzi\Graph\Graph;
1214
use Grafizzi\Graph\Node;
13-
use Monolog\Handler\StreamHandler;
14-
use Monolog\Logger;
1515
use Pimple\Container;
1616
use Symfony\Component\DependencyInjection\ContainerInterface;
1717

@@ -26,10 +26,10 @@ class ContentModerationGraph extends ContentModerationReportBase implements Cont
2626
*/
2727
protected $pimple;
2828

29-
public function __construct(EntityStorageInterface $stateStorage, EntityStorageInterface $transStorage, Container $pimple) {
29+
public function __construct(ContentEntityStorageInterface $stateStorage, ConfigEntityStorageInterface $workflowStorage, Container $pimple) {
3030
$this->pimple = $pimple;
3131
$this->stateStorage = $stateStorage;
32-
$this->transStorage = $transStorage;
32+
$this->workflowStorage = $workflowStorage;
3333
}
3434

3535
/**
@@ -84,19 +84,21 @@ public static function create(ContainerInterface $container) {
8484
/** @var EntityTypeManagerInterface $etm */
8585
$etm = $container->get('entity_type.manager');
8686

87-
$stateStorage = $etm->getStorage('moderation_state');
88-
$transStorage = $etm->getStorage('moderation_state_transition');
87+
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $stateStorage */
88+
$stateStorage = $etm->getStorage('content_moderation_state');
8989

90-
$logger = new Logger(basename(__FILE__, '.php'));
91-
// Change the minimum logging level using the Logger:: constants.
92-
$logger->pushHandler(new StreamHandler('php://stderr', Logger::INFO));
90+
/** @var \Psr\Log\LoggerInterface $logger */
91+
$logger = $container->get('logger.channel.qa');
92+
93+
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $stateStorage */
94+
$workflowStorage = $etm->getStorage('workflow');
9395

9496
$pimple = new Container([
9597
'logger' => $logger,
9698
'directed' => TRUE,
9799
]);
98100

99-
return new static($stateStorage, $transStorage, $pimple);
101+
return new static($stateStorage, $workflowStorage, $pimple);
100102
}
101103

102104
public function report() {

src/Workflows/ContentModerationReportBase.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\magpjm\Workflows;
3+
namespace Drupal\qa\Workflows;
44

55
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
66
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -11,14 +11,13 @@ abstract class ContentModerationReportBase implements ContainerInjectionInterfac
1111

1212
protected $stateStorage;
1313

14-
protected $transStorage;
14+
protected $workflowStorage;
1515

1616
protected function buildGrid() {
1717
$grid = [];
1818
$stateIds = array_keys($this->getStates());
19-
$stateCells = array_map(function ($stateId) {
20-
return [];
21-
}, array_flip($stateIds));
19+
20+
$stateCells = array_fill(0, count($stateIds), []);
2221

2322
foreach ($stateIds as $stateId) {
2423
$grid[$stateId] = $stateCells;
@@ -50,6 +49,7 @@ public function getDuplicateTransLabels() {
5049

5150
protected function getStates() {
5251
$fullStates = $this->stateStorage->loadMultiple();
52+
print_R($fullStates);
5353
$simpleStates = array_map(function ($entity) {
5454
return $entity->label();
5555
}, $fullStates);
@@ -58,7 +58,7 @@ protected function getStates() {
5858
}
5959

6060
protected function getTrans() {
61-
$fullTrans = $this->transStorage->loadMultiple();
61+
$fullTrans = $this->workflowStorage->loadMultiple();
6262
$simpleTrans = array_map(function ($trans) {
6363
return [
6464
'label' => $trans->label(),

0 commit comments

Comments
 (0)