-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CollectTaxonomyTermsEvent and related code.
- Loading branch information
Showing
8 changed files
with
144 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Drupal\quant\Event; | ||
|
||
use Drupal\quant\Plugin\QueueItem\TaxonomyTermItem; | ||
|
||
/** | ||
* Collect taxonomy terms event. | ||
* | ||
* This is triggered when we need to gather all taxonomy terms | ||
* to export to Quant. | ||
*/ | ||
class CollectTaxonomyTermsEvent extends ConfigFormEventBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $queueItemClass = TaxonomyTermItem::class; | ||
|
||
} |
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,56 @@ | ||
<?php | ||
|
||
namespace Drupal\quant\Plugin\QueueItem; | ||
|
||
use Drupal\quant\Seed; | ||
|
||
/** | ||
* A taxonomy term queue item. | ||
* | ||
* @ingroup quant | ||
*/ | ||
class TaxonomyTermItem implements QuantQueueItemInterface { | ||
|
||
/** | ||
* The taxonomy term id. | ||
* | ||
* @var int | ||
*/ | ||
private $tid; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __construct(array $data = []) { | ||
$this->tid = $data['tid']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function send() { | ||
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($this->tid); | ||
|
||
foreach ($term->getTranslationLanguages() as $langcode => $language) { | ||
Seed::seedTaxonomyTerm($term, $langcode); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function info() { | ||
return [ | ||
'#type' => '#markup', | ||
'#markup' => "<b>Term ID:</b> {$this->tid}", | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function log($phase = 'start') { | ||
return "[taxonomy_term_item] - tid: {$this->tid}"; | ||
} | ||
|
||
} |
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