going on with home display: shworooms
This commit is contained in:
@@ -8,6 +8,8 @@ use Drupal\Core\Field\FieldItemList;
|
||||
use Drupal\Core\TypedData\TypedDataInterface;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\TypedData\ComputedItemListTrait;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
|
||||
|
||||
// https://www.drupal.org/node/2112677
|
||||
// https://www.cornel.co/article/entity-reference-computed-field-example-drupal
|
||||
@@ -38,9 +40,15 @@ class ComputedShowroomsReferences extends EntityReferenceFieldItemList
|
||||
$query = \Drupal::entityQuery('taxonomy_term')
|
||||
->condition('status', 1)
|
||||
->condition('vid', 'showroom');
|
||||
// remove masqué
|
||||
|
||||
|
||||
$tids = $query->execute();
|
||||
shuffle($tids);
|
||||
foreach ($tids as $key => $tid) {
|
||||
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);
|
||||
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
|
||||
if($sid != 'workflow_visible') continue;
|
||||
$this->list[$key] = $this->createItem($key, $tid);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user