This repository was archived by the owner on Aug 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from ec-europa/drupal-8.6.x
Run on 8.6.x
- Loading branch information
Showing
22 changed files
with
385 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Drupal\rdf_taxonomy\Entity; | ||
|
||
use Drupal\Core\Entity\EntityTypeInterface; | ||
use Drupal\taxonomy\Entity\Term; | ||
|
||
/** | ||
* Provides an alternative entity class for 'taxonomy_term'. | ||
*/ | ||
class RdfTerm extends Term { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { | ||
$base_fields = parent::baseFieldDefinitions($entity_type); | ||
// Support also Drupal 8.5.x. | ||
if (isset($base_fields['status'])) { | ||
$base_fields['status']->setCustomStorage(TRUE); | ||
} | ||
return $base_fields; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isPublished() { | ||
// The RDF taxonomy term doesn't support the published flag. | ||
return TRUE; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setPublished($published = NULL) { | ||
// The RDF taxonomy term doesn't support the published flag. | ||
return $this; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
modules/rdf_taxonomy/src/EventSubscriber/OutboundTermParentSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Drupal\rdf_taxonomy\EventSubscriber; | ||
|
||
use Drupal\rdf_entity\Event\OutboundValueEvent; | ||
use Drupal\rdf_entity\Event\RdfEntityEvents; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* Massages outbound term parent value. | ||
*/ | ||
class OutboundTermParentSubscriber implements EventSubscriberInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents() { | ||
return [ | ||
RdfEntityEvents::OUTBOUND_VALUE => 'fixParentTermId', | ||
]; | ||
} | ||
|
||
/** | ||
* Fixes the term parent ID. | ||
* | ||
* Drupal core uses taxonomy terms with numeric IDs. If case, we convert the | ||
* term ID, from a numeric type to string. | ||
* | ||
* @param \Drupal\rdf_entity\Event\OutboundValueEvent $event | ||
* The outbound value event. | ||
*/ | ||
public function fixParentTermId(OutboundValueEvent $event) { | ||
if ($event->getEntityTypeId() === 'taxonomy_term' && $event->getField() === 'parent') { | ||
$event->setValue((string) $event->getValue()); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.