diff --git a/config/schema/diff.schema.yml b/config/schema/diff.schema.yml
index 1efc568..8321192 100644
--- a/config/schema/diff.schema.yml
+++ b/config/schema/diff.schema.yml
@@ -188,12 +188,9 @@ diff.layout_plugins:
type: text
label: 'Plugin key'
settings:
- type: diff.plugin.settings.[%parent.type]
+ type: diff.layout_plugin.settings.[%parent.type]
diff.layout_plugin.settings_base:
type: mapping
label: 'Settings for base diff layout plugin'
mapping:
- markdown:
- type: string
- label: 'Mark-down function ID'
diff --git a/diff.api.php b/diff.api.php
index 8d5661c..e0f6e0d 100644
--- a/diff.api.php
+++ b/diff.api.php
@@ -43,5 +43,18 @@ function hook_field_diff_builder_info_alter(&$diff_builders) {
}
/**
+ * Alter the information provided in \Drupal\diff\Annotation\DiffLayoutBuilder.
+ *
+ * @param $diff_layouts
+ * The array of diff layout builders plugins, keyed on the machine-readable
+ * plugin name.
+ */
+function hook_diff_layout_builder_info_alter(&$diff_layouts) {
+ // Set a new label for the text_field_diff_builder plugin
+ // instead of the one provided in the annotation.
+ $diff_layouts['my_layout']['label'] = t('New label');
+}
+
+/**
* @} End of "addtogroup hooks".
*/
diff --git a/src/Controller/GenericRevisionController.php b/src/Controller/GenericRevisionController.php
deleted file mode 100644
index f9fbde1..0000000
--- a/src/Controller/GenericRevisionController.php
+++ /dev/null
@@ -1,398 +0,0 @@
-date = $date;
- $this->config = $this->config('diff.settings');
- $this->nonBreakingSpace = new FormattableMarkup(' ', array());
- $this->entityComparison = $entityComparison;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('date.formatter'),
- $container->get('diff.entity_comparison')
- );
- }
-
- /**
- * Get all the revision ids of given entity id.
- *
- * @param $storage
- * The entity storage manager.
- * @param $entity_id
- * The entity to find revisions of.
- *
- * @return array
- */
- protected function getVids(EntityStorageInterface $storage, $entity_id) {
- $result = $storage->getQuery()
- ->allRevisions()
- ->condition($storage->getEntityType()->getKey('id'), $entity_id)
- ->execute();
- $result_array = array_keys($result);
- sort($result_array);
- return $result_array;
- }
-
- /**
- * Returns a table which shows the differences between two entity revisions.
- *
- * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
- * The route match.
- * @param \Drupal\Core\Entity\EntityInterface $left_revision
- * The left revision.
- * @param \Drupal\Core\Entity\EntityInterface $right_revision
- * The right revision.
- * @param string $filter
- * If $filter == 'raw' raw text is compared (including html tags)
- * If filter == 'raw-plain' markdown function is applied to the text before comparison.
- *
- * @return array
- * Table showing the diff between the two entity revisions.
- */
- public function compareEntityRevisions(RouteMatchInterface $route_match, EntityInterface $left_revision, EntityInterface $right_revision, $filter) {
- $entity_type_id = $left_revision->getEntityTypeId();
- $entity = $route_match->getParameter($entity_type_id);
- $diff_rows = array();
- $build = array(
- '#title' => $this->t('Changes to %title', ['%title' => $entity->label()]),
- );
- if (!in_array($filter, array('raw', 'raw-plain'))) {
- $filter = 'raw';
- }
- elseif ($filter == 'raw-plain') {
- $filter = 'raw_plain';
- }
-
- $entity_type_id = $entity->getEntityTypeId();
- $storage = $this->entityTypeManager()->getStorage($entity_type_id);
-
- // Get language from the entity context.
- $langcode = $entity->language()->getId();
-
- // Get left and right revision in current language.
- $left_revision = $left_revision->getTranslation($langcode);
- $right_revision = $right_revision->getTranslation($langcode);
-
- $vids = [];
- // Filter revisions of current translation and where the translation is
- // affected.
- foreach ($this->getVids($storage, $entity->id()) as $vid) {
- $revision = $storage->loadRevision($vid);
- if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
- $vids[] = $vid;
- }
- }
- $diff_header = $this->buildTableHeader($left_revision, $right_revision);
-
- // Build the layout filter.
- $build['diff_layout'] = [
- '#type' => 'item',
- '#title' => $this->t('Layout'),
- ];
- $build['diff_layout']['filter'] = $this->buildMarkdownNavigation($entity, $left_revision->getRevisionId(), $right_revision->getRevisionId(), $filter);
-
- // Build the navigation links.
- $build['diff_navigation'] = $this->buildRevisionsNavigation($entity, $vids, $left_revision->getRevisionId(), $right_revision->getRevisionId());
-
- // Perform comparison only if both entity revisions loaded successfully.
- if ($left_revision != FALSE && $right_revision != FALSE) {
- $fields = $this->entityComparison->compareRevisions($left_revision, $right_revision);
- // Build the diff rows for each field and append the field rows
- // to the table rows.
- foreach ($fields as $field) {
- $field_label_row = '';
- if (!empty($field['#name'])) {
- $field_label_row = array(
- 'data' => $this->t('%name', ['%name' => $field['#name']]),
- 'colspan' => 4,
- 'class' => array('field-name'),
- );
- }
- $field_diff_rows = $this->entityComparison->getRows(
- $field['#states'][$filter]['#left'],
- $field['#states'][$filter]['#right']
- );
-
- // Add the field label to the table only if there are changes to that field.
- if (!empty($field_diff_rows) && !empty($field_label_row)) {
- $diff_rows[] = array($field_label_row);
- }
-
- // Add field diff rows to the table rows.
- $diff_rows = array_merge($diff_rows, $field_diff_rows);
- }
-
- // Add the CSS for the diff.
- $build['#attached']['library'][] = 'diff/diff.general';
- $build['#attached']['library'][] = 'diff/diff.github';
-
- $build['diff'] = array(
- '#type' => 'table',
- '#header' => $diff_header,
- '#rows' => $diff_rows,
- '#empty' => $this->t('No visible changes'),
- '#attributes' => array(
- 'class' => array('diff'),
- ),
- );
-
- if ($entity->hasLinkTemplate('version-history')) {
- $build['back'] = array(
- '#type' => 'link',
- '#attributes' => array(
- 'class' => array(
- 'button',
- 'diff-button',
- ),
- ),
- '#title' => $this->t('Back to Revision Overview'),
- '#url' => Url::fromRoute("entity.$entity_type_id.version_history", [$entity_type_id => $entity->id()]),
- );
- }
-
- return $build;
- }
- else {
- // @todo When task 'Convert drupal_set_message() to a service' (2278383)
- // will be merged use the corresponding service instead.
- drupal_set_message($this->t('Selected @label revisions could not be loaded.', ['@label' => $entity->getEntityType()->getLabel()]), 'error');
- }
- }
-
- /**
- * Build the header for the diff table.
- *
- * @param \Drupal\Core\Entity\EntityInterface $left_revision
- * Revision from the left hand side.
- * @param \Drupal\Core\Entity\EntityInterface $right_revision
- * Revision from the right hand side.
- *
- * @return array
- * Header for Diff table.
- */
- protected function buildTableHeader(EntityInterface $left_revision, EntityInterface $right_revision) {
- $header = [];
- // @todo When theming think about where in the table to integrate this
- // link to the revision user. There is some issue about multi-line headers
- // for theme table.
- // $header[] = array(
- // 'data' => $this->t('by' . '!username', array('!username' => drupal_render($username))),
- // 'colspan' => 1,
- // );
-
- $header[] = [
- 'data' => ['#markup' => $this->buildRevisionLink($left_revision)],
- 'colspan' => 2,
- ];
- $header[] = [
- 'data' => ['#markup' => $this->buildRevisionLink($right_revision)],
- 'colspan' => 2,
- ];
-
- return $header;
- }
-
- /**
- * Build the revision link for a revision.
- *
- * @param \Drupal\Core\Entity\EntityInterface $revision
- * A revision where to add a link.
- *
- * @return \Drupal\Core\GeneratedLink
- * Header link for a revision in the table.
- */
- protected function buildRevisionLink(EntityInterface $revision) {
- $entity_type_id = $revision->getEntityTypeId();
- if ($revision instanceof EntityRevisionLogInterface || $revision instanceof NodeInterface) {
- $revision_log = $this->nonBreakingSpace;
-
- if ($revision instanceof EntityRevisionLogInterface) {
- $revision_log = Xss::filter($revision->getRevisionLogMessage());
- }
- elseif ($revision instanceof NodeInterface) {
- $revision_log = $revision->revision_log->value;
- }
- $username = [
- '#theme' => 'username',
- '#account' => $revision->uid->entity,
- ];
- $revision_date = $this->date->format($revision->getRevisionCreationTime(), 'short');
- $route_name = $entity_type_id != 'node' ? "entity.$entity_type_id.revisions_diff" : 'entity.node.revision';
- $revision_link = $this->t($revision_log . '@date', [
- '@date' => $this->l($revision_date, Url::fromRoute($route_name, [
- $entity_type_id => $revision->id(),
- $entity_type_id . '_revision' => $revision->getRevisionId(),
- ])),
- ]);
- }
- else {
- $revision_link = $this->l($revision->label(), $revision->toUrl('revision'));
- }
- return $revision_link;
- }
-
- /**
- * Returns the navigation row for diff table.
- */
- protected function buildRevisionsNavigation(EntityInterface $entity, $vids, $left_vid, $right_vid) {
- $revisions_count = count($vids);
- // If there are only 2 revision return an empty row.
- if ($revisions_count == 2) {
- return [];
- }
- else {
- $left_link = $right_link = '';
- $element['diff_navigation'] = [
- '#type' => 'item',
- '#title' => $this->t('Navigation'),
- ];
- $i = 0;
- // Find the previous revision.
- while ($left_vid > $vids[$i]) {
- $i += 1;
- }
- if ($i != 0) {
- // build the left link.
- $left_link = $this->l($this->t('< Previous difference'), $this->diffRoute($entity, $vids[$i - 1], $left_vid));
- }
- $element['diff_navigation']['left'] = [
- '#type' => 'markup',
- '#markup' => $left_link,
- '#prefix' => '',
- '#suffix' => '',
- ];
- // Find the next revision.
- $i = 0;
- while ($i < $revisions_count && $right_vid >= $vids[$i]) {
- $i += 1;
- }
- if ($revisions_count != $i && $vids[$i - 1] != $vids[$revisions_count - 1]) {
- // Build the right link.
- $right_link = $this->l($this->t('Next difference >'), $this->diffRoute($entity, $right_vid, $vids[$i]));
- }
- $element['diff_navigation']['right'] = [
- '#type' => 'markup',
- '#markup' => $right_link,
- '#prefix' => '',
- '#suffix' => '',
- ];
- return $element;
- }
- }
-
- /**
- * Builds a table row with navigation between raw and raw-plain formats.
- */
- protected function buildMarkdownNavigation(EntityInterface $entity, $left_vid, $right_vid, $active_filter) {
- $links['raw'] = array(
- 'title' => $this->t('Standard'),
- 'url' => $this->diffRoute($entity, $left_vid, $right_vid),
- );
- $links['raw_plain'] = array(
- 'title' => $this->t('Markdown'),
- 'url' => $this->diffRoute($entity, $left_vid, $right_vid, 'raw-plain'),
- );
-
- // Set as the first element the current filter.
- $filter = $links[$active_filter];
- unset($links[$active_filter]);
- array_unshift($links, $filter);
-
- $filter = [
- '#type' => 'dropbutton',
- '#links' => $links,
- '#prefix' => '
',
- '#suffix' => '
',
- ];
-
- return $filter;
- }
-
- /**
- * Creates an url object for diff.
- *
- * @param \Drupal\Core\Entity\EntityInterface $entity
- * The entity to be compared.
- * @param $left_vid
- * Vid of the left revision.
- * @param $right_vid
- * Vid of the right revision.
- * @param $filter
- * (optional) The filter added to the route.
- *
- * @return \Drupal\Core\Url
- * The URL object.
- */
- protected function diffRoute(EntityInterface $entity, $left_vid, $right_vid, $filter = NULL) {
- $entity_type_id = $entity->getEntityTypeId();
- // @todo Remove the diff.revisions_diff route so we avoid adding extra cases.
- if ($entity->getEntityTypeId() == 'node') {
- $route_name = 'diff.revisions_diff';
- }
- else {
- $route_name = "entity.$entity_type_id.revisions_diff";
- }
- $route_parameters = [
- $entity_type_id => $entity->id(),
- 'left_revision' => $left_vid,
- 'right_revision' => $right_vid,
- ];
- if ($filter) {
- $route_parameters['filter'] = $filter;
- }
- return Url::fromRoute($route_name, $route_parameters);
- }
-}
diff --git a/src/Controller/PluginRevisionController.php b/src/Controller/PluginRevisionController.php
index c47a807..07cae4f 100644
--- a/src/Controller/PluginRevisionController.php
+++ b/src/Controller/PluginRevisionController.php
@@ -67,7 +67,7 @@ class PluginRevisionController extends ControllerBase {
*
* @return array
*/
- public function getVids(EntityStorageInterface $storage, $entity_id) {
+ public function getRevisionIds(EntityStorageInterface $storage, $entity_id) {
$result = $storage->getQuery()
->allRevisions()
->condition($storage->getEntityType()->getKey('id'), $entity_id)
@@ -106,13 +106,13 @@ class PluginRevisionController extends ControllerBase {
$left_revision = $left_revision->getTranslation($langcode);
$right_revision = $right_revision->getTranslation($langcode);
- $vids = [];
+ $revisions_ids = [];
// Filter revisions of current translation and where the translation is
// affected.
- foreach ($this->getVids($storage, $entity->id()) as $vid) {
- $revision = $storage->loadRevision($vid);
+ foreach ($this->getRevisionIds($storage, $entity->id()) as $revision_id) {
+ $revision = $storage->loadRevision($revision_id);
if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
- $vids[] = $vid;
+ $revisions_ids[] = $revision_id;
}
}
@@ -125,16 +125,17 @@ class PluginRevisionController extends ControllerBase {
'#type' => 'item',
'#title' => $this->t('Layout'),
];
- $build['diff_layout']['filter'] = $this->buildMarkdownNavigation($entity, $left_revision->getRevisionId(), $right_revision->getRevisionId(), $filter);
+ $build['diff_layout']['filter'] = $this->buildLayoutNavigation($entity, $left_revision->getRevisionId(), $right_revision->getRevisionId(), $filter);
// Build the navigation links.
- $build['diff_navigation'] = $this->buildRevisionsNavigation($entity, $vids, $left_revision->getRevisionId(), $right_revision->getRevisionId());
+ $build['diff_navigation'] = $this->buildRevisionsNavigation($entity, $revisions_ids, $left_revision->getRevisionId(), $right_revision->getRevisionId());
// Perform comparison only if both entity revisions loaded successfully.
if ($left_revision != FALSE && $right_revision != FALSE) {
// Build the diff comparison with the plugin.
- $plugin = $this->diffLayoutManager->createInstance($filter);
- $build = $plugin->build($build, $left_revision, $right_revision, $entity);
+ if ($plugin = $this->diffLayoutManager->createInstance($filter)) {
+ $build += $plugin->build($left_revision, $right_revision, $entity);
+ }
}
$build['#attached']['library'][] = 'diff/diff.general';
@@ -142,14 +143,26 @@ class PluginRevisionController extends ControllerBase {
}
/**
- * Builds a table row with navigation between raw and raw-plain formats.
+ * Builds a table row with navigation between the layout plugins.
+ *
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ * The entity to be compared.
+ * @param $left_revision_id
+ * Revision id of the left revision.
+ * @param $right_revision_id
+ * Revision id of the right revision.
+ * @param $active_filter
+ * The active filter.
+ *
+ * @return array
+ * The layout filter.
*/
- protected function buildMarkdownNavigation(EntityInterface $entity, $left_vid, $right_vid, $active_filter) {
+ protected function buildLayoutNavigation(EntityInterface $entity, $left_revision_id, $right_revision_id, $active_filter) {
$links = [];
foreach ($this->diffLayoutManager->getDefinitions() as $key => $value) {
$links[$key] = array(
'title' => $value['label'],
- 'url' => $this->diffRoute($entity, $left_vid, $right_vid, $key),
+ 'url' => $this->diffRoute($entity, $left_revision_id, $right_revision_id, $key),
);
}
@@ -168,8 +181,23 @@ class PluginRevisionController extends ControllerBase {
return $filter;
}
- protected function buildRevisionsNavigation(EntityInterface $entity, $vids, $left_vid, $right_vid) {
- $revisions_count = count($vids);
+ /**
+ * Creates an url object for diff.
+ *
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ * The entity to be compared.
+ * @param $revision_ids
+ * The revision ids.
+ * @param $left_revision_id
+ * Revision id of the left revision.
+ * @param $right_revision_id
+ * Revision id of the right revision.
+ *
+ * @return array
+ * The revision navigation links.
+ */
+ protected function buildRevisionsNavigation(EntityInterface $entity, $revision_ids, $left_revision_id, $right_revision_id) {
+ $revisions_count = count($revision_ids);
// If there are only 2 revision return an empty row.
if ($revisions_count == 2) {
return [];
@@ -182,12 +210,12 @@ class PluginRevisionController extends ControllerBase {
];
$i = 0;
// Find the previous revision.
- while ($left_vid > $vids[$i]) {
+ while ($left_revision_id > $revision_ids[$i]) {
$i += 1;
}
if ($i != 0) {
// build the left link.
- $left_link = $this->l($this->t('< Previous difference'), $this->diffRoute($entity, $vids[$i - 1], $left_vid));
+ $left_link = $this->l($this->t('< Previous difference'), $this->diffRoute($entity, $revision_ids[$i - 1], $left_revision_id));
}
$element['diff_navigation']['left'] = [
'#type' => 'markup',
@@ -197,12 +225,12 @@ class PluginRevisionController extends ControllerBase {
];
// Find the next revision.
$i = 0;
- while ($i < $revisions_count && $right_vid >= $vids[$i]) {
+ while ($i < $revisions_count && $right_revision_id >= $revision_ids[$i]) {
$i += 1;
}
- if ($revisions_count != $i && $vids[$i - 1] != $vids[$revisions_count - 1]) {
+ if ($revisions_count != $i && $revision_ids[$i - 1] != $revision_ids[$revisions_count - 1]) {
// Build the right link.
- $right_link = $this->l($this->t('Next difference >'), $this->diffRoute($entity, $right_vid, $vids[$i]));
+ $right_link = $this->l($this->t('Next difference >'), $this->diffRoute($entity, $right_revision_id, $revision_ids[$i]));
}
$element['diff_navigation']['right'] = [
'#type' => 'markup',
@@ -219,17 +247,17 @@ class PluginRevisionController extends ControllerBase {
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to be compared.
- * @param $left_vid
- * Vid of the left revision.
- * @param $right_vid
- * Vid of the right revision.
+ * @param $left_revision_id
+ * Revision id of the left revision.
+ * @param $right_revision_id
+ * Revision id of the right revision.
* @param $filter
* (optional) The filter added to the route.
*
* @return \Drupal\Core\Url
* The URL object.
*/
- public function diffRoute(EntityInterface $entity, $left_vid, $right_vid, $filter = NULL) {
+ public function diffRoute(EntityInterface $entity, $left_revision_id, $right_revision_id, $filter = NULL) {
$entity_type_id = $entity->getEntityTypeId();
// @todo Remove the diff.revisions_diff route so we avoid adding extra cases.
if ($entity->getEntityTypeId() == 'node') {
@@ -240,8 +268,8 @@ class PluginRevisionController extends ControllerBase {
}
$route_parameters = [
$entity_type_id => $entity->id(),
- 'left_revision' => $left_vid,
- 'right_revision' => $right_vid,
+ 'left_revision' => $left_revision_id,
+ 'right_revision' => $right_revision_id,
];
if ($filter) {
$route_parameters['filter'] = $filter;
diff --git a/src/DiffLayoutBase.php b/src/DiffLayoutBase.php
index 8f67beb..68ff102 100644
--- a/src/DiffLayoutBase.php
+++ b/src/DiffLayoutBase.php
@@ -52,10 +52,10 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
* The entity manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, EntityTypeManagerInterface $entity_type_manager, DiffEntityParser $entityParser) {
+ parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config;
$this->entityTypeManager = $entity_type_manager;
$this->entityParser = $entityParser;
- parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configuration += $this->defaultConfiguration();
}
@@ -77,21 +77,18 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- // @todo Implement buildConfigurationForm() method.
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
- // @todo Implement validateConfigurationForm() method.
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
- // @todo Implement submitConfigurationForm() method.
}
/**
@@ -105,14 +102,16 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
* {@inheritdoc}
*/
public function getConfiguration() {
- // @todo Implement getConfiguration() method.
+ return $this->configFactory->getEditable('diff.layout_plugins');
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
- // @todo Implement setConfiguration() method.
+ $config = $this->configFactory->getEditable('diff.layout_plugins');
+ $config->set($this->pluginId, $configuration);
+ $config->save();
}
/**
diff --git a/src/DiffLayoutInterface.php b/src/DiffLayoutInterface.php
index dcfccc5..c518641 100644
--- a/src/DiffLayoutInterface.php
+++ b/src/DiffLayoutInterface.php
@@ -5,7 +5,6 @@ namespace Drupal\diff;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
-use Drupal\Core\Routing\RouteMatchInterface;
interface DiffLayoutInterface extends PluginFormInterface, ConfigurablePluginInterface {
@@ -16,10 +15,8 @@ interface DiffLayoutInterface extends PluginFormInterface, ConfigurablePluginInt
* revisions of the same entity. It can build a table, navigation links and
* headers of a diff comparison.
*
- * @see \Drupal\diff\Plugin\Layout\ClassicDiffLayout
+ * @see \Drupal\Plugin\Layout\ClassicDiffLayout
*
- * @param array $build
- * A renderable array of data.
* @param \Drupal\Core\Entity\EntityInterface $left_revision
* The left revision.
* @param \Drupal\Core\Entity\EntityInterface $right_revision
@@ -30,5 +27,5 @@ interface DiffLayoutInterface extends PluginFormInterface, ConfigurablePluginInt
* @return mixed
* The modified build array that the plugin builds.
*/
- public function build(array $build, EntityInterface $left_revision, EntityInterface $right_revision, EntityInterface $entity);
+ public function build(EntityInterface $left_revision, EntityInterface $right_revision, EntityInterface $entity);
}
diff --git a/src/DiffLayoutManager.php b/src/DiffLayoutManager.php
index 9d3f781..bb58dc5 100644
--- a/src/DiffLayoutManager.php
+++ b/src/DiffLayoutManager.php
@@ -6,9 +6,6 @@ use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\Field\BaseFieldDefinition;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
/**
@@ -53,6 +50,8 @@ class DiffLayoutManager extends DefaultPluginManager {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $configFactory) {
parent::__construct('Plugin/Layout', $namespaces, $module_handler, '\Drupal\diff\DiffLayoutInterface', 'Drupal\diff\Annotation\DiffLayoutBuilder');
+ $this->setCacheBackend($cache_backend, 'diff_layout_builder_plugins');
+ $this->alterInfo('field_diff_builder_info');
$this->entityTypeManager = $entity_type_manager;
$this->config = $configFactory->get('diff.settings');
$this->layoutPluginsConfig = $configFactory->get('diff.layout_plugins');
diff --git a/src/Plugin/Layout/ClassicDiffLayout.php b/src/Plugin/Layout/ClassicDiffLayout.php
index 9afeb2e..efc741d 100644
--- a/src/Plugin/Layout/ClassicDiffLayout.php
+++ b/src/Plugin/Layout/ClassicDiffLayout.php
@@ -87,7 +87,7 @@ class ClassicDiffLayout extends DiffLayoutBase {
/**
* {@inheritdoc}
*/
- public function build(array $build, EntityInterface $left_revision, EntityInterface $right_revision, EntityInterface $entity) {
+ public function build(EntityInterface $left_revision, EntityInterface $right_revision, EntityInterface $entity) {
$diff_header = $this->buildTableHeader($left_revision, $right_revision);
// Perform comparison only if both entity revisions loaded successfully.
$fields = $this->entityComparison->compareRevisions($left_revision, $right_revision);
diff --git a/src/Plugin/Layout/MarkdownDiffLayout.php b/src/Plugin/Layout/MarkdownDiffLayout.php
index 4d2d6a4..2b2c3c5 100644
--- a/src/Plugin/Layout/MarkdownDiffLayout.php
+++ b/src/Plugin/Layout/MarkdownDiffLayout.php
@@ -88,7 +88,7 @@ class MarkdownDiffLayout extends DiffLayoutBase {
/**
* {@inheritdoc}
*/
- public function build(array $build, EntityInterface $left_revision, EntityInterface $right_revision, EntityInterface $entity) {
+ public function build(EntityInterface $left_revision, EntityInterface $right_revision, EntityInterface $entity) {
$diff_header = $this->buildTableHeader($left_revision, $right_revision);
// Perform comparison only if both entity revisions loaded successfully.
$fields = $this->entityComparison->compareRevisions($left_revision, $right_revision);