Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. YamlEncoderContextBuilder.php

class YamlEncoderContextBuilder

A helper providing autocompletion for available YamlEncoder options.

Note that the "indentation" setting is not offered in this builder because it can only be set during the construction of the YamlEncoder, but not per call.

@author Mathias Arlaud <mathias.arlaud@gmail.com>

Hierarchy

  • class \Symfony\Component\Serializer\Context\Encoder\YamlEncoderContextBuilder implements \Symfony\Component\Serializer\Context\ContextBuilderInterface uses \Symfony\Component\Serializer\Context\ContextBuilderTrait

Expanded class hierarchy of YamlEncoderContextBuilder

File

vendor/symfony/serializer/Context/Encoder/YamlEncoderContextBuilder.php, line 27

Namespace

Symfony\Component\Serializer\Context\Encoder
View source
final class YamlEncoderContextBuilder implements ContextBuilderInterface {
    use ContextBuilderTrait;
    
    /**
     * Configures the threshold to switch to inline YAML.
     */
    public function withInlineThreshold(?int $inlineThreshold) : static {
        return $this->with(YamlEncoder::YAML_INLINE, $inlineThreshold);
    }
    
    /**
     * Configures the indentation level.
     *
     * Must be positive.
     *
     * @param int<0, max>|null $indentLevel
     */
    public function withIndentLevel(?int $indentLevel) : static {
        return $this->with(YamlEncoder::YAML_INDENT, $indentLevel);
    }
    
    /**
     * Configures \Symfony\Component\Yaml\Dumper::dump flags bitmask.
     *
     * @see \Symfony\Component\Yaml\Yaml
     */
    public function withFlags(?int $flags) : static {
        return $this->with(YamlEncoder::YAML_FLAGS, $flags);
    }
    
    /**
     * Configures whether to preserve empty objects "{}" or to convert them to null.
     */
    public function withPreservedEmptyObjects(?bool $preserveEmptyObjects) : static {
        return $this->with(YamlEncoder::PRESERVE_EMPTY_OBJECTS, $preserveEmptyObjects);
    }

}

Members

Title Sort descending Modifiers Object type Summary
ContextBuilderTrait::$context private property
ContextBuilderTrait::toArray public function
ContextBuilderTrait::with protected function
ContextBuilderTrait::withContext public function
YamlEncoderContextBuilder::withFlags public function Configures \Symfony\Component\Yaml\Dumper::dump flags bitmask.
YamlEncoderContextBuilder::withIndentLevel public function Configures the indentation level.
YamlEncoderContextBuilder::withInlineThreshold public function Configures the threshold to switch to inline YAML.
YamlEncoderContextBuilder::withPreservedEmptyObjects public function Configures whether to preserve empty objects &quot;{}&quot; or to convert them to null.
RSS feed
Powered by Drupal