abstract class AbstractControlledProject

Provides a starting point for page controlled projects.

UML: AbstractControlledProject

@author darrenkelly

Hierarchy

Expanded class hierarchy of AbstractControlledProject

3 files declare their use of AbstractControlledProject
Demo.php in lib/Drupal/ooe/Demo/Project/Demo.php
Demo
DemoOfForms.php in lib/Drupal/ooe/Demo/Form/DemoOfForms.php
DemoOfForms
DemoOfPageArguments.php in lib/Drupal/ooe/Demo/Arguments/DemoOfPageArguments.php
DemoOfPageArguments

File

lib/Drupal/ooe/Project/AbstractControlledProject.php, line 18
AbstractControlledProject

Namespace

Drupal\ooe\Project
View source
abstract class AbstractControlledProject extends AbstractProject implements IControlledProject {

  /**
   * Overridden to return the controlled page menu item.
   *
   * Because this is a page controlled project,
   * the primary menu must be a controlled page menu item.
   *
   * @return \Drupal\ooe\Menu\IMenuItem
   *   The controlled page menu item.
   */
  final public function getMenuItem() {
    return $this->getPageMenuItem();
  }

  /**
   * Overridden to return a new page menu item.
   *
   * @return \Drupal\ooe\Menu\IMenuItem
   *   A new page menu item.
   */
  final protected function myMenuItem() {
    return $this->myPageMenuItem();
  }

  /**
   * The page-controlled menu item.
   *
   * @var \Drupal\ooe\Page\IPageMenuItem
   */
  private $pageMenuItem;

  /**
   * Lazily creates and configures a page menu item.
   *
   * The actual page menu item chosen will depend on
   * @link AbstractControlledProject::myPageMenuItem @endlink.
   *
   * @return \Drupal\ooe\Page\IPageMenuItem
   *   A lazily created and configured page menu item.
   */
  public function getPageMenuItem() {
    if (empty($this->pageMenuItem)) {
      $this->pageMenuItem = $this->myPageMenuItem();
    }
    return $this->pageMenuItem;
  }

  /**
   * The page controller for the main page menu item.
   *
   * @var \Drupal\ooe\Page\IPageController
   */
  private $pageController;

  /**
   * Lazily creates and configures a page controller.
   *
   * The actual page menu item chosen will depend on
   * @link AbstractControlledProject::myPageController @endlink.
   *
   * @return \Drupal\ooe\Page\IPageController
   *   A lazily created and configured page controller.
   */
  protected function getPageController() {
    if (empty($this->pageController)) {
      $this->pageController = $this->myPageController();
    }
    return $this->pageController;
  }

  /**
   * Implement to return a specific page controller.
   *
   * @return \Drupal\ooe\Page\IPageController
   *   A new configured page controller.
   */
  abstract protected function myPageController();

  /**
   * Implement to return a specific page menu item.
   *
   * @return \Drupal\ooe\Page\IPageMenuItem
   *   A new configured page menu item.
   */
  abstract protected function myPageMenuItem();

