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