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
- class \Drupal\instagram_feeds\Event\InstagramFeedsEventBase extends \Symfony\Component\EventDispatcher\Event
- class \Drupal\instagram_feeds\Event\MediaEntityInstantiatedEvent
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\EventView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InstagramFeedsEventBase:: |
private | property | Instagram account. | |
InstagramFeedsEventBase:: |
private | property | Instagram Feeds Config bucket. | |
InstagramFeedsEventBase:: |
public | function | Gets related Instagram Account. | |
InstagramFeedsEventBase:: |
public | function | Gets Instagram Feeds setting (except client_secret). | |
MediaEntityInstantiatedEvent:: |
public | property | Just created media entity. | |
MediaEntityInstantiatedEvent:: |
public | property | Instagram single post data. | |
MediaEntityInstantiatedEvent:: |
public static | function |
Returns event system name for dispatcher. Overrides InstagramFeedsEventBase:: |
|
MediaEntityInstantiatedEvent:: |
public | function |
Constructs the object. Overrides InstagramFeedsEventBase:: |