class DemoOfMenuTabs

Demonstrates MenuTabs

Convention: This is called DemoOfMenuTabs rather than DemoMenuTabs as it is not an IMenuTabs (it uses an IMenuTabs).

It is extremely important that you examine this demonstration class in conjunction with the explanation and UML diagram(s) at http://drupal7demo.webel.com.au/node/1019 as it deliberately includes some examples of HOW NOT TO DO THINGS when working in general with the UML-friendly Webel coding recipe for OOE.

Note also that this example is NOT an IProject; most other examples in the OOE suite leverage IProject as a starting point, but you are under no obligation to do so.

@author darrenkelly

Hierarchy

Expanded class hierarchy of DemoOfMenuTabs

1 file declares its use of DemoOfMenuTabs
OoeBridge.php in lib/Drupal/ooe/Demo/Module/OoeBridge.php
OoeBridge

File

lib/Drupal/ooe/Demo/Tabs/DemoOfMenuTabs.php, line 32
DemoOfMenuTabs

Namespace

Drupal\ooe\Demo\Tabs
View source
class DemoOfMenuTabs extends DefaultModuleHelper {

  /**
   * The menu tabs.
   *
   * @var \Drupal\ooe\Menu\IMenuTabs
   */
  private $menuTabs;

  /**
   * The menu tabs.
   *
   * @return \Drupal\ooe\Menu\IMenuTabs
   *   The menu tabs.
   */
  public function getMenuTabs() {
    return $this->menuTabs;
  }

  /**
   * Constructor: fetches an @link IMenuTabs @endlink from a factory.
   *
   * Creates some tabs with page controllers.
   *
   * This example deliberately pragmatically uses inline "new" creation
   * of page controllers passed directly to the tab creation method
   * (instead of private variables with lazy creation/configuration methods
   * for each of the page controllers).
   *
   * The approach here is NOT graphical UML-friendly, and is only done
   * to show you WHAT NOT TO DO when working with OOE as explained here:
   *
   * @link http://drupal7demo.webel.com.au/node/1019 @endlink
   *
   * @link http://drupal7demo.webel.com.au/node/1177 @endlink
   *
   * @param string $module
   *   The machine name of the module.
   * @param IFactory $factory
   *   Optional factory; if none given or null
   *   a @link DefaultFactory @endlink will be used.
   */
  public function __construct($module, IFactory $factory = NULL) {
    parent::__construct($module, $factory);

    $path = $module . '/demo/tabs';
    // @todo ENCAPSULATE!

    $this->menuTabs = $this->factory()->newMenuTabs(
    $path, 
    new DemoPageControllerMain(), 
    // Pseudo local page controller is not UML-friendly.
    $this->getModuleDisplayName() . ": Tabs demo"
    );

    $this->menuTabs->newTabMenuItem(
    new DemoPageControllerTab2(), 
    // Pseudo local page controller is not UML-friendly.
    "Tab2"
    );

    $this->menuTabs->newTabMenuItem(
    new DemoPageControllerTab3(), 
    // Pseudo local page controller is not UML-friendly.
    "Tab3"
    );
  }

  /**
   * All of the menu items of this.
   *
   * @return \Drupal\ooe\Menu\IMenuItem[]
   *   All of the menu items of this.
   */
  public function getMenuItems() {
    return $this->menuTabs->getMenuItems();
  }

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
DefaultModuleHelper::$displayName private property A human readable and displayable name of the module.
DefaultModuleHelper::$factory private property The current factory of this.
DefaultModuleHelper::$module private property The module machine name.
DefaultModuleHelper::f protected function The current factory, or a lazily created DefaultFactory.
DefaultModuleHelper::factory protected function The current factory or a lazily created DefaultFactory.
DefaultModuleHelper::getFactory public function The current factory. Overrides IModuleHelper::getFactory
DefaultModuleHelper::getModule public function Gets the module machine name. Overrides IModuleHelper::getModule
DefaultModuleHelper::getModuleDisplayName public function A human readable and displayable name of the module. Overrides IModuleHelper::getModuleDisplayName
DefaultModuleHelper::setFactory protected function Sets the factory of this.
DefaultModuleHelper::setModule private function Sets the module machine name.
DefaultModuleHelper::setModuleDisplayName public function Sets a human readable and displayable name of the module. Overrides IModuleHelper::setModuleDisplayName
DemoOfMenuTabs::$menuTabs private property The menu tabs.
DemoOfMenuTabs::getMenuItems public function All of the menu items of this.
DemoOfMenuTabs::getMenuTabs public function The menu tabs.
DemoOfMenuTabs::__construct public function Constructor: fetches an IMenuTabs from a factory. Overrides DefaultModuleHelper::__construct