class JsonldBundle

Jsonld dependency injection container.

Hierarchy

Expanded class hierarchy of JsonldBundle

File

drupal/core/modules/jsonld/lib/Drupal/jsonld/JsonldBundle.php, line 17
Definition of Drupal\jsonld\JsonldBundle.

Namespace

Drupal\jsonld
View source
class JsonldBundle extends Bundle {

  /**
   * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build().
   */
  public function build(ContainerBuilder $container) {
    $priority = 5;

    // Normalizers can be specified to support a particular class and format in
    // Normalizer::supportsNormalization(). Since the first matching Normalizer
    // is used, Normalizers should be ordered from most specific to least
    // specific.
    $normalizers = array(
      // Field Item.
      'entity_reference' => array(
        'jsonld' => 'Drupal\\jsonld\\JsonldEntityReferenceNormalizer',
      ),
      'field_item' => array(
        'jsonld' => 'Drupal\\jsonld\\JsonldFieldItemNormalizer',
      ),
      // Entity.
      'entity' => array(
        'jsonld' => 'Drupal\\jsonld\\JsonldEntityNormalizer',
      ),
    );

    // Encoders can only specify which format they support in
    // Encoder::supportsEncoding().
    $encoders = array(
      'jsonld' => 'Drupal\\jsonld\\JsonldEncoder',
    );

    // Add Normalizers to service container.
    foreach ($normalizers as $supported_class => $formats) {
      foreach ($formats as $format => $normalizer_class) {
        $container
          ->register("serializer.normalizer.{$supported_class}.{$format}", $normalizer_class)
          ->addTag('normalizer', array(
          'priority' => $priority,
        ));
      }
    }

    // Add Encoders to service container.
    foreach ($encoders as $format => $encoder_class) {
      $container
        ->register("serializer.encoder.{$format}", $encoder_class)
        ->addTag('encoder', array(
        'priority' => $priority,
      ));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Bundle::$extension protected property
Bundle::$name protected property
Bundle::$reflected protected property
Bundle::boot public function Boots the Bundle. Overrides BundleInterface::boot
Bundle::getContainerExtension public function Returns the bundle's container extension. Overrides BundleInterface::getContainerExtension
Bundle::getName final public function Returns the bundle name (the class short name). Overrides BundleInterface::getName
Bundle::getNamespace public function Gets the Bundle namespace. Overrides BundleInterface::getNamespace
Bundle::getParent public function Returns the bundle parent name. Overrides BundleInterface::getParent
Bundle::getPath public function Gets the Bundle directory path. Overrides BundleInterface::getPath
Bundle::registerCommands public function Finds and registers Commands.
Bundle::shutdown public function Shutdowns the Bundle. Overrides BundleInterface::shutdown
ContainerAware::$container protected property @api
ContainerAware::setContainer public function Sets the Container associated with this Controller. Overrides ContainerAwareInterface::setContainer
JsonldBundle::build public function Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build(). Overrides Bundle::build