1 <?php 2 // This file is part of Moodle - https://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <https://www.gnu.org/licenses/>. 16 17 namespace test_plugin; 18 19 /** 20 * Fixture for testing of hooks. 21 * 22 * @package core 23 * @author Petr Skoda 24 * @copyright 2022 Open LMS 25 * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 final class callbacks { 28 /** @var string[] list of calls */ 29 public static $calls = []; 30 31 /** 32 * Callback tester. 33 * 34 * @param \test_plugin\hook\hook $hook 35 * @return void 36 */ 37 public static function test1(\test_plugin\hook\hook $hook): void { 38 self::$calls[] = 'test1'; 39 } 40 41 /** 42 * Callback tester. 43 * 44 * @param \test_plugin\hook\hook $hook 45 * @return void 46 */ 47 public static function test2(\test_plugin\hook\hook $hook): void { 48 self::$calls[] = 'test2'; 49 } 50 51 /** 52 * Callback tester. 53 * 54 * @param \test_plugin\hook\stoppablehook $hook 55 * @return void 56 */ 57 public static function stop1(\test_plugin\hook\stoppablehook $hook): void { 58 self::$calls[] = 'stop1'; 59 $hook->stop(); 60 } 61 62 /** 63 * Callback tester. 64 * 65 * @param \test_plugin\hook\stoppablehook $hook 66 * @return void 67 */ 68 public static function stop2(\test_plugin\hook\stoppablehook $hook): void { 69 self::$calls[] = 'stop2'; 70 $hook->stop(); 71 } 72 73 /** 74 * Callback tester for exceptions. 75 * 76 * @param \test_plugin\hook\hook $hook 77 * @return void 78 */ 79 public static function exception(\test_plugin\hook\hook $hook): void { 80 self::$calls[] = 'exception'; 81 throw new \Exception('grrr'); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body