setLabel(new TranslatableMarkup('Layout Section')) ->setRequired(FALSE); return $properties; } /** * {@inheritdoc} */ public function __get($name) { // @todo \Drupal\Core\Field\FieldItemBase::__get() does not return default // values for uninstantiated properties. This will forcibly instantiate // all properties with the side-effect of a performance hit, resolve // properly in https://www.drupal.org/node/2413471. $this->getProperties(); return parent::__get($name); } /** * {@inheritdoc} */ public static function mainPropertyName() { return 'section'; } /** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = [ 'columns' => [ 'section' => [ 'type' => 'blob', 'size' => 'normal', 'serialize' => TRUE, ], ], ]; return $schema; } /** * {@inheritdoc} */ public static function generateSampleValue(FieldDefinitionInterface $field_definition) { // @todo Expand this in https://www.drupal.org/node/2912331. $values['section'] = new Section('layout_onecol'); return $values; } /** * {@inheritdoc} */ public function isEmpty() { return empty($this->section); } }