class FocalPoint in Thunder 6.2.x
Resolves the focal point positions for a file.
Plugin annotation
@DataProducer(
id = "focal_point",
name = @Translation("FocalPoint"),
description = @Translation("Resolves the focal point positions for a file."),
produces = @ContextDefinition("any",
label = @Translation("Focal point positions")
),
consumes = {
"file" = @ContextDefinition("entity",
label = @Translation("Root value")
)
}
)
Hierarchy
- class \Drupal\thunder_gqls\Plugin\GraphQL\DataProducer\FocalPoint extends \Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase implements ContainerFactoryPluginInterface
Expanded class hierarchy of FocalPoint
1 string reference to 'FocalPoint'
- ThunderSchema::resolveBaseTypes in modules/
thunder_gqls/ src/ Plugin/ GraphQL/ Schema/ ThunderSchema.php - Resolve custom types, that are used in multiple places.
File
- modules/
thunder_gqls/ src/ Plugin/ GraphQL/ DataProducer/ FocalPoint.php, line 30
Namespace
Drupal\thunder_gqls\Plugin\GraphQL\DataProducerView source
class FocalPoint extends DataProducerPluginBase implements ContainerFactoryPluginInterface {
/**
* The focal point config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* The focal point manager service.
*
* @var \Drupal\focal_point\FocalPointManagerInterface
*/
protected $focalPointManager;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
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'));
}
/**
* FocalPoint constructor.
*
* @param array $configuration
* The plugin configuration array.
* @param string $pluginId
* The plugin id.
* @param mixed $pluginDefinition
* The plugin definition.
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory service.
* @param \Drupal\focal_point\FocalPointManagerInterface $focalPointManager
* The focal point manager service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The 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;
}
/**
* Resolve the focal point positions.
*
* @param \Drupal\file\FileInterface $file
* The entity.
*
* @return mixed
* The focal point position tag.
*/
public function resolve(FileInterface $file) {
if (!$this->moduleHandler
->moduleExists('focal_point')) {
return '';
}
return $this->focalPointManager
->getCropEntity($file, $this->config
->get('crop_type'))
->position();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FocalPoint:: |
protected | property | The focal point config. | |
FocalPoint:: |
protected | property | The focal point manager service. | |
FocalPoint:: |
protected | property | The module handler. | |
FocalPoint:: |
public static | function |
@codeCoverageIgnore Overrides ContainerFactoryPluginInterface:: |
|
FocalPoint:: |
public | function | Resolve the focal point positions. | |
FocalPoint:: |
public | function | FocalPoint constructor. |