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

Default name for the method implementing the external function

XMLWordPrintable

    • MOODLE_311_STABLE
    • MOODLE_311_STABLE
    • MDL-71169-master-execute
    • Hide
      1. Install the attached tool_demo.zip plugin which provides a simple external function without specifying its methodname in db/services.php
      2. TEST Run the demo plugin's tests and make sure they pass (i.e. external function was correctly registered using default methodname).

        vendor/bin/phpunit -c admin/tool/demo/
        

      3. Modify the file admin/tool/demo/db/services.php and use some explicitly declared methodname, e.g.:

            'tool_demo_get_current_time' => [
                'classname' => '\tool_demo\external\get_current_time',
                'methodname' => 'run',
                // ...
        

      4. Modify the file demo/classes/external/get_current_time.php and change the name of all three methods accordingly. In this example, we would replace 'execute' prefix with 'run'.
      5. Increase the version number in the tool_demo plugin's version.php and upgrade the site.
      6. TEST Run the demo plugin's tests again and make sure they still pass (i.e. developers can still provide explicit custom name).
      7. Modify the file admin/tool/demo/db/services.php and remove the methodname property that you added.
      8. Modify the file demo/classes/external/get_current_time.php and revert the method names back to using the "execute" prefix.
      9. Increase the version number in the tool_demo plugin's version.php and upgrade the site.
      10. TEST Run the demo plugin's tests again and make sure they still pass (i.e. the methodname can be removed from the file if the class uses default names).
      Show
      Install the attached tool_demo.zip plugin which provides a simple external function without specifying its methodname in db/services.php TEST Run the demo plugin's tests and make sure they pass (i.e. external function was correctly registered using default methodname). vendor/bin/phpunit -c admin/tool/demo/ Modify the file admin/tool/demo/db/services.php and use some explicitly declared methodname, e.g.: 'tool_demo_get_current_time' => [ 'classname' => '\tool_demo\external\get_current_time', 'methodname' => 'run', // ... Modify the file demo/classes/external/get_current_time.php and change the name of all three methods accordingly. In this example, we would replace 'execute' prefix with 'run'. Increase the version number in the tool_demo plugin's version.php and upgrade the site. TEST Run the demo plugin's tests again and make sure they still pass (i.e. developers can still provide explicit custom name). Modify the file admin/tool/demo/db/services.php and remove the methodname property that you added. Modify the file demo/classes/external/get_current_time.php and revert the method names back to using the "execute" prefix. Increase the version number in the tool_demo plugin's version.php and upgrade the site. TEST Run the demo plugin's tests again and make sure they still pass (i.e. the methodname can be removed from the file if the class uses default names).

      As a follow-up of MDLSITE-6096, let's make execute the default name of the method that implements the external function.

      It has been promoted and recommended as a de-facto standard for all new external functions. Supporting it as a default name will help to make it commonly adopted pattern and it can eventually lead to making it a requested standard.

            mudrd8mz David Mudrák (@mudrd8mz)
            mudrd8mz David Mudrák (@mudrd8mz)
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Andrew Lyons Andrew Lyons
            Dongsheng Cai Dongsheng Cai
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 30 minutes
                3h 30m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.