public function AcquiaContentHubEntityCommands::contenthubLocal in Acquia Content Hub 8.2
Prints the CDF from a local source (drupal site)
@option decode Decodes the metadata 'data' element to make it easier to understand the content of each CDF entity stored in Content Hub.
@command acquia:contenthub-local @aliases ach-lo,acquia-contenthub-local
Parameters
string $entity_type: The entity type to load.
string $entity_id: The entity identifier or entity's UUID.
array $options: An associative array of options whose values come from cli, aliases, config, etc.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
Deprecated
//@codingStandardsIgnoreLine
File
- src/
Commands/ AcquiaContentHubEntityCommands.php, line 142
Class
- AcquiaContentHubEntityCommands
- Drush commands for interacting with Acquia Content Hub entities.
Namespace
Drupal\acquia_contenthub\CommandsCode
public function contenthubLocal($entity_type, $entity_id, array $options = [
'decode' => NULL,
]) {
$entity_type_manager = \Drupal::entityTypeManager();
/** @var \Drupal\Core\Entity\EntityRepository $entity_repository */
$entity_repository = \Drupal::service('entity.repository');
if (empty($entity_type) || empty($entity_id)) {
throw new \Exception(dt("Missing required parameters: entity_type and entity_id (or entity's uuid)"));
}
elseif (!$entity_type_manager
->getDefinition($entity_type)) {
throw new \Exception(dt("Entity type @entity_type does not exist", [
'@entity_type' => $entity_type,
]));
}
else {
if (Uuid::isValid($entity_id)) {
$entity = $entity_repository
->loadEntityByUuid($entity_type, $entity_id);
}
else {
$entity = $entity_type_manager
->getStorage($entity_type)
->load($entity_id);
}
}
if (!$entity) {
throw new \Exception(dt("Entity having entity_type = @entity_type and entity_id = @entity_id does not exist.", [
'@entity_type' => $entity_type,
'@entity_id' => $entity_id,
]));
}
// If nothing else, return our object structure.
$this
->contenthubEntity('local', $entity
->uuid(), $entity_type, $options);
}