|
|
|
@ -2,9 +2,9 @@
|
|
|
|
|
|
|
|
|
|
namespace Drupal\islandora\Plugin\ContextReaction; |
|
|
|
|
|
|
|
|
|
use Drupal\Core\Config\ConfigFactoryInterface; |
|
|
|
|
use Drupal\Core\Entity\EntityInterface; |
|
|
|
|
use Drupal\Core\Form\FormStateInterface; |
|
|
|
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; |
|
|
|
|
use Drupal\islandora\ContextReaction\NormalizerAlterReaction; |
|
|
|
|
use Drupal\islandora\MediaSource\MediaSourceService; |
|
|
|
|
use Drupal\jsonld\Normalizer\NormalizerBase; |
|
|
|
@ -19,7 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
|
* label = @Translation("Map URI to predicate") |
|
|
|
|
* ) |
|
|
|
|
*/ |
|
|
|
|
class MappingUriPredicateReaction extends NormalizerAlterReaction implements ContainerFactoryPluginInterface { |
|
|
|
|
class MappingUriPredicateReaction extends NormalizerAlterReaction { |
|
|
|
|
|
|
|
|
|
const URI_PREDICATE = 'drupal_uri_predicate'; |
|
|
|
|
|
|
|
|
@ -28,8 +28,18 @@ class MappingUriPredicateReaction extends NormalizerAlterReaction implements Con
|
|
|
|
|
/** |
|
|
|
|
* {@inheritdoc} |
|
|
|
|
*/ |
|
|
|
|
public function __construct(array $configuration, $plugin_id, $plugin_definition, MediaSourceService $media_source) { |
|
|
|
|
parent::__construct($configuration, $plugin_id, $plugin_definition); |
|
|
|
|
public function __construct(array $configuration, |
|
|
|
|
$plugin_id, |
|
|
|
|
$plugin_definition, |
|
|
|
|
ConfigFactoryInterface $config_factory, |
|
|
|
|
MediaSourceService $media_source) { |
|
|
|
|
|
|
|
|
|
parent::__construct( |
|
|
|
|
$configuration, |
|
|
|
|
$plugin_id, |
|
|
|
|
$plugin_definition, |
|
|
|
|
$config_factory |
|
|
|
|
); |
|
|
|
|
$this->mediaSource = $media_source; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -41,6 +51,7 @@ class MappingUriPredicateReaction extends NormalizerAlterReaction implements Con
|
|
|
|
|
$configuration, |
|
|
|
|
$plugin_id, |
|
|
|
|
$plugin_definition, |
|
|
|
|
$container->get('config.factory'), |
|
|
|
|
$container->get('islandora.media_source_service') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -59,10 +70,7 @@ class MappingUriPredicateReaction extends NormalizerAlterReaction implements Con
|
|
|
|
|
$config = $this->getConfiguration(); |
|
|
|
|
$drupal_predicate = $config[self::URI_PREDICATE]; |
|
|
|
|
if (!is_null($drupal_predicate) && !empty($drupal_predicate)) { |
|
|
|
|
$url = $entity |
|
|
|
|
->toUrl('canonical', ['absolute' => TRUE]) |
|
|
|
|
->setRouteParameter('_format', 'jsonld') |
|
|
|
|
->toString(); |
|
|
|
|
$url = $this->getSubjectUrl($entity); |
|
|
|
|
if ($context['needs_jsonldcontext'] === FALSE) { |
|
|
|
|
$drupal_predicate = NormalizerBase::escapePrefix($drupal_predicate, $context['namespaces']); |
|
|
|
|
} |
|
|
|
|