You are here

class FlexiformDisplayUserCategory in Flexiform 7

Class for add page displays.

Hierarchy

Expanded class hierarchy of FlexiformDisplayUserCategory

2 string references to 'FlexiformDisplayUserCategory'
flexiform_update_7011 in ./flexiform.install
Switch to keying displays by class name.
flexiform_user_categories in ./flexiform.module
Implements hook_user_categories()

File

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

View source
class FlexiformDisplayUserCategory extends FlexiformDisplayBase {

  /**
   * Define the menu links
   */
  public function hook_menu_alter(&$items) {
    $path = 'user/%user_category/edit/' . $this->configuration['category'];
    $items[$path]['page callback'] = 'flexiform_page_wrapper';
    $items[$path]['page arguments'] = array(
      $this
        ->getFlexiform()->form,
      get_class($this),
      1,
    );
    $items[$path]['access callback'] = 'flexiform_user_category_access';
    $items[$path]['access arguments'] = array(
      $this
        ->getFlexiform()->form,
      get_class($this),
      1,
    );
    $items[$path]['module'] = 'flexiform';
    $items[$path]['file'] = 'flexiform.pages.inc';
    $items[$path]['weight'] = isset($this->configuration['weight']) ? $this->configuration['weight'] : 0;
  }

  /**
   * Define the category for for this form.
   */
  public function hook_user_categories() {
    return array(
      array(
        'name' => check_plain($this->configuration['category']),
        'title' => $this->configuration['title'],
        'weight' => 0,
      ),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getBaseEntity($context = array()) {

    //@todo: Check the entity is the right bundle.
    return $context['base_entity_id'];
  }

  /**
   * Get the configuration form.
   */
  public function configForm($form, &$form_state) {
    $form = parent::configForm($form, $form_state);
    $form['category'] = array(
      '#title' => t('Category'),
      '#type' => 'textfield',
      '#default_value' => isset($this->configuration['category']) ? $this->configuration['category'] : NULL,
      '#description' => t('The path component for this category.'),
    );
    $form['weight'] = array(
      '#title' => t('Weight'),
      '#type' => 'weight',
      '#description' => t('Heavier items will sink and lighter items will be positioned near the top.'),
      '#default_value' => isset($this->configuration['weight']) ? $this->configuration['weight'] : 0,
      '#delta' => 30,
    );
    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::getPath public function Get the path, if applicable, for the display. Overrides FlexiformDisplayInterface::getPath 1
FlexiformDisplayBase::isEnabled public function Is this display enabled. 1
FlexiformDisplayBase::title public function Get the title. Overrides FlexiformDisplayInterface::title 1
FlexiformDisplayBase::__construct public function
FlexiformDisplayUserCategory::configForm public function Get the configuration form. Overrides FlexiformDisplayBase::configForm
FlexiformDisplayUserCategory::getBaseEntity public function Get the base entity for a flexiform. Overrides FlexiformDisplayBase::getBaseEntity
FlexiformDisplayUserCategory::hook_menu_alter public function Define the menu links
FlexiformDisplayUserCategory::hook_user_categories public function Define the category for for this form.