You are here

class MediaEntityInstantiatedEvent in Instagram Feeds 8

En event occurs when instagram_feeds creates a new media entity.

This event is more useful than hook_entity_presave(), because it also has data received from Instagram API, so it is possible to manipulate that data in order to modify media entity before it will be saved.

Hierarchy

Expanded class hierarchy of MediaEntityInstantiatedEvent

1 file declares its use of MediaEntityInstantiatedEvent
CronHandler.php in src/CronHandler.php

File

src/Event/MediaEntityInstantiatedEvent.php, line 16

Namespace

Drupal\instagram_feeds\Event
View source
class MediaEntityInstantiatedEvent extends InstagramFeedsEventBase {

  /**
   * Just created media entity.
   *
   * @var \Drupal\media\MediaInterface
   */
  public $mediaEntity;

  /**
   * Instagram single post data.
   *
   * @var array
   */
  public $post;

  /**
   * Constructs the object.
   *
   * @param \Drupal\Core\Config\ImmutableConfig $configuration
   *   The Instagram feeds module settings.
   * @param \Drupal\instagram_feeds\Entity\InstagramAccountInterface $account
   *   The Instagram account.
   * @param \Drupal\media\MediaInterface $media
   *   The media entity just created (not saved yet).
   * @param array $post
   *   Instagram single post data.
   */
  public function __construct(ImmutableConfig $configuration, InstagramAccountInterface $account, MediaInterface $media, array $post) {
    parent::__construct($configuration, $account);
    $this->mediaEntity = $media;
    $this->post = $post;
  }

  /**
   * {@inheritdoc}
   */
  public static function getEventName() : string {
    return 'instagram_feeds_media_entity_instantiated';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InstagramFeedsEventBase::$account private property Instagram account.
InstagramFeedsEventBase::$config private property Instagram Feeds Config bucket.
InstagramFeedsEventBase::getAccount public function Gets related Instagram Account.
InstagramFeedsEventBase::getConfig public function Gets Instagram Feeds setting (except client_secret).
MediaEntityInstantiatedEvent::$mediaEntity public property Just created media entity.
MediaEntityInstantiatedEvent::$post public property Instagram single post data.
MediaEntityInstantiatedEvent::getEventName public static function Returns event system name for dispatcher. Overrides InstagramFeedsEventBase::getEventName
MediaEntityInstantiatedEvent::__construct public function Constructs the object. Overrides InstagramFeedsEventBase::__construct