You are here

abstract class InstagramFeedsEventBase 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 InstagramFeedsEventBase

File

src/Event/InstagramFeedsEventBase.php, line 16

Namespace

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

  /**
   * Instagram Feeds Config bucket.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  private $config;

  /**
   * Instagram account.
   *
   * @var \Drupal\instagram_feeds\Entity\InstagramAccountInterface $account
   */
  private $account;

  /**
   * Constructs the object.
   *
   * @param \Drupal\Core\Config\ImmutableConfig $configuration
   *   The Instagram feeds module settings.
   * @param \Drupal\instagram_feeds\Entity\InstagramAccountInterface $account
   *   The Instagram account.
   */
  public function __construct(ImmutableConfig $configuration, InstagramAccountInterface $account) {
    $this->config = $configuration;
    $this->account = $account;
  }

  /**
   * Returns event system name for dispatcher.
   */
  public static abstract function getEventName() : string;

  /**
   * Gets Instagram Feeds setting (except client_secret).
   *
   * @param string $key
   *   Config key to obtain.
   *
   * @return mixed
   *   Config key value.
   */
  public function getConfig($key) {

    // Do not share client_secret.
    return $key !== 'client_secret' ? $this->config
      ->get($key) : 'SECRET';
  }

  /**
   * Gets related Instagram Account.
   *
   * @return \Drupal\instagram_feeds\Entity\InstagramAccountInterface
   *   Currently processed Instagram account.
   */
  public function getAccount() : InstagramAccountInterface {
    return $this->account;
  }

}

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).
InstagramFeedsEventBase::getEventName abstract public static function Returns event system name for dispatcher. 2
InstagramFeedsEventBase::__construct public function Constructs the object. 2