properties example

// Ensure proper ordering of children.       '#weight',
      // Properties already processed for the parent element.       '#prefix',
      '#suffix',
      '#attached',
      '#processed',
      '#theme_wrappers',
    ];
    // Move this element into sub-element 'value'.     unset($element['value']);
    foreach (Element::properties($element) as $key) {
      if (!in_array($key$keys_not_to_copy)) {
        $element['value'][$key] = $element[$key];
      }
    }

    $element['value']['#type'] = $element['#base_type'];
    $element['value'] += static::elementInfo()->getInfo($element['#base_type']);
    // Make sure the #default_value key is set, so we can use it below.     $element['value'] += ['#default_value' => ''];

    // Turn original element into a text format wrapper.
/** * Tests the properties() method. */
  public function testProperties() {
    $element = [
      '#property1' => 'property1',
      '#property2' => 'property2',
      'property3' => 'property3',
      0 => [],
    ];

    $properties = Element::properties($element);

    $this->assertSame(['#property1', '#property2']$properties);
  }

  /** * Tests the child() method. */
  public function testChild() {
    $this->assertFalse(Element::child('#property'));
    $this->assertTrue(Element::child('property'));
    $this->assertTrue(Element::child('property#'));
  }
// Check that the element properties are cached as specified.     foreach ($expected_results as $property => $expected) {
      $cached = !empty($data[$property]);
      $this->assertEquals($cached(bool) $expected);
      // Check that only the #markup key is preserved for children.       if ($cached) {
        $this->assertEquals($data[$property]$original[$property]);
      }
    }
    // #custom_property_array can not be a safe_cache_property.     $safe_cache_properties = array_diff(Element::properties(array_filter($expected_results))['#custom_property_array']);
    foreach ($safe_cache_properties as $cache_property) {
      $this->assertInstanceOf(MarkupInterface::class$data[$cache_property]);
    }
  }

  /** * Data provider for ::testRenderCacheProperties(). * * @return array * An array of associative arrays of expected results keyed by property * name. */
Home | Imprint | This part of the site doesn't use cookies.