public function FileEntityHandler::onParseCdf in Acquia Content Hub 8.2
Parse CDF attributes to import files as necessary.
Parameters
\Drupal\acquia_contenthub\Event\ParseCdfEntityEvent $event: The Parse CDF Entity Event.
Throws
\Drupal\Component\Plugin\Exception\PluginException
File
- src/
EventSubscriber/ Cdf/ FileEntityHandler.php, line 77
Class
- FileEntityHandler
- Manipulates file content entity CDF representation to better support files.
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfCode
public function onParseCdf(ParseCdfEntityEvent $event) {
$cdf = $event
->getCdf();
$entity_type = $cdf
->getAttribute('entity_type');
if ($entity_type && $entity_type
->getValue()[LanguageInterface::LANGCODE_NOT_SPECIFIED] !== 'file') {
return;
}
if ($cdf
->getAttribute('file_scheme')) {
$scheme = $cdf
->getAttribute('file_scheme')
->getValue()[LanguageInterface::LANGCODE_NOT_SPECIFIED];
$handler = $this->manager
->createInstance($scheme);
$handler
->getFile($cdf);
}
else {
$label_attribute = $cdf
->getAttribute('label');
$label = $label_attribute ? $label_attribute
->getValue()[LanguageInterface::LANGCODE_NOT_SPECIFIED] : '';
$this->channel
->warning(sprintf('File %s does not have a scheme and therefore was not copied. This likely
means that its scheme is remote, unsupported or that it should already exist within a module, theme or library in
the subscriber.', $label));
}
}