1 layout.class.inc Layout::setPath($path)

Set a layout path.

File

core/modules/layout/includes/layout.class.inc, line 654
Class for loading, modifying, and executing a layout.

Class

Layout
@file Class for loading, modifying, and executing a layout.

Code

function setPath($path) {
  if (empty($this->menu_item) || $this->menu_item->path !== $path) {
    // Use an existing menu item if one exists at this path.
    if ($existing_item = layout_menu_item_load_multiple_by_path($path)) {
      $this->menu_item = $existing_item;
    }
    // If this layout doesn't have a menu item, make one. If the path is
    // provided by another module, no menu item is necessary.
    elseif (layout_provides_path($path) === NULL) {
      if (empty($this->menu_item)) {
        $menu_item_settings = array(
          'path' => $path,
          'name' => $this->name,
        );
        $this->menu_item = new LayoutMenuItem($menu_item_settings);
      }
      else {
        $this->menu_item->path = $path;
      }
    }
    else {
      if ($this->menu_item) {
        $this->menu_item->delete();
      }
      $this->menu_item = NULL;
    }
  }
  // On any path change, reset contexts.
  if ($this->path !== $path) {
    $this->path = $path;
    $this->resetContexts();
  }
}