Commit 8b2afef4 authored by Jacob Rockowitz's avatar Jacob Rockowitz Committed by Jacob Rockowitz
Browse files

Issue #2704691 by jrockowitz: Convert NodeOrderManager to a Service with an Interface

parent 7934a27a
Loading
Loading
Loading
Loading
+629 −0
Original line number Diff line number Diff line
diff --git a/nodeorder.module b/nodeorder.module
index cfa221d..89b58c2 100755
--- a/nodeorder.module
+++ b/nodeorder.module
@@ -8,7 +8,6 @@
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\node\NodeInterface;
-use Drupal\nodeorder\NodeOrderManager;
 use Drupal\taxonomy\Entity\Vocabulary;
 
 /**
@@ -20,8 +19,11 @@ use Drupal\taxonomy\Entity\Vocabulary;
  * Implements hook_form_FORM_ID_alter() for taxonomy_overview_terms().
  */
 function nodeorder_form_taxonomy_overview_terms_alter(&$form, FormStateInterface $form_state) {
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
   $vocabulary = $form_state->get(['taxonomy', 'vocabulary']);
-  if (!NodeOrderManager::vocabularyIsOrderable($vocabulary->id())) {
+  if (!$nodeorder_manager->vocabularyIsOrderable($vocabulary->id())) {
     return;
   }
   // This is a hack to include an 'order' link in the 'Operations' column, but
@@ -58,6 +60,10 @@ function nodeorder_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterfac
   if ($form_state->get('confirm_delete')) {
     return;
   }
+
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
   $vocabulary = $form_state->getFormObject()->getEntity();
 
   $form['nodeorder'] = array(
@@ -69,7 +75,7 @@ function nodeorder_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterfac
     '#type' => 'checkbox',
     '#title' => t('Orderable'),
     '#description' => t('If enabled, nodes may be ordered within this vocabulary.'),
-    '#default_value' => NodeOrderManager::vocabularyIsOrderable($vocabulary->id()),
+    '#default_value' => $nodeorder_manager->vocabularyIsOrderable($vocabulary->id()),
   );
 
   // Add a submit handler for saving the orderable settings.
@@ -80,6 +86,9 @@ function nodeorder_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterfac
  * Submit handler for nodeorder_form_taxonomy_vocabulary_form_alter().
  */
 function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $form_state) {
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
   $vocabulary = $form_state->getFormObject()->getEntity();
   $config = \Drupal::configFactory()->getEditable('nodeorder.settings');
   $orderable = $form_state->getValue('orderable');
@@ -108,7 +117,7 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
       foreach ($tids as $i => $tid) {
         // Select *current* nodes for the current term.
         // @todo: Replace this hacked function call.
-        $result = NodeOrderManager::selectNodes(array($tid), 'and', 0, FALSE, $order, 0);
+        $result = $nodeorder_manager->selectNodes(array($tid), 'and', 0, FALSE, $order, 0);
 
         foreach ($result as $node) {
           $max = $query_max->execute()->fetchField();
@@ -156,7 +165,10 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
  * Implements hook_node_presave().
  */
 function nodeorder_node_presave(NodeInterface $node) {
-  if (NodeOrderManager::canBeOrdered($node)) {
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
+  if ($nodeorder_manager->canBeOrdered($node)) {
     // Store the old node orders for use in nodeorder_node_update().
     $node->nodeorder = [];
     // When a node is created, store an element called 'nodeorder' that
@@ -177,10 +189,13 @@ function nodeorder_node_presave(NodeInterface $node) {
  * Handle lists in which the node is removed.
  */
 function nodeorder_node_delete(NodeInterface $node) {
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
   // Get tids from node var; in the database they're already removed.
-  $tids = NodeOrderManager::getOrderableTidsFromNode($node);
+  $tids = $nodeorder_manager->getOrderableTidsFromNode($node);
   foreach ($tids as $tid) {
-    NodeOrderManager::handleListsDecrease($tid);
+    $nodeorder_manager->handleListsDecrease($tid);
   }
 }
 
@@ -190,9 +205,12 @@ function nodeorder_node_delete(NodeInterface $node) {
  * Handle the weights of the node in the taxonomy orderable lists it id added.
  */
 function nodeorder_node_insert(NodeInterface $node) {
-  $tids = NodeOrderManager::getOrderableTids($node, TRUE);
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
+  $tids = $nodeorder_manager->getOrderableTids($node, TRUE);
   foreach ($tids as $tid) {
-    NodeOrderManager::addToList($node, $tid);
+    $nodeorder_manager->addToList($node, $tid);
   }
 }
 
@@ -202,10 +220,13 @@ function nodeorder_node_insert(NodeInterface $node) {
  * Handle the weights, which were reset on rebuild of the taxonomy.
  */
 function nodeorder_node_update(NodeInterface $node) {
-  if (!NodeOrderManager::canBeOrdered($node)) {
+  /** @var \Drupal\nodeorder\NodeOrderManagerInterface $nodeorder_manager */
+  $nodeorder_manager = \Drupal::service('nodeorder.manager');
+
+  if (!$nodeorder_manager->canBeOrdered($node)) {
     return;
   }
-  $tids = NodeOrderManager::getOrderableTids($node, TRUE);
+  $tids = $nodeorder_manager->getOrderableTids($node, TRUE);
   $old_tids = $node->nodeorder;
   foreach ($tids as $tid) {
     // Restore weight of unchanged terms, or leave as is if zero.
@@ -222,7 +243,7 @@ function nodeorder_node_update(NodeInterface $node) {
     }
     // Push new or newly orderable node to top of ordered list.
     else {
-      NodeOrderManager::addToList($node, $tid);
+      $nodeorder_manager->addToList($node, $tid);
     }
   }
 
@@ -230,7 +251,7 @@ function nodeorder_node_update(NodeInterface $node) {
   // Note that the old tids are at this point only the ones that were not
   // updated, the others were dropped when restoring above.
   foreach ($old_tids as $tid => $weight) {
-    NodeOrderManager::handleListsDecrease($tid);
+    $nodeorder_manager->handleListsDecrease($tid);
   }
 
 }
diff --git a/nodeorder.services.yml b/nodeorder.services.yml
new file mode 100755
index 0000000..583913d
--- /dev/null
+++ b/nodeorder.services.yml
@@ -0,0 +1,4 @@
+services:
+  nodeorder.manager:
+    class: Drupal\nodeorder\NodeOrderManager
+    arguments: ['@config.factory', '@entity.manager']
diff --git a/src/NodeOrderManager.php b/src/NodeOrderManager.php
index 97dfb01..f1ae6bf 100644
--- a/src/NodeOrderManager.php
+++ b/src/NodeOrderManager.php
@@ -6,26 +6,51 @@
  */
 
 namespace Drupal\nodeorder;
+
 use Drupal\Core\Cache\Cache;
 use Drupal\node\NodeInterface;
 use Drupal\taxonomy\Entity\Vocabulary;
+use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Entity\EntityManagerInterface;
 
 /**
- * The NodeOrderManager contains helper functions for the nodeorder module.
+ * Defines a service that creates and manages noder ordering within taxonomy terms.
  */
-class NodeOrderManager {
+class NodeOrderManager implements NodeOrderManagerInterface {
+
+  /**
+   * The configuration object factory.
+   *
+   * @var \Drupal\Core\Config\ConfigFactoryInterface
+   */
+  protected $configFactory;
+
+  /**
+   * Taxonomy term storage.
+   *
+   * @var \Drupal\taxonomy\TermStorageInterface
+   */
+  protected $termStorage;
 
   /**
-   * Push new or newly orderable node to the top of ordered list.
+   * Constructs a NodeOrderManager object.
    *
-   * @param \Drupal\node\NodeInterface $node
-   *   The node to add to the top of the list.
-   * @param int $tid
-   *   The term ID to order the node in.
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+   *   The configuration object factory.
+   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   *   The entity manager.
    */
-  public static function addToList(NodeInterface $node, $tid) {
+  public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager) {
+    $this->configFactory = $config_factory;
+    $this->termStorage = $entity_manager->getStorage('taxonomy_term');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function addToList(NodeInterface $node, $tid) {
     // Append new orderable node.
-    $weights = static::getTermMinMax($tid); // Get the cached weights.
+    $weights = $this->getTermMinMax($tid); // Get the cached weights.
     db_update('taxonomy_index')
       ->fields(array('weight' => $weights['min'] - 1))
       ->condition('nid', $node->id())
@@ -67,21 +92,10 @@ class NodeOrderManager {
         ->execute();
     }
     // Make sure the weight cache is invalidated.
-    static::getTermMinMax($tid, TRUE);
+    $this->getTermMinMax($tid, TRUE);
   }
 
-  /**
-   * Get the minimum and maximum weights available for ordering nodes on a term.
-   *
-   * @param int $tid
-   *   The tid of the term from which to check values.
-   * @param bool $reset
-   *   (optional) Select from or reset the cache.
-   *
-   * @return array
-   *   An associative array with elements 'min' and 'max'.
-   */
-  public static function getTermMinMax($tid, $reset = FALSE) {
+  public function getTermMinMax($tid, $reset = FALSE) {
     static $min_weights = [];
     static $max_weights = [];
 
@@ -110,50 +124,17 @@ class NodeOrderManager {
   }
 
   /**
-   * Determines if a given vocabulary is orderable.
-   *
-   * @param string $vid
-   *   The vocabulary vid.
-   *
-   * @return bool
-   *   Returns TRUE if the given vocabulary is orderable.
+   * {@inheritdoc}
    */
-  public static function vocabularyIsOrderable($vid) {
-    $vocabularies = \Drupal::config('nodeorder.settings')->get('vocabularies');
+  public function vocabularyIsOrderable($vid) {
+    $vocabularies = $this->configFactory->get('nodeorder.settings')->get('vocabularies');
     return !empty($vocabularies[$vid]);
   }
 
   /**
-   * Finds all nodes that match selected taxonomy conditions.
-   *
-   * NOTE: This is nearly a direct copy of taxonomy_select_nodes() -- see
-   *       http://drupal.org/node/25801 if you find this sort of copy and
-   *       paste upsetting...
-   *
-   *
-   * @param $tids
-   *   An array of term IDs to match.
-   * @param $operator
-   *   How to interpret multiple IDs in the array. Can be "or" or "and".
-   * @param $depth
-   *   How many levels deep to traverse the taxonomy tree. Can be a nonnegative
-   *   integer or "all".
-   * @param $pager
-   *   Whether the nodes are to be used with a pager (the case on most Drupal
-   *   pages) or not (in an XML feed, for example).
-   * @param $order
-   *   The order clause for the query that retrieve the nodes.
-   * @param $count
-   *   If $pager is TRUE, the number of nodes per page, or -1 to use the
-   *   backward-compatible 'default_nodes_main' variable setting.  If $pager
-   *   is FALSE, the total number of nodes to select; or -1 to use the
-   *   backward-compatible 'feed_default_items' variable setting; or 0 to
-   *   select all nodes.
-   *
-   * @return \Drupal\Core\Database\StatementInterface
-   *   A resource identifier pointing to the query results.
+   * {@inheritdoc}
    */
-  public static function selectNodes($tids = [], $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC', $count = -1) {
+  public function selectNodes($tids = [], $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC', $count = -1) {
     if (count($tids) > 0) {
       // For each term ID, generate an array of descendant term IDs to the right depth.
       $descendant_tids = [];
@@ -161,8 +142,8 @@ class NodeOrderManager {
         $depth = NULL;
       }
       foreach ($tids as $index => $tid) {
-        $term = \Drupal::entityManager()->getStorage('taxonomy_term')->load($tid);
-        $tree = \Drupal::entityManager()->getStorage("taxonomy_term")->loadTree($term->getVocabularyId(), $tid, $depth);
+        $term = $this->termStorage->load($tid);
+        $tree = $this->termStorage->loadTree($term->getVocabularyId(), $tid, $depth);
         $descendant_tids[] = array_merge([$tid], array_map(function ($value) { return $value->id(); }, $tree));
       }
 
@@ -190,13 +171,13 @@ class NodeOrderManager {
 
       if ($pager) {
         if ($count == -1) {
-          $count = \Drupal::config('nodeorder.settings')->get('default_nodes_main');
+          $count = $this->configFactory->get('nodeorder.settings')->get('default_nodes_main');
         }
         $result = pager_query($sql, $count, 0, $sql_count, $args);
       }
       else {
         if ($count == -1) {
-          $count = \Drupal::config('nodeorder.settings')->get('feed_default_items');
+          $count = $this->configFactory->get('nodeorder.settings')->get('feed_default_items');
         }
 
         if ($count == 0) {
@@ -214,15 +195,9 @@ class NodeOrderManager {
   }
 
   /**
-   * Determine if a given node can be ordered in any vocabularies.
-   *
-   * @param \Drupal\node\NodeInterface
-   *   The node object.
-   *
-   * @return bool
-   *   Returns TRUE if the node has terms in any orderable vocabulary.
+   * {@inheritdoc}
    */
-  public static function canBeOrdered(NodeInterface $node) {
+  public function canBeOrdered(NodeInterface $node) {
     $cid = 'nodeorder:can_be_ordered:' . $node->getType();
 
     if (($cache = \Drupal::cache()->get($cid)) && !empty($cache->data)) {
@@ -256,22 +231,9 @@ class NodeOrderManager {
   }
 
   /**
-   * Get a list of term IDs on a node that can be ordered.
-   *
-   * This method uses the `taxonomy_index` table to determine which terms on a
-   * node are orderable.
-   *
-   * @see self::getOrderableTidsFromNode()
-   *
-   * @param \Drupal\node\NodeInterface
-   *   The node to check for orderable term IDs.
-   * @param bool
-   *   Flag to reset cached data.
-   *
-   * @return int[]
-   *   Returns an array of the node's tids that are in orderable vocabularies.
+   * {@inheritdoc}
    */
-  public static function getOrderableTids(NodeInterface $node, $reset = FALSE) {
+  public function getOrderableTids(NodeInterface $node, $reset = FALSE) {
     $cid = 'nodeorder:orderable_tids:' . $node->getType();
 
     if (!$reset && ($cache = \Drupal::cache()->get($cid)) && !empty($cache->data)) {
@@ -279,7 +241,7 @@ class NodeOrderManager {
     }
     else {
       $vocabularies = [];
-      foreach (\Drupal::config('nodeorder.settings')->get('vocabularies') as $vid => $orderable) {
+      foreach ($this->configFactory->get('nodeorder.settings')->get('vocabularies') as $vid => $orderable) {
         if ($orderable) {
           $vocabularies[] = $vid;
         }
@@ -304,19 +266,9 @@ class NodeOrderManager {
   }
 
   /**
-   * Get all term IDs on a node that are on orderable vocabularies.
-   *
-   * Returns an array of the node's tids that are in orderable vocabularies.
-   * Slower than self::getOrderableTids() but needed when tids have already been
-   * removed from the database.
-   *
-   * @param \Drupal\node\NodeInterface
-   *   The node to find term IDs for.
-   *
-   * @return int[]
-   *   An array of term IDs.
+   * {@inheritdoc}
    */
-  public static function getOrderableTidsFromNode(NodeInterface $node) {
+  public function getOrderableTidsFromNode(NodeInterface $node) {
     $tids = [];
     foreach ($node->getFieldDefinitions() as $field) {
       if ($field->getType() == 'entity_reference' && $field->getSetting('target_type') == 'taxonomy_term') {
@@ -339,14 +291,9 @@ class NodeOrderManager {
   }
 
   /**
-   * Reorder list in which the node is dropped.
-   *
-   * When a node is removed, recalculates the ordering for a given term ID
-   *
-   * @param int $tid
-   *   The term ID.
+   * {@inheritdoc}
    */
-  public static function handleListsDecrease($tid) {
+  public function handleListsDecrease($tid) {
     $taxonomy_nids = db_select('taxonomy_index', 'ti')
       ->fields('ti', array('nid'))
       ->condition('ti.tid', $tid)
@@ -356,7 +303,7 @@ class NodeOrderManager {
     if (!count($taxonomy_nids)) {
       return;
     }
-    $weights = static::getTermMinMax($tid, TRUE);
+    $weights = $this->getTermMinMax($tid, TRUE);
     $range_border = ceil(count($taxonomy_nids) / 2);
     // Out of range when one of both new list's border weights is corresponding range border.
     $border_out_of_range = ($weights['min'] < -$range_border || $weights['max'] > $range_border);
@@ -371,7 +318,7 @@ class NodeOrderManager {
         $weight ++;
       }
       // Make sure the weight cache is invalidated.
-      static::getTermMinMax($tid, TRUE);
+      $this->getTermMinMax($tid, TRUE);
     }
   }
 
diff --git a/src/NodeOrderManagerInterface.php b/src/NodeOrderManagerInterface.php
new file mode 100644
index 0000000..da11070
--- /dev/null
+++ b/src/NodeOrderManagerInterface.php
@@ -0,0 +1,137 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\nodeorder\NodeOrderManagerInterface.
+ */
+
+namespace Drupal\nodeorder;
+
+use Drupal\node\NodeInterface;
+
+/**
+ * Provides an interface defining a NodeOrderManager.
+ */
+interface NodeOrderManagerInterface {
+
+  /**
+   * Push new or newly orderable node to the top of ordered list.
+   *
+   * @param \Drupal\node\NodeInterface $node
+   *   The node to add to the top of the list.
+   * @param int $tid
+   *   The term ID to order the node in.
+   */
+  public function addToList(NodeInterface $node, $tid);
+
+  /**
+   * Get the minimum and maximum weights available for ordering nodes on a term.
+   *
+   * @param int $tid
+   *   The tid of the term from which to check values.
+   * @param bool $reset
+   *   (optional) Select from or reset the cache.
+   *
+   * @return array
+   *   An associative array with elements 'min' and 'max'.
+   */
+  public function getTermMinMax($tid, $reset = FALSE);
+
+  /**
+   * Determines if a given vocabulary is orderable.
+   *
+   * @param string $vid
+   *   The vocabulary vid.
+   *
+   * @return bool
+   *   Returns TRUE if the given vocabulary is orderable.
+   */
+  public function vocabularyIsOrderable($vid);
+
+  /**
+   * Finds all nodes that match selected taxonomy conditions.
+   *
+   * NOTE: This is nearly a direct copy of taxonomy_select_nodes() -- see
+   *       http://drupal.org/node/25801 if you find this sort of copy and
+   *       paste upsetting...
+   *
+   *
+   * @param $tids
+   *   An array of term IDs to match.
+   * @param $operator
+   *   How to interpret multiple IDs in the array. Can be "or" or "and".
+   * @param $depth
+   *   How many levels deep to traverse the taxonomy tree. Can be a nonnegative
+   *   integer or "all".
+   * @param $pager
+   *   Whether the nodes are to be used with a pager (the case on most Drupal
+   *   pages) or not (in an XML feed, for example).
+   * @param $order
+   *   The order clause for the query that retrieve the nodes.
+   * @param $count
+   *   If $pager is TRUE, the number of nodes per page, or -1 to use the
+   *   backward-compatible 'default_nodes_main' variable setting.  If $pager
+   *   is FALSE, the total number of nodes to select; or -1 to use the
+   *   backward-compatible 'feed_default_items' variable setting; or 0 to
+   *   select all nodes.
+   *
+   * @return \Drupal\Core\Database\StatementInterface
+   *   A resource identifier pointing to the query results.
+   */
+  public function selectNodes($tids = [], $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC', $count = -1);
+
+  /**
+   * Determine if a given node can be ordered in any vocabularies.
+   *
+   * @param \Drupal\node\NodeInterface
+   *   The node object.
+   *
+   * @return bool
+   *   Returns TRUE if the node has terms in any orderable vocabulary.
+   */
+  public function canBeOrdered(NodeInterface $node);
+
+  /**
+   * Get a list of term IDs on a node that can be ordered.
+   *
+   * This method uses the `taxonomy_index` table to determine which terms on a
+   * node are orderable.
+   *
+   * @see self::getOrderableTidsFromNode()
+   *
+   * @param \Drupal\node\NodeInterface
+   *   The node to check for orderable term IDs.
+   * @param bool
+   *   Flag to reset cached data.
+   *
+   * @return int[]
+   *   Returns an array of the node's tids that are in orderable vocabularies.
+   */
+  public function getOrderableTids(NodeInterface $node, $reset = FALSE);
+
+  /**
+   * Get all term IDs on a node that are on orderable vocabularies.
+   *
+   * Returns an array of the node's tids that are in orderable vocabularies.
+   * Slower than self::getOrderableTids() but needed when tids have already been
+   * removed from the database.
+   *
+   * @param \Drupal\node\NodeInterface
+   *   The node to find term IDs for.
+   *
+   * @return int[]
+   *   An array of term IDs.
+   */
+  public function getOrderableTidsFromNode(NodeInterface $node);
+
+  /**
+   * Reorder list in which the node is dropped.
+   *
+   * When a node is removed, recalculates the ordering for a given term ID
+   *
+   * @param int $tid
+   *   The term ID.
+   */
+  public function handleListsDecrease($tid);
+
+}
diff --git a/src/Tests/NodeorderCrudTest.php b/src/Tests/NodeorderCrudTest.php
index 15b0762..60366cb 100644
--- a/src/Tests/NodeorderCrudTest.php
+++ b/src/Tests/NodeorderCrudTest.php
@@ -8,7 +8,6 @@
 namespace Drupal\nodeorder\Tests;
 
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
-use Drupal\nodeorder\NodeOrderManager;
 use Drupal\taxonomy\Tests\TaxonomyTestBase;
 
 /**
@@ -24,6 +23,13 @@ class NodeorderCrudTest extends TaxonomyTestBase {
   public static $modules = ['taxonomy', 'node', 'nodeorder'];
 
   /**
+   * The node order manager.
+   *
+   * @var \Drupal\nodeorder\NodeOrderManagerInterface
+   */
+  protected $nodeOrderManager;
+
+  /**
    * Taxonomy term reference field for testing.
    *
    * @var \Drupal\field\FieldConfigInterface
@@ -44,6 +50,9 @@ class NodeorderCrudTest extends TaxonomyTestBase {
    */
   public function setUp() {
     parent::setUp();
+
+    $this->nodeOrderManager = $this->container->get('nodeorder.manager');
+
     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access', 'order nodes within categories']));
     $this->vocabulary = $this->createVocabulary();
 
@@ -94,7 +103,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
    */
   public function testOrderableVocabulary() {
     // Vocabulary should default to not being orderable.
-    $this->assertFalse(NodeOrderManager::vocabularyIsOrderable($this->vocabulary->id()), 'The test vocabulary is not orderable by default.');
+    $this->assertFalse($this->nodeOrderManager->vocabularyIsOrderable($this->vocabulary->id()), 'The test vocabulary is not orderable by default.');
 
     // Enable 'orderable' on this vocabulary.
     \Drupal::configFactory()->getEditable('nodeorder.settings')
@@ -102,7 +111,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
       ->save();
 
     // Ensure the vocabulary is sortable.
-    $this->assertTrue(NodeOrderManager::vocabularyIsOrderable($this->vocabulary->id()), 'The test vocabulary is orderable.');
+    $this->assertTrue($this->nodeOrderManager->vocabularyIsOrderable($this->vocabulary->id()), 'The test vocabulary is orderable.');
   }
 
   /**
+34 −13

File changed.

Preview size limit exceeded, changes collapsed.

nodeorder.services.yml

0 → 100755
+4 −0
Original line number Diff line number Diff line
services:
  nodeorder.manager:
    class: Drupal\nodeorder\NodeOrderManager
    arguments: ['@config.factory', '@entity.manager']
+56 −109

File changed.

Preview size limit exceeded, changes collapsed.

+137 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading