Loading src/Plugin/Block/NextPreviousBlock.php +12 −15 Original line number Diff line number Diff line Loading @@ -80,8 +80,6 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $node_types = node_type_get_names(); $form['content_type'] = [ '#type' => 'select', Loading Loading @@ -112,12 +110,10 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { parent::blockSubmit($form, $form_state); $values = $form_state->getValues(); $this->configuration['content_type'] = $form_state->getValue('content_type'); $this->configuration['previous_text'] = $values['previous_text']; $this->configuration['next_text'] = $values['next_text']; parent::blockSubmit($form, $form_state); } /** Loading @@ -128,7 +124,8 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta // Get the created time of the current node. $node = $this->request->attributes->get('node'); if ($node) { if ($node && $node->bundle() == $this->configuration['content_type']) { $current_nid = $node->get('nid')->getValue()[0]['value']; $link['prev'] = $this->generatePrevious($current_nid); $link['next'] = $this->generateNext($current_nid); Loading Loading @@ -173,21 +170,21 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta * Lookup the next or previous node. * * @param string $current_nid * Get current pagae node id. * Get current page node id. * @param string $direction * show button name from generatePrevious() and generatePrevious(). * Default value is "next" and other value come from * generatePrevious() and generatePrevious(). * * @return array * Find the alias of the next node. */ private function generateNextPrevious($current_nid, $direction) { if ($direction === 'next') { private function generateNextPrevious($current_nid, $direction = 'next') { $comparison_opperator = '>'; $sort = 'ASC'; $display_text = $this->configuration['next_text']; $class = "nextpre_next"; } elseif ($direction === 'prev') { if ($direction === 'prev') { $comparison_opperator = '<'; $sort = 'DESC'; $display_text = $this->configuration['previous_text']; Loading Loading
src/Plugin/Block/NextPreviousBlock.php +12 −15 Original line number Diff line number Diff line Loading @@ -80,8 +80,6 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $node_types = node_type_get_names(); $form['content_type'] = [ '#type' => 'select', Loading Loading @@ -112,12 +110,10 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state) { parent::blockSubmit($form, $form_state); $values = $form_state->getValues(); $this->configuration['content_type'] = $form_state->getValue('content_type'); $this->configuration['previous_text'] = $values['previous_text']; $this->configuration['next_text'] = $values['next_text']; parent::blockSubmit($form, $form_state); } /** Loading @@ -128,7 +124,8 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta // Get the created time of the current node. $node = $this->request->attributes->get('node'); if ($node) { if ($node && $node->bundle() == $this->configuration['content_type']) { $current_nid = $node->get('nid')->getValue()[0]['value']; $link['prev'] = $this->generatePrevious($current_nid); $link['next'] = $this->generateNext($current_nid); Loading Loading @@ -173,21 +170,21 @@ class NextPreviousBlock extends BlockBase implements BlockPluginInterface, Conta * Lookup the next or previous node. * * @param string $current_nid * Get current pagae node id. * Get current page node id. * @param string $direction * show button name from generatePrevious() and generatePrevious(). * Default value is "next" and other value come from * generatePrevious() and generatePrevious(). * * @return array * Find the alias of the next node. */ private function generateNextPrevious($current_nid, $direction) { if ($direction === 'next') { private function generateNextPrevious($current_nid, $direction = 'next') { $comparison_opperator = '>'; $sort = 'ASC'; $display_text = $this->configuration['next_text']; $class = "nextpre_next"; } elseif ($direction === 'prev') { if ($direction === 'prev') { $comparison_opperator = '<'; $sort = 'DESC'; $display_text = $this->configuration['previous_text']; Loading