Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / diff / src / Controller / NodeRevisionController.php
1 <?php
2
3 namespace Drupal\diff\Controller;
4
5 use Drupal\node\NodeInterface;
6
7 /**
8  * Returns responses for Node Revision routes.
9  */
10 class NodeRevisionController extends PluginRevisionController {
11
12   /**
13    * Returns a form for revision overview page.
14    *
15    * @todo This might be changed to a view when the issue at this link is
16    *   resolved: https://drupal.org/node/1863906
17    *
18    * @param \Drupal\node\NodeInterface $node
19    *   The node whose revisions are inspected.
20    *
21    * @return array
22    *   Render array containing the revisions table for $node.
23    */
24   public function revisionOverview(NodeInterface $node) {
25     return $this->formBuilder()->getForm('Drupal\diff\Form\RevisionOverviewForm', $node);
26   }
27
28   /**
29    * Returns a table which shows the differences between two node revisions.
30    *
31    * @param \Drupal\node\NodeInterface $node
32    *   The node whose revisions are compared.
33    * @param int $left_revision
34    *   Vid of the node revision from the left.
35    * @param int $right_revision
36    *   Vid of the node revision from the right.
37    * @param string $filter
38    *   If $filter == 'raw' raw text is compared (including html tags)
39    *   If $filter == 'raw-plain' markdown function is applied to the text before comparison.
40    *
41    * @return array
42    *   Table showing the diff between the two node revisions.
43    */
44   public function compareNodeRevisions(NodeInterface $node, $left_revision, $right_revision, $filter) {
45     $storage = $this->entityTypeManager()->getStorage('node');
46     $route_match = \Drupal::routeMatch();
47     $left_revision = $storage->loadRevision($left_revision);
48     $right_revision = $storage->loadRevision($right_revision);
49     $build = $this->compareEntityRevisions($route_match, $left_revision, $right_revision, $filter);
50     return $build;
51   }
52
53 }