1

Just found out that on Drupal API hook_help() don't have break after in the end of switch statements. Is it supposed to be so?

function hook_help($path, $arg) {
  switch ($path) {
    // Main module help for the block module
    case 'admin/help#block':
      return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href="@blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', array('@blocks' => url('admin/structure/block'))) . '</p>';

      // Help for another path in the block module
    case 'admin/structure/block':
      return '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
  }
}
4
  • 1
    the returns do that for you...
    – Jimajamma
    Feb 13, 2013 at 18:24
  • break isn't required in a switch statement... "If you don't write a break statement at the end of a case's statement list, PHP will go on executing the statements of the following case." That + what @Jimajamma said explains what's going on in your example
    – Clive
    Feb 13, 2013 at 18:27
  • Some folk put a break after the return to be extra clear, and in case the code's later altered and the return gets removed, but as it stands in your example it's entirely unnecessary.
    – Andy
    Feb 13, 2013 at 18:27
  • It's totally obvious. Don't know how I could miss that. @Jimajamma, Clive, Andy Thanks! Feb 13, 2013 at 18:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.