public function CliService::check_entity_flags in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 8 src/Cli/CliService.php \Drupal\cms_content_sync\Cli\CliService::check_entity_flags()
- 2.1.x src/Cli/CliService.php \Drupal\cms_content_sync\Cli\CliService::check_entity_flags()
Check the flags for an entity.
Parameters
ICLIIO $io: The CLI service which allows interoperability
string $entity_uuid: The uuid of the entity the flags should be checked for
array $options: An array containing the option parameters provided by Drush
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
Cli/ CliService.php, line 454
Class
Namespace
Drupal\cms_content_sync\CliCode
public function check_entity_flags($io, $entity_uuid, $options = [
'flag' => null,
]) {
$flag = empty($options['flag']) ? null : $options['flag'];
/**
* @var \Drupal\cms_content_sync\Entity\EntityStatus[] $entity_status
*/
$entity_status = \Drupal::entityTypeManager()
->getStorage('cms_content_sync_entity_status')
->loadByProperties([
'entity_uuid' => $entity_uuid,
]);
if (empty($entity_status)) {
$io
->text(dt('There is no status entity existent yet for this UUID.'));
}
else {
foreach ($entity_status as $status) {
$result = '';
$io
->text(dt('Flow: ' . $status
->get('flow')->value));
if (empty($flag)) {
$result .= 'FLAG_IS_SOURCE_ENTITY: ' . ($status
->isSourceEntity() ? 'TRUE' : 'FALSE') . PHP_EOL;
$result .= 'FLAG_PUSH_ENABLED: ' . ($status
->isPushEnabled() ? 'TRUE' : 'FALSE') . PHP_EOL;
$result .= 'FLAG_PUSHED_AS_DEPENDENCY: ' . ($status
->isPushedAsDependency() ? 'TRUE' : 'FALSE') . PHP_EOL;
$result .= 'FLAG_EDIT_OVERRIDE: ' . ($status
->isOverriddenLocally() ? 'TRUE' : 'FALSE') . PHP_EOL;
$result .= 'FLAG_USER_ENABLED_PUSH: ' . ($status
->didUserEnablePush() ? 'TRUE' : 'FALSE') . PHP_EOL;
$result .= 'FLAG_DELETED: ' . ($status
->isDeleted() ? 'TRUE' : 'FALSE') . PHP_EOL;
}
else {
switch ($flag) {
case 'FLAG_IS_SOURCE_ENTITY':
$status
->isSourceEntity() ? $result .= 'TRUE' : ($result .= 'FALSE');
break;
case 'FLAG_PUSH_ENABLED':
$status
->isPushEnabled() ? $result .= 'TRUE' : ($result .= 'FALSE');
break;
case 'FLAG_PUSHED_AS_DEPENDENCY':
$status
->isPushedAsDependency() ? $result .= 'TRUE' : ($result .= 'FALSE');
break;
case 'FLAG_EDIT_OVERRIDE':
$status
->isOverriddenLocally() ? $result .= 'TRUE' : ($result .= 'FALSE');
break;
case 'FLAG_USER_ENABLED_PUSH':
$status
->didUserEnablePush() ? $result .= 'TRUE' : ($result .= 'FALSE');
break;
case 'FLAG_DELETED':
$status
->isDeleted() ? $result .= 'TRUE' : ($result .= 'FALSE');
break;
}
}
$io
->text(dt($result));
}
}
}