You are here

class Log in Acquia Content Hub 8.2

Log for not yet confirmed entities found.

@package Drupal\acquia_contenthub_publisher\EventSubscriber\NotConfirmedEntitiesFound

Hierarchy

  • class \Drupal\acquia_contenthub_publisher\EventSubscriber\NotConfirmedEntitiesFound\Log implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of Log

1 string reference to 'Log'
acquia_contenthub_publisher.services.yml in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
1 service uses Log
acquia_contenthub_publisher.not_confirmed_entities.log in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
Drupal\acquia_contenthub_publisher\EventSubscriber\NotConfirmedEntitiesFound\Log

File

modules/acquia_contenthub_publisher/src/EventSubscriber/NotConfirmedEntitiesFound/Log.php, line 15

Namespace

Drupal\acquia_contenthub_publisher\EventSubscriber\NotConfirmedEntitiesFound
View source
class Log implements EventSubscriberInterface {

  /**
   * Acquia Logger Channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  /**
   * Log constructor.
   *
   * @param \Drupal\Core\Logger\LoggerChannelInterface $logger_channel
   *   Acquia Logger Channel.
   */
  public function __construct(LoggerChannelInterface $logger_channel) {
    $this->logger = $logger_channel;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[ContentHubPublisherEvents::NOT_CONFIRMED_ENTITIES_FOUND][] = 'onNotConfirmedEntitiesFound';
    return $events;
  }

  /**
   * Logs a brief information about "stale" entities found.
   *
   * @param \Drupal\acquia_contenthub_publisher\Event\NotConfirmedEntitiesFoundEvent $event
   *   Event.
   */
  public function onNotConfirmedEntitiesFound(NotConfirmedEntitiesFoundEvent $event) {
    $stale_entities_breakdown = [];
    array_map(function ($item) use (&$stale_entities_breakdown) {
      $stale_entities_breakdown[$item->entity_type][] = $item->entity_id;
    }, $event
      ->getItems());
    array_walk($stale_entities_breakdown, function (&$value, $key) {
      $value = $key . ' [' . implode(', ', $value) . ']';
    });
    $this->logger
      ->warning('"Stale" entities found (type [ids]): %entities_breakdown.', [
      '%entities_breakdown' => implode('; ', $stale_entities_breakdown),
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Log::$logger protected property Acquia Logger Channel.
Log::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
Log::onNotConfirmedEntitiesFound public function Logs a brief information about "stale" entities found.
Log::__construct public function Log constructor.