You are here

public function HomeboxSettingsForm::getOperations in Homebox 8

Gets this list's default operations.

Parameters

int $block_id: The entity the operations are for.

bool $status: Status of block.

Return value

array The array structure is identical to the return value of self::getOperations().

1 call to HomeboxSettingsForm::getOperations()
HomeboxSettingsForm::buildOperations in src/Form/HomeboxSettingsForm.php
Builds a renderable list of operation links for the entity.

File

src/Form/HomeboxSettingsForm.php, line 460

Class

HomeboxSettingsForm
Class HomeboxForm.

Namespace

Drupal\homebox\Form

Code

public function getOperations($block_id, $status) {
  $operations['delete'] = [
    'title' => t('Delete'),
    'weight' => -10,
    'url' => Url::fromRoute('homebox.settings_form', [
      'homebox' => $this->entity
        ->id(),
    ], [
      'query' => [
        'block-delete' => $block_id,
      ],
    ]),
  ];
  if (!$status) {
    $operations['enable'] = [
      'title' => t('Enable'),
      'weight' => -15,
      'url' => Url::fromRoute('homebox.settings_form', [
        'homebox' => $this->entity
          ->id(),
      ], [
        'query' => [
          'block-enable' => $block_id,
        ],
      ]),
    ];
  }
  else {
    $operations['disable'] = [
      'title' => t('Disable'),
      'weight' => 40,
      'url' => Url::fromRoute('homebox.settings_form', [
        'homebox' => $this->entity
          ->id(),
      ], [
        'query' => [
          'block-disable' => $block_id,
        ],
      ]),
    ];
  }
  uasort($operations, '\\Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
  return $operations;
}