You are here

public function PanelsIPEPageController::getBlockContentTypes in Panels 8.3

Same name and namespace in other branches
  1. 8.4 panels_ipe/src/Controller/PanelsIPEPageController.php \Drupal\panels_ipe\Controller\PanelsIPEPageController::getBlockContentTypes()

Gets a list of Block Content Types from the server.

Parameters

string $panels_storage_type: The id of the storage plugin.

string $panels_storage_id: The id within the storage plugin for the requested Panels display.

Return value

\Symfony\Component\HttpFoundation\JsonResponse

1 string reference to 'PanelsIPEPageController::getBlockContentTypes'
panels_ipe.routing.yml in panels_ipe/panels_ipe.routing.yml
panels_ipe/panels_ipe.routing.yml

File

panels_ipe/src/Controller/PanelsIPEPageController.php, line 374

Class

PanelsIPEPageController
Contains all JSON endpoints required for Panels IPE + Page Manager.

Namespace

Drupal\panels_ipe\Controller

Code

public function getBlockContentTypes($panels_storage_type, $panels_storage_id) {

  // Assemble our relevant data.
  $types = $this
    ->entityTypeManager()
    ->getStorage('block_content_type')
    ->loadMultiple();
  $data = [];

  /** @var \Drupal\block_content\BlockContentTypeInterface $definition */
  foreach ($types as $id => $definition) {
    $data[] = [
      'id' => $definition
        ->id(),
      'revision' => $definition
        ->shouldCreateNewRevision(),
      'label' => $definition
        ->label(),
      'description' => $definition
        ->getDescription(),
    ];
  }

  // Return a structured JSON response for our Backbone App.
  return new JsonResponse($data);
}