Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-49643

Deprecate inconsistent API to extend the navigation by local plugins

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8.5
    • Fix Version/s: 2.9
    • Component/s: Navigation
    • Testing Instructions:
      Hide

      You can use this very minimalistic plugin local_demo:

      <?php // version.php ///////////////////////////////////////////////////////////
       
      $plugin->version = 2015032300;
       
       
      <?php // lib.php ///////////////////////////////////////////////////////////////
       
      function local_demo_extends_navigation(global_navigation $navigation) {
          $navigation->add('Demo!');
      }
       
      function local_demo_extends_settings_navigation(settings_navigation $settings, $context) {
          if ($node = $settings->get('usercurrentsettings')) {
              $node->add('Awesome!');
          }
      }
       
       
      <?php // lang/en/local_demo.php ////////////////////////////////////////////////
       
      $string['pluginname'] = 'Demo local plugin';
      

      • Play with the file lib.php and make sure that both variants 'extends' and 'extend' actually work and the new texts appear in the blocks.
      • Make sure that the deprecated variant throws DEBUG_DEVELOPER message.
      • Make sure that if both current and deprecated variants exists, the current is used and no deprecation warning is displayed.
      Show
      You can use this very minimalistic plugin local_demo: <?php // version.php ///////////////////////////////////////////////////////////   $plugin->version = 2015032300;     <?php // lib.php ///////////////////////////////////////////////////////////////   function local_demo_extends_navigation(global_navigation $navigation) { $navigation->add('Demo!'); }   function local_demo_extends_settings_navigation(settings_navigation $settings, $context) { if ($node = $settings->get('usercurrentsettings')) { $node->add('Awesome!'); } }     <?php // lang/en/local_demo.php ////////////////////////////////////////////////   $string['pluginname'] = 'Demo local plugin'; Play with the file lib.php and make sure that both variants 'extends' and 'extend' actually work and the new texts appear in the blocks. Make sure that the deprecated variant throws DEBUG_DEVELOPER message. Make sure that if both current and deprecated variants exists, the current is used and no deprecation warning is displayed.
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-49643-master-local-nav

      Description

      Discussed at https://moodle.org/local/chatlogs/index.php?conversationid=17444

      It seems that MDL-22209 and MDL-30506 introduced inconsistent API for the local plugins to extend navigation. Whereas in all other places the callbacks are called in the imperative mood like <plugin>_extend_navigation() and <plugin>_extend_settings_navigation(), the local plugins have them like <plugin>_extends_navigation().

      Me and Eloy believe it was a mistake, probably confusion caused by the existence of the global_navigation::module_extends_navigation() method. As such, it should be fixed.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/May/15