class S3FileEntityHandler in Acquia Content Hub 8.2
Manipulates file content entity CDF representation to better support files.
Hierarchy
- class \Drupal\acquia_contenthub_s3\EventSubscriber\Cdf\S3FileEntityHandler implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of S3FileEntityHandler
1 file declares its use of S3FileEntityHandler
- S3FileEntityHandlerTest.php in modules/
acquia_contenthub_s3/ tests/ src/ Unit/ S3FileEntityHandlerTest.php
1 string reference to 'S3FileEntityHandler'
- acquia_contenthub_s3.services.yml in modules/
acquia_contenthub_s3/ acquia_contenthub_s3.services.yml - modules/acquia_contenthub_s3/acquia_contenthub_s3.services.yml
1 service uses S3FileEntityHandler
- s3_file_entity.cdf.handler in modules/
acquia_contenthub_s3/ acquia_contenthub_s3.services.yml - Drupal\acquia_contenthub_s3\EventSubscriber\Cdf\S3FileEntityHandler
File
- modules/
acquia_contenthub_s3/ src/ EventSubscriber/ Cdf/ S3FileEntityHandler.php, line 14
Namespace
Drupal\acquia_contenthub_s3\EventSubscriber\CdfView source
class S3FileEntityHandler implements EventSubscriberInterface {
/**
* The s3 file mapper.
*
* @var \Drupal\acquia_contenthub_s3\S3FileMap
*/
protected $s3FileMapper;
/**
* FileEntityHandler constructor.
*
* @param \Drupal\acquia_contenthub_s3\S3FileMapper $s3_file_mapper
* The s3 file mapper.
*/
public function __construct(S3FileMapper $s3_file_mapper) {
$this->s3FileMapper = $s3_file_mapper;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// At this point the entity has been already crated, hence the weight.
$events[AcquiaContentHubEvents::PARSE_CDF][] = [
'onParseCdf',
90,
];
return $events;
}
/**
* Parse CDF attributes to record s3 related files.
*
* @param \Drupal\acquia_contenthub\Event\ParseCdfEntityEvent $event
* The Parse CDF Entity Event.
*
* @throws \Exception
*/
public function onParseCdf(ParseCdfEntityEvent $event) {
/** @var \Drupal\file\FileInterface $entity */
$entity = $event
->getEntity();
if (!$entity instanceof FileInterface) {
return;
}
$cdf = $event
->getCdf();
$file_uri = $cdf
->getAttribute('file_uri');
if (!$file_uri) {
return;
}
$this->s3FileMapper
->mapS3File($cdf, $entity);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
S3FileEntityHandler:: |
protected | property | The s3 file mapper. | |
S3FileEntityHandler:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
S3FileEntityHandler:: |
public | function | Parse CDF attributes to record s3 related files. | |
S3FileEntityHandler:: |
public | function | FileEntityHandler constructor. |