public function FlowListBuilder::buildRow in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Controller/FlowListBuilder.php \Drupal\cms_content_sync\Controller\FlowListBuilder::buildRow()
- 2.0.x src/Controller/FlowListBuilder.php \Drupal\cms_content_sync\Controller\FlowListBuilder::buildRow()
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- src/
Controller/ FlowListBuilder.php, line 62
Class
- FlowListBuilder
- Provides a listing of Flow.
Namespace
Drupal\cms_content_sync\ControllerCode
public function buildRow(EntityInterface $entity) {
/**
* @var \Drupal\cms_content_sync\Entity\Flow $entity
*/
$row['name'] = $entity
->label();
$row['id'] = $entity
->id();
$config = $this->configFactory
->get('cms_content_sync.flow.' . $entity
->id());
$overwritten = $config
->get('status') != $entity
->status();
$active = $overwritten ? !$entity
->status() : $entity
->status();
$status = $active ? $this
->t('Active') : $this
->t('Inactive');
if ($overwritten) {
$status .= ' <i>(' . $this
->t('Overwritten') . ')</i>';
}
if ($active) {
// Show version mismatch warning.
$entity_type_configs = $entity
->getEntityTypeConfig(null, null, true);
// Get version from config.
$flow_config = \Drupal::config('cms_content_sync.flow.' . $entity
->id());
$version_mismatch = false;
foreach ($entity_type_configs as $config_key => $entity_type_config) {
$entity_type = $entity_type_config['entity_type_name'];
$bundle = $entity_type_config['bundle_name'];
// Get active version.
$active_version = Flow::getEntityTypeVersion($entity_type, $bundle);
// Get config version.
$config_version = $flow_config
->get('sync_entities.' . $config_key . '.version');
if ($active_version != $config_version) {
$version_mismatch = true;
break;
}
}
if ($version_mismatch) {
$status .= ' <i>(' . $this
->t('Version mismatch') . ')</i>';
}
}
$row['status'] = new FormattableMarkup($status, []);
return $row + parent::buildRow($entity);
}