  /**
   * Creates a default new page menu item using the primary page controller.
   *
   * This is a helper method that assists in implementations of
   * @link AbstractControlledProject::myPageMenuItem @endlink
   * by enforcing
   * some rules (such as using the primary page controller for the menu item)
   * and some sensible defaults and conventions such as optionally prefixing
   * the title and path with the module display name or machine name.
   *
   * There is however no obligation to use it to implement
   * @link AbstractControlledProject::myPageMenuItem() @endink.
   * However, if you choose not to use it, you should at least
   * use the primary page controller of this in the page menu item !
   *
   * @param string $title
   *   The menu title, will be optionally automatically
   *   prefixed with the module display name and ': '.
   * @param string $path
   *   The menu path, will be optionally automatically
   *   prefixed with the module machine name and '/'.
   *
   * @return \Drupal\ooe\Page\IPageMenuItem
   *   A default new page menu item using the primary page controller.
   */
  protected function newPageMenuItem($title, $path) {
    $fullTitle = $this->isDoPrefixMenuTitles() ? $this->getModuleDisplayName() . ": $title" : $title;
    $fullPath = $this->isDoPrefixMenuPaths() ? $this->getModule() . "/$path" : $path;

    return $this->factory()->newPageMenuItem(
    $this->getPageController(), $fullTitle, $fullPath
    );
  }
}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
AbstractControlledProject::$pageController private property The page controller for the main page menu item.
AbstractControlledProject::$pageMenuItem private property The page-controlled menu item.
AbstractControlledProject::getMenuItem final public function Overridden to return the controlled page menu item. Overrides AbstractProject::getMenuItem
AbstractControlledProject::getPageController protected function Lazily creates and configures a page controller.
AbstractControlledProject::getPageMenuItem public function Lazily creates and configures a page menu item. Overrides IControlledProject::getPageMenuItem
AbstractControlledProject::myMenuItem final protected function Overridden to return a new page menu item. Overrides AbstractProject::myMenuItem
AbstractControlledProject::myPageController abstract protected function Implement to return a specific page controller.
AbstractControlledProject::myPageMenuItem abstract protected function Implement to return a specific page menu item.
AbstractControlledProject::newPageMenuItem protected function Creates a default new page menu item using the primary page controller.
AbstractProject::$accessArguments private property A Drupal access arguments array.
AbstractProject::$block private property The (default) block of this project.
AbstractProject::$blockRegion private property A theme region for the default block.
AbstractProject::$blockView private property A (default) block view for a project.
AbstractProject::$doPrefixBlockInfo private property If TRUE the block info will be automatically prefixed with the module display name followed by ': '
AbstractProject::$doPrefixMenuPaths private property If TRUE menu paths will be automatically prefixed with the module machine name followed by '/'
AbstractProject::$doPrefixMenuTitles private property If TRUE menu title will be automatically prefixed with the module display name followed by ': ".
AbstractProject::$menuItem private property The primary menu item of this.
AbstractProject::$menuItemSet private property A set of menu items.
AbstractProject::accessArguments protected function By default there is no access restriction ! Inject via constructor (only).
AbstractProject::addMenuItem final protected function Adds a menu item to the menu item set of this.
AbstractProject::blockRegion protected function If not injected on construction, defaults to the Bartik theme 1st sidebar.
AbstractProject::getBlock public function Lazily creates a demo block. Overrides IProject::getBlock
AbstractProject::getBlockView public function A (default) block view for a project. Overrides IProject::getBlockView
AbstractProject::getMenuItems public function The set of menu items handled by this. Overrides IProject::getMenuItems
AbstractProject::isDoPrefixBlockInfo public function Whether the block info will be automatically prefixed.
AbstractProject::isDoPrefixMenuPaths public function Whether the menu paths will be automatically prefixed.
AbstractProject::isDoPrefixMenuTitles public function Whether the menu titles will be automatically prefixed.
AbstractProject::menuItemSet final protected function Lazily creates and configures a set/group of menu items.
AbstractProject::myBlock abstract protected function Implement to return a new configured block.
AbstractProject::myBlockView abstract protected function Implement to return a (usually new) configured block view.
AbstractProject::myFillMenuItemSet protected function By default does nothing; reimplement to add additional menu items.
AbstractProject::newBlock protected function A helper method to assist in implementing @link AbstractBlock::myBlock().
AbstractProject::newMenuItem protected function Creates a new basic menu item with an explicit .module file callback.
AbstractProject::setDoPrefixBlockInfo public function Sets whether the block info will be automatically prefixed.
AbstractProject::setDoPrefixMenuPaths public function Sets whether the menu paths will be automatically prefixed.
AbstractProject::setDoPrefixMenuTitles public function Sets whether the menu titles will be automatically prefixed.
AbstractProject::__construct public function Constructor. Overrides DefaultModuleHelper::__construct
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