dataHasStringForSerializeColumn example

protected function checkForSerializedStrings($data$class, FieldItemInterface $field_item) {
    // Require specialized denormalizers for fields with 'serialize' columns.     // Note: this cannot be checked in ::supportsDenormalization() because at     // that time we only have the field item class. ::hasSerializeColumn()     // must be able to call $field_item->schema(), which requires a field     // storage definition. To determine that, the entity type and bundle     // must be known, which is contextual information that the Symfony     // serializer does not pass to ::supportsDenormalization().     if (!is_array($data)) {
      $data = [$field_item->getDataDefinition()->getMainPropertyName() => $data];
    }
    if ($this->dataHasStringForSerializeColumn($field_item$data)) {
      $field_name = $field_item->getParent() ? $field_item->getParent()->getName() : $field_item->getName();
      throw new \LogicException(sprintf('The generic FieldItemNormalizer cannot denormalize string values for "%s" properties of the "%s" field (field item class: %s).', implode('", "', $this->getSerializedPropertyNames($field_item))$field_name$class));
    }
  }

  /** * Checks if the data contains string value for serialize column. * * @param \Drupal\Core\Field\FieldItemInterface $field_item * The field item. * @param array $data * The data being denormalized. * * @return bool * TRUE if there is a string value for serialize column, otherwise FALSE. */
Home | Imprint | This part of the site doesn't use cookies.