You are here

public function AbstractNormalizer::setCamelizedAttributes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Normalizer/AbstractNormalizer.php \Symfony\Component\Serializer\Normalizer\AbstractNormalizer::setCamelizedAttributes()

Set attributes to be camelized on denormalize.

Parameters

array $camelizedAttributes:

Return value

self

Throws

LogicException

Deprecated

Deprecated since version 2.7, to be removed in 3.0. Use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter instead.

File

vendor/symfony/serializer/Normalizer/AbstractNormalizer.php, line 154

Class

AbstractNormalizer
Normalizer implementation.

Namespace

Symfony\Component\Serializer\Normalizer

Code

public function setCamelizedAttributes(array $camelizedAttributes) {
  @trigger_error(sprintf('%s is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\\Component\\Serializer\\NameConverter\\CamelCaseToSnakeCaseNameConverter instead.', __METHOD__), E_USER_DEPRECATED);
  if ($this->nameConverter && !$this->nameConverter instanceof CamelCaseToSnakeCaseNameConverter) {
    throw new LogicException(sprintf('%s cannot be called if a custom Name Converter is defined.', __METHOD__));
  }
  $attributes = array();
  foreach ($camelizedAttributes as $camelizedAttribute) {
    $attributes[] = lcfirst(preg_replace_callback('/(^|_|\\.)+(.)/', function ($match) {
      return ('.' === $match[1] ? '_' : '') . strtoupper($match[2]);
    }, $camelizedAttribute));
  }
  $this->nameConverter = new CamelCaseToSnakeCaseNameConverter($attributes);
  return $this;
}