xref: /plugin/combo/action/linkmove.php (revision 007225e5fb2d3f64edaccd3bd447ca26effb9d68)
1<?php
2
3use ComboStrap\LinkUtility;
4use ComboStrap\PluginUtility;
5
6if (!defined('DOKU_INC')) die();
7require_once(__DIR__ . '/../class/PluginUtility.php');
8require_once(__DIR__ . '/../class/LinkUtility.php');
9
10/**
11 * Class action_plugin_combo_move
12 * Handle the move of a page in order to update the link
13 */
14class action_plugin_combo_linkmove extends DokuWiki_Action_Plugin
15{
16
17    /**
18     * As explained https://www.dokuwiki.org/plugin:move
19     * @param Doku_Event_Handler $controller
20     */
21    function register(Doku_Event_Handler $controller)
22    {
23        $controller->register_hook('PLUGIN_MOVE_HANDLERS_REGISTER', 'BEFORE', $this, 'handle_move', array());
24    }
25
26    /**
27     * Handle the move of a page
28     * @param Doku_Event $event
29     * @param $params
30     */
31    function handle_move(Doku_Event $event, $params)
32    {
33        /**
34         * 'combo_link' refers to the {@link syntax_plugin_combo_link} handler
35         * 'rewrite_combo' to the below method
36         */
37        $event->data['handlers']['combo_link'] = array($this, 'rewrite_combo');
38    }
39
40    /**
41     *
42     * @param $match
43     * @param $state
44     * @param $pos
45     * @param $plugin
46     * @param helper_plugin_move_handler $handler
47     * @return bool
48     */
49    public function rewrite_combo($match, $state, $pos, $plugin, helper_plugin_move_handler $handler)
50    {
51        /**
52         * We call the original move method
53         * that supports Link rewriting
54         */
55        $handler->internallink($match, $state, $pos);
56        return '';
57
58    }
59
60
61}
62