Skip to content

Commit

Permalink
Merge pull request #227 from quantcdn/feature/delete-files
Browse files Browse the repository at this point in the history
Updated to support deleted file entities.
  • Loading branch information
kepol authored Feb 28, 2024
2 parents 11d6868 + 3a9d420 commit 445fe2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ function _quant_entity_delete_op(EntityInterface $entity) {
case 'taxonomy_term':
Seed::unpublishTaxonomyTerm($entity);
break;

case 'file':
Seed::unpublishFile($entity);
break;
}

}
Expand Down
15 changes: 13 additions & 2 deletions src/Seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ public static function unpublishNode(EntityInterface $entity) {

$langcode = $entity->language()->getId();
$nid = $entity->get('nid')->value;

$url = Utility::getCanonicalUrl('node', $nid, $langcode);

$site_config = \Drupal::config('system.site');
Expand All @@ -389,7 +388,6 @@ public static function unpublishTaxonomyTerm(EntityInterface $entity) {

$langcode = $entity->language()->getId();
$tid = $entity->get('tid')->value;

$url = Utility::getCanonicalUrl('taxonomy_term', $tid, $langcode);

// Handle internal path redirects.
Expand All @@ -398,6 +396,19 @@ public static function unpublishTaxonomyTerm(EntityInterface $entity) {
\Drupal::service('event_dispatcher')->dispatch(new QuantEvent('', $url, [], NULL), QuantEvent::UNPUBLISH);
}

/**
* Unpublish the file from Quant.
*
* @param Drupal\Core\Entity\EntityInterface $entity
* The file entity.
*/
public static function unpublishFile(EntityInterface $entity) {

$url = $entity->createFileUrl();

\Drupal::service('event_dispatcher')->dispatch(new QuantEvent('', $url, [], NULL), QuantEvent::UNPUBLISH);
}

/**
* Unpublish path alias via API request.
*/
Expand Down

0 comments on commit 445fe2f

Please sign in to comment.