FocalPoint.php in Thunder 6.2.x
File
modules/thunder_gqls/src/Plugin/GraphQL/DataProducer/FocalPoint.php
View source
<?php
namespace Drupal\thunder_gqls\Plugin\GraphQL\DataProducer;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\file\FileInterface;
use Drupal\focal_point\FocalPointManagerInterface;
use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FocalPoint extends DataProducerPluginBase implements ContainerFactoryPluginInterface {
protected $config;
protected $focalPointManager;
protected $moduleHandler;
public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition) {
return new static($configuration, $pluginId, $pluginDefinition, $container
->get('config.factory'), $container
->get('focal_point.manager'), $container
->get('module_handler'));
}
public function __construct(array $configuration, string $pluginId, $pluginDefinition, ConfigFactoryInterface $configFactory, FocalPointManagerInterface $focalPointManager, ModuleHandlerInterface $moduleHandler) {
parent::__construct($configuration, $pluginId, $pluginDefinition);
$this->config = $configFactory
->get('focal_point.settings');
$this->focalPointManager = $focalPointManager;
$this->moduleHandler = $moduleHandler;
}
public function resolve(FileInterface $file) {
if (!$this->moduleHandler
->moduleExists('focal_point')) {
return '';
}
return $this->focalPointManager
->getCropEntity($file, $this->config
->get('crop_type'))
->position();
}
}
Classes
Name |
Description |
FocalPoint |
Resolves the focal point positions for a file. |