You are here

class Container in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/dependency-injection/Container.php \Symfony\Component\DependencyInjection\Container
  2. 8 core/lib/Drupal/Core/DependencyInjection/Container.php \Drupal\Core\DependencyInjection\Container
  3. 8 core/lib/Drupal/Component/DependencyInjection/Container.php \Drupal\Component\DependencyInjection\Container
  4. 8 vendor/symfony/dependency-injection/Tests/Fixtures/php/services1-1.php \Symfony\Component\DependencyInjection\Container
  5. 8 core/lib/Drupal/Core/Render/Element/Container.php \Drupal\Core\Render\Element\Container
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Render/Element/Container.php \Drupal\Core\Render\Element\Container

Provides a render element that wraps child elements in a container.

Surrounds child elements with a <div> and adds attributes such as classes or an HTML ID.

Usage example:

$form['needs_accommodation'] = array(
  '#type' => 'checkbox',
  '#title' => 'Need Special Accommodations?',
);
$form['accommodation'] = array(
  '#type' => 'container',
  '#attributes' => array(
    'class' => 'accommodation',
  ),
  '#states' => array(
    'invisible' => array(
      'input[name="needs_accommodation"]' => array(
        'checked' => FALSE,
      ),
    ),
  ),
);
$form['accommodation']['diet'] = array(
  '#type' => 'textfield',
  '#title' => t('Dietary Restrictions'),
);

Plugin annotation

@RenderElement("container");

Hierarchy

Expanded class hierarchy of Container

5 string references to 'Container'
field.field.taxonomy_term.forums.forum_container.yml in core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml
core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml
Kernel::getContainerBaseClass in vendor/symfony/http-kernel/Kernel.php
Gets the container's base class.
PhpDumper::dump in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Dumps the service container as a PHP class.
PhpDumperTest::testDump in vendor/symfony/dependency-injection/Tests/Dumper/PhpDumperTest.php
SearchExcerptTest::testSearchExcerptSimplified in core/modules/search/src/Tests/SearchExcerptTest.php
Tests search_excerpt() with search keywords matching simplified words.
52 #type uses of Container
AccountForm::form in core/modules/user/src/AccountForm.php
Gets the actual form array to be built.
AccountSettingsForm::buildForm in core/modules/user/src/AccountSettingsForm.php
Form constructor.
AggregatorController::buildPageList in core/modules/aggregator/src/Controller/AggregatorController.php
Builds a listing of aggregator feed items.
ArgumentPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Provide a form to edit options for this plugin.
ArgumentPluginBase::processContainerRadios in core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
Custom form radios process function.

... See full list

File

core/lib/Drupal/Core/Render/Element/Container.php, line 46
Contains \Drupal\Core\Render\Element\Container.

Namespace

Drupal\Core\Render\Element
View source
class Container extends RenderElement {

  /**
   * {@inheritdoc}
   */
  public function getInfo() {
    $class = get_class($this);
    return array(
      '#process' => array(
        array(
          $class,
          'processGroup',
        ),
        array(
          $class,
          'processContainer',
        ),
      ),
      '#pre_render' => array(
        array(
          $class,
          'preRenderGroup',
        ),
      ),
      '#theme_wrappers' => array(
        'container',
      ),
    );
  }

  /**
   * Processes a container element.
   *
   * @param array $element
   *   An associative array containing the properties and children of the
   *   container.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   * @param array $complete_form
   *   The complete form structure.
   *
   * @return array
   *   The processed element.
   */
  public static function processContainer(&$element, FormStateInterface $form_state, &$complete_form) {

    // Generate the ID of the element if it's not explicitly given.
    if (!isset($element['#id'])) {
      $element['#id'] = HtmlUtility::getUniqueId(implode('-', $element['#parents']) . '-wrapper');
    }
    return $element;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Container::getInfo public function Returns the element properties for this element. Overrides ElementInterface::getInfo 1
Container::processContainer public static function Processes a container element.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
PluginBase::$configuration protected property Configuration information passed into the plugin. 2
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. 69
RenderElement::preRenderAjaxForm public static function Adds Ajax information about an element to communicate with JavaScript.
RenderElement::preRenderGroup public static function Adds members of this group as actual elements for rendering.
RenderElement::processAjaxForm public static function Form element processing handler for the #ajax form property.
RenderElement::processGroup public static function Arranges elements into groups.
RenderElement::setAttributes public static function Sets a form element's class attribute. Overrides ElementInterface::setAttributes
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.