Merge branch 'MDL-74733-master' of https://github.com/sammarshallou/moodle

This commit is contained in:
Sara Arjona 2022-06-08 18:10:38 +02:00
commit bb5831c623
9 changed files with 29 additions and 9 deletions

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_block\local\views;
namespace core_block\navigation\views;
/**
* Class secondary

View File

@ -1684,12 +1684,20 @@ class block_manager {
* Convenience function to check whether a block is implementing a secondary nav class and return it
* initialised to the calling function
*
* @todo MDL-74939 Remove support for old 'local\views\secondary' class location
* @param block_base $block
* @return \core\navigation\views\secondary
*/
protected function get_secondarynav(block_base $block): \core\navigation\views\secondary {
$class = "core_block\\local\\views\\secondary";
if (class_exists("block_{$block->name()}\\local\\views\\secondary")) {
$class = "core_block\\navigation\\views\\secondary";
if (class_exists("block_{$block->name()}\\navigation\\views\\secondary")) {
$class = "block_{$block->name()}\\navigation\\views\\secondary";
} else if (class_exists("block_{$block->name()}\\local\\views\\secondary")) {
// For backwards compatibility, support the old location for this class (it was in a
// 'local' namespace which shouldn't be used for core APIs).
debugging("The class block_{$block->name()}\\local\\views\\secondary uses a deprecated " .
"namespace. Please move it to block_{$block->name()}\\navigation\\views\\secondary.",
DEBUG_DEVELOPER);
$class = "block_{$block->name()}\\local\\views\\secondary";
}
$secondarynav = new $class($this->page);

View File

@ -867,13 +867,22 @@ class moodle_page {
/**
* Returns the secondary navigation object
*
* @todo MDL-74939 Remove support for old 'local\views\secondary' class location
* @return secondary
*/
protected function magic_get_secondarynav() {
if ($this->_secondarynav === null) {
$class = 'core\navigation\views\secondary';
// Try and load a custom class first.
if (class_exists("mod_{$this->activityname}\\local\\views\\secondary")) {
if (class_exists("mod_{$this->activityname}\\navigation\\views\\secondary")) {
$class = "mod_{$this->activityname}\\navigation\\views\\secondary";
} else if (class_exists("mod_{$this->activityname}\\local\\views\\secondary")) {
// For backwards compatibility, support the old location for this class (it was in a
// 'local' namespace which shouldn't be used for core APIs).
debugging("The class mod_{$this->activityname}}\\local\\views\\secondary uses a deprecated " .
"namespace. Please move it to mod_{$this->activityname}\\navigation\\views\\secondary.",
DEBUG_DEVELOPER);
$class = "mod_{$this->activityname}\\local\\views\\secondary";
}

View File

@ -12,6 +12,9 @@ information provided here is intended especially for developers.
an event exists with the given criteria (see MDL-72723 for details).
- Breaking: 3rd party log readers implementing interface sql_reader will need to implement get_events_select_exists()
* Added $strictness parameter to persistent `get_record` method, optionally allowing caller to ensure record exists
* For plugins that override secondary navigation, the namespace for the custom secondary navigation class has
changed. It was (for example) mod_mymodule\local\views\secondary but is now
mod_mymodule\navigation\views\secondary. The old location will continue to work, but is deprecated.
=== 4.0 ===

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_assign\local\views;
namespace mod_assign\navigation\views;
use core\navigation\views\secondary as core_secondary;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_feedback\local\views;
namespace mod_feedback\navigation\views;
use core\navigation\views\secondary as core_secondary;
use settings_navigation;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_glossary\local\views;
namespace mod_glossary\navigation\views;
use core\navigation\views\secondary as core_secondary;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_label\local\views;
namespace mod_label\navigation\views;
use core\navigation\views\secondary as core_secondary;
use settings_navigation;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_quiz\local\views;
namespace mod_quiz\navigation\views;
use core\navigation\views\secondary as core_secondary;