You are here

public function ParserOperationForm::executeOperation in Markdown 8.2

Controller for the "markdown.parser.operation" route.

Parameters

\Drupal\markdown\Plugin\Markdown\ParserInterface $parser: The parser being operated on.

string $operation: The operation to perform.

Return value

array|\Symfony\Component\HttpFoundation\Response|void A render array or response object.

1 string reference to 'ParserOperationForm::executeOperation'
markdown.routing.yml in ./markdown.routing.yml
markdown.routing.yml

File

src/Form/ParserOperationForm.php, line 202

Class

ParserOperationForm
Provides a confirmation form to disable a parser.

Namespace

Drupal\markdown\Form

Code

public function executeOperation(ParserInterface $parser, $operation) {
  $this
    ->initializeOperation($parser, $operation);

  // Retrieve the Config object for the parser.
  $configName = sprintf(isset($this->operationConfigNames[$this->operation]) ? $this->operationConfigNames[$this->operation] : 'markdown.parser.%s', $this->parser
    ->getPluginId());
  $config = $this
    ->configFactory()
    ->getEditable($configName);

  // Execute the operation, passing the config as its only parameter.
  $callable = $this->operationMethod;
  $response = $callable($config);
  $this
    ->logger('markdown')
    ->notice('Performed operation (@operation) on parser %parser (@parser_id).', [
    '@operation' => $this->operation,
    '%parser' => $this->parser
      ->getLabel(FALSE),
    '@parser_id' => $this->parser
      ->getPluginId(),
  ]);
  if ($message = $this
    ->getSuccessMessage()) {
    drupal_set_message($message);
  }

  // Allow the operation to override the response.
  if ($response) {
    return $response;
  }

  // Otherwise, redirect to the overview page.
  return $this
    ->redirect('markdown.overview');
}