SectionData.php

Same filename in other branches
  1. 9 core/modules/layout_builder/src/Plugin/DataType/SectionData.php
  2. 8.9.x core/modules/layout_builder/src/Plugin/DataType/SectionData.php
  3. 11.x core/modules/layout_builder/src/Plugin/DataType/SectionData.php

Namespace

Drupal\layout_builder\Plugin\DataType

File

core/modules/layout_builder/src/Plugin/DataType/SectionData.php

View source
<?php

namespace Drupal\layout_builder\Plugin\DataType;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\Attribute\DataType;
use Drupal\Core\TypedData\TypedData;
use Drupal\layout_builder\Section;

/**
 * Provides a data type wrapping \Drupal\layout_builder\Section.
 *
 * @internal
 *   Plugin classes are internal.
 */
class SectionData extends TypedData {
    
    /**
     * The section object.
     *
     * @var \Drupal\layout_builder\Section
     */
    protected $value;
    
    /**
     * {@inheritdoc}
     */
    public function setValue($value, $notify = TRUE) {
        if ($value && !$value instanceof Section) {
            throw new \InvalidArgumentException(sprintf('Value assigned to "%s" is not a valid section', $this->getName()));
        }
        parent::setValue($value, $notify);
    }

}

Classes

Title Deprecated Summary
SectionData Provides a data type wrapping \Drupal\layout_builder\Section.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.