original_string: protected function add_context_locking_node(\navigation_node $node, \context $context) {
          global $CFG;
          // Manage context locking.
          if (!empty($CFG->contextlocking) && has_capability('moodle/site:managecontextlocks', $context)) {
              $parentcontext = $context->get_parent_context();
              if (empty($parentcontext) || !$parentcontext->locked) {
                  if ($context->locked) {
                      $lockicon = 'i/unlock';
                      $lockstring = get_string('managecontextunlock', 'admin');
                  } else {
                      $lockicon = 'i/lock';
                      $lockstring = get_string('managecontextlock', 'admin');
                  }
                  $node->add(
                      $lockstring,
                      new moodle_url(
                          '/admin/lock.php',
                          [
                              'id' => $context->id,
                          ]
                      ),
                      self::TYPE_SETTING,
                      null,
                      'contextlocking',
                       new pix_icon($lockicon, '')
                  );
              }
          }
  
      }
code: protected function add_context_locking_node(\navigation_node $node, \context $context) {
          global $CFG;
          // Manage context locking.
          if (!empty($CFG->contextlocking) && has_capability('moodle/site:managecontextlocks', $context)) {
              $parentcontext = $context->get_parent_context();
              if (empty($parentcontext) || !$parentcontext->locked) {
                  if ($context->locked) {
                      $lockicon = 'i/unlock';
                      $lockstring = get_string('managecontextunlock', 'admin');
                  } else {
                      $lockicon = 'i/lock';
                      $lockstring = get_string('managecontextlock', 'admin');
                  }
                  $node->add(
                      $lockstring,
                      new moodle_url(
                          '/admin/lock.php',
                          [
                              'id' => $context->id,
                          ]
                      ),
                      self::TYPE_SETTING,
                      null,
                      'contextlocking',
                       new pix_icon($lockicon, '')
                  );
              }
          }
  
      }
code_tokens: protected function add_context_locking_node ( \ navigation_node $ node , \ context $ context ) { global $ CFG ; // Manage context locking. if ( ! empty ( $ CFG -> contextlocking ) && has_capability ( 'moodle/site:managecontextlocks' , $ context ) ) { $ parentcontext = $ context -> get_parent_context ( ) ; if ( empty ( $ parentcontext ) || ! $ parentcontext -> locked ) { if ( $ context -> locked ) { $ lockicon = 'i/unlock' ; $ lockstring = get_string ( 'managecontextunlock' , 'admin' ) ; } else { $ lockicon = 'i/lock' ; $ lockstring = get_string ( 'managecontextlock' , 'admin' ) ; } $ node -> add ( $ lockstring , new moodle_url ( '/admin/lock.php' , [ 'id' => $ context -> id , ] ) , self :: TYPE_SETTING , null , 'contextlocking' , new pix_icon ( $ lockicon , '' ) ) ; } } }
docstring: Add the menu item to handle locking and unlocking of a conext.
  
  @param \navigation_node $node Node to add
  @param \context $context The context to be locked
docstring_tokens: Add the menu item to handle locking and unlocking of a conext .