diff -u b/CHANGELOG.txt b/CHANGELOG.txt --- b/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -23,8 +23,6 @@ - + Deceber 10, 2014 ------------------- gvso: Porting the module to Drupal 8 larowlan: Thanks to review it - - diff -u b/src/Form/TermsOfUseForm.php b/src/Form/TermsOfUseForm.php --- b/src/Form/TermsOfUseForm.php +++ b/src/Form/TermsOfUseForm.php @@ -14,7 +14,13 @@ class TermsOfUseForm extends ConfigFormBase { - private $node_title; + /** + * @var $node_title + * Save the node title in validateForm method + * and next submitForm method uses it to save it + * in the configuration management + */ + protected $node_title; /** * {@inheritdoc} diff -u b/terms_of_use.module b/terms_of_use.module --- b/terms_of_use.module +++ b/terms_of_use.module @@ -11,7 +11,6 @@ use Drupal\Core\Language\Language; use Drupal\Component\Utility\Xss; use Drupal\node\Entity\Node; -use Drupal\Core\Url; /** * Implements hook_form_FORM_ID_alter @@ -27,13 +26,13 @@ // Getting the nid of the the Terms of Use node. - $terms_of_use_node_id = $config->get('node_id'); + $node_id = $config->get('node_id'); // Get the language code $langcode = \Drupal::languageManager()->getLanguage(Language::TYPE_CONTENT); // A nid for the desired language was found. - if ($terms_of_use_node_id) { + if ($node_id) { // Adding the fieldset. $fieldset_name = Xss::filter($config->get('fieldset_name')); @@ -45,15 +44,15 @@ ); // Getting the node through its nid. - $node = Node::load($terms_of_use_node_id); + $node = Node::load($node_id); $translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode); // If we were able to load the node. - if ($node->nid) { + if ($node->uuid) { // If we find @link in the text for the terms checkbox we just show a // link. Otherwise we show the full terms. if (strpos($checkbox_label, '@link') !== FALSE) { - $checkbox_label = str_replace('@link', \Drupal::l($node->label(), 'node/' . $node->nid), $checkbox_label); + $checkbox_label = str_replace('@link', \Drupal::l($node->label(), 'node/' . $node->uuid), $checkbox_label); } // If there wasn't a link to the node we add the body field of the node // to the login form.