Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Drupal\Core\DependencyInjection\Compiler; use Symfony\Component\Dependen..

Decoded Output download

<?php

namespace Drupal\Core\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
 * Registers all event subscribers to the event dispatcher.
 */
class RegisterEventSubscribersPass implements CompilerPassInterface {

  /**
   * {@inheritdoc}
   */
  public function process(ContainerBuilder $container) {
    if (!$container->hasDefinition('event_dispatcher')) {
      return;
    }

    $definition = $container->getDefinition('event_dispatcher');

    $event_subscriber_info = [];
    foreach ($container->findTaggedServiceIds('event_subscriber') as $id => $attributes) {

      // We must assume that the class value has been correctly filled, even if
      // the service is created by a factory.
      $class = $container->getDefinition($id)->getClass();

      $refClass = new \ReflectionClass($class);
      $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
      if (!$refClass->implementsInterface($interface)) {
        throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
      }

      // Get all subscribed events.
      foreach ($class::getSubscribedEvents() as $event_name => $params) {
        if (is_string($params)) {
          $priority = 0;
          $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $params]];
        }
        elseif (is_string($params[0])) {
          $priority = isset($params[1]) ? $params[1] : 0;
          $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $params[0]]];
        }
        else {
          foreach ($params as $listener) {
            $priority = isset($listener[1]) ? $listener[1] : 0;
            $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $listener[0]]];
          }
        }
      }
    }

    foreach (array_keys($event_subscriber_info) as $event_name) {
      krsort($event_subscriber_info[$event_name]);
    }

    $definition->addArgument($event_subscriber_info);
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Drupal\Core\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
 * Registers all event subscribers to the event dispatcher.
 */
class RegisterEventSubscribersPass implements CompilerPassInterface {

  /**
   * {@inheritdoc}
   */
  public function process(ContainerBuilder $container) {
    if (!$container->hasDefinition('event_dispatcher')) {
      return;
    }

    $definition = $container->getDefinition('event_dispatcher');

    $event_subscriber_info = [];
    foreach ($container->findTaggedServiceIds('event_subscriber') as $id => $attributes) {

      // We must assume that the class value has been correctly filled, even if
      // the service is created by a factory.
      $class = $container->getDefinition($id)->getClass();

      $refClass = new \ReflectionClass($class);
      $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
      if (!$refClass->implementsInterface($interface)) {
        throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
      }

      // Get all subscribed events.
      foreach ($class::getSubscribedEvents() as $event_name => $params) {
        if (is_string($params)) {
          $priority = 0;
          $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $params]];
        }
        elseif (is_string($params[0])) {
          $priority = isset($params[1]) ? $params[1] : 0;
          $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $params[0]]];
        }
        else {
          foreach ($params as $listener) {
            $priority = isset($listener[1]) ? $listener[1] : 0;
            $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $listener[0]]];
          }
        }
      }
    }

    foreach (array_keys($event_subscriber_info) as $event_name) {
      krsort($event_subscriber_info[$event_name]);
    }

    $definition->addArgument($event_subscriber_info);
  }

}

Function Calls

None

Variables

None

Stats

MD5 231c0d4487af06be8f8258bc3809b38a
Eval Count 0
Decode Time 81 ms