FallbackEntity.php in Media Expire 8.2
File
src/Plugin/GraphQL/DataProducer/FallbackEntity.php
View source
<?php
namespace Drupal\media_expire\Plugin\GraphQL\DataProducer;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
use Drupal\media\MediaInterface;
use Drupal\media_expire\MediaExpireService;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FallbackEntity extends DataProducerPluginBase implements ContainerFactoryPluginInterface {
protected $mediaExpireService;
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('media_expire.service'));
}
public function __construct(array $configuration, $pluginId, $pluginDefinition, MediaExpireService $mediaExpireService) {
parent::__construct($configuration, $pluginId, $pluginDefinition);
$this->mediaExpireService = $mediaExpireService;
}
public function resolve(MediaInterface $entity, RefinableCacheableDependencyInterface $metadata) {
return $this->mediaExpireService
->getFallbackMedia($entity);
}
}