You are here

public function ImageBrowserController::page in Image Entity Browser 8

1 string reference to 'ImageBrowserController::page'
image_browser.routing.yml in ./image_browser.routing.yml
image_browser.routing.yml

File

src/Controller/ImageBrowserController.php, line 14

Class

ImageBrowserController

Namespace

Drupal\image_browser\Controller

Code

public function page() {

  //We only accept ajax request for that page
  if (false == \Drupal::request()
    ->isXmlHttpRequest()) {
    throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
  }
  $html_id = Html::getUniqueId('dexp-image-browser');
  return [
    [
      '#theme' => 'links',
      '#attributes' => [
        'class' => [
          'dexp-image-browser-tabs',
        ],
      ],
      '#links' => [
        'upload_link' => [
          'title' => $this
            ->t('Upload'),
          'url' => \Drupal\Core\Url::fromRoute('image_browser.upload'),
          'ajax' => [
            'wrapper' => $html_id,
            'method' => 'html',
          ],
        ],
        'library_browser' => [
          'title' => $this
            ->t('Library'),
          'url' => \Drupal\Core\Url::fromRoute('image_browser.library'),
          'ajax' => [
            'wrapper' => $html_id,
            'method' => 'html',
          ],
        ],
      ],
    ],
    [
      '#markup' => '<div id="' . $html_id . '"></div>',
    ],
  ];
}