You are here

protected function JsonapiHelper::addOption in Entity Share 8

Helper function to add an option.

Parameters

array $options: The array of options for the tableselect form type element.

\Drupal\Core\Entity\ContentEntityInterface $entity: An unserialized entity.

string $entity_type_id: The entity type ID of the entity.

string $bundle_id: The bundle id of the entity.

int $level: The level of indentation.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\InvalidArgumentException

1 call to JsonapiHelper::addOption()
JsonapiHelper::addOptionFromJson in modules/entity_share_client/src/Service/JsonapiHelper.php
Helper function to add an option.

File

modules/entity_share_client/src/Service/JsonapiHelper.php, line 468

Class

JsonapiHelper
Class JsonapiHelper.

Namespace

Drupal\entity_share_client\Service

Code

protected function addOption(array &$options, ContentEntityInterface $entity, $entity_type_id, $bundle_id, $level = 0) {
  $indentation = '';
  for ($i = 1; $i <= $level; $i++) {
    $indentation .= '<div class="indentation">&nbsp;</div>';
  }
  $label = new FormattableMarkup($indentation . '@label', [
    '@label' => $entity
      ->label(),
  ]);
  $status_info = $this
    ->getStatusInfo($entity, $entity_type_id);
  $options[$entity
    ->uuid()] = [
    'label' => $label,
    'type' => $entity
      ->getEntityType()
      ->getLabel(),
    'bundle' => $this->bundleInfos[$entity_type_id][$bundle_id]['label'],
    'language' => $this
      ->getEntityLanguageLabel($entity),
    'status' => $status_info['label'],
    '#attributes' => [
      'class' => [
        $status_info['class'],
      ],
    ],
  ];
}