You are here

class FlexiformDisplayEditPage in Flexiform 7

Class for add page displays.

Hierarchy

Expanded class hierarchy of FlexiformDisplayEditPage

2 string references to 'FlexiformDisplayEditPage'
flexiform_update_7011 in ./flexiform.install
Switch to keying displays by class name.
flexiform_webform_form_submit in flexiform_webform/flexiform_webform.admin.inc
Form API submit callback for the type form.

File

includes/display/edit_page.display.inc, line 10
Define Display plugin for the add page.

View source
class FlexiformDisplayEditPage extends FlexiformDisplayPageBase {

  /**
   * The position of the base entity id.
   *
   * @var int
   */
  private $base_id_position;

  /**
   * Retrieve the position of the base id in the menu path.
   *
   * @return int|FALSE
   */
  protected function getBaseIdPosition() {

    // Assume the first wildcard is the base id position.
    if (!isset($this->base_id_position)) {
      $path_bits = explode('/', $this->configuration['path']);
      $this->base_id_position = array_search('%', $path_bits);
    }
    return $this->base_id_position;
  }

  /**
   * {@inheritdoc}
   */
  public function hook_menu() {

    // If there is no base id in this path we cannot use it for an edit page.
    if (!$this
      ->getBaseIdPosition()) {
      return array();
    }
    return parent::hook_menu();
  }

  /**
   * {@inheritdoc}
   */
  protected function getMenuArguments() {
    $args = parent::getMenuArguments();
    $args[2] = $this
      ->getBaseIdPosition();
    return $args;
  }

  /**
   * {@inheritdoc}
   */
  public function getBaseEntity($context = array()) {
    $base_entity = entity_load_single($this
      ->getFlexiform()->base_entity, $context['base_entity_id']);

    //@todo: Check the entity is the right bundle.
    return $base_entity;
  }

  /**
   * Get the configuration form.
   */
  public function configForm($form, &$form_state) {
    $form = parent::configForm($form, $form_state);
    $form['path']['#description'] = t('The path to this form. Must include a single \'%\' where the id of the base entity will go.');
    return $form;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlexiformDisplayBase::$flexiform protected property The Flexiform the display is for.
FlexiformDisplayBase::access public function Check the access for this form display. Overrides FlexiformDisplayInterface::access 1
FlexiformDisplayBase::build public function Build the form ready for rendering. Overrides FlexiformDisplayInterface::build 2
FlexiformDisplayBase::getFlexiform public function Retrieve the flexiform for this display. Overrides FlexiformDisplayInterface::getFlexiform
FlexiformDisplayBase::isEnabled public function Is this display enabled. 1
FlexiformDisplayBase::__construct public function
FlexiformDisplayEditPage::$base_id_position private property The position of the base entity id.
FlexiformDisplayEditPage::configForm public function Get the configuration form. Overrides FlexiformDisplayPageBase::configForm
FlexiformDisplayEditPage::getBaseEntity public function Get the base entity for a flexiform. Overrides FlexiformDisplayBase::getBaseEntity
FlexiformDisplayEditPage::getBaseIdPosition protected function Retrieve the position of the base id in the menu path.
FlexiformDisplayEditPage::getMenuArguments protected function Get the page/title arguments for hook_menu. Overrides FlexiformDisplayPageBase::getMenuArguments
FlexiformDisplayEditPage::hook_menu public function Define the menu links Overrides FlexiformDisplayPageBase::hook_menu
FlexiformDisplayPageBase::getPath public function Get the path, if applicable, for the display. Overrides FlexiformDisplayBase::getPath
FlexiformDisplayPageBase::getPermissionOptions protected function Get Permission Options.
FlexiformDisplayPageBase::title public function Get the title. Overrides FlexiformDisplayBase::title 1