<?php

namespace Drupal\restaurant_bookings\Theme;

use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\node\NodeInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;

/**
 * Provides a ThemeNegotiator for content type gist.
 */
class ThemeNegotiator implements ThemeNegotiatorInterface {

  /**
   * AdminContext service.
   *
   * @var \Drupal\Core\Routing\AdminContext
   */
  protected $adminContext;

  /**
   * Creates a new ThemeNegotiator instance.
   *
   * @param \Drupal\Core\Routing\AdminContext $admin_context
   *   AdminContext service.
   */
  public function __construct(AdminContext $admin_context) {
    $this->adminContext = $admin_context;
  }

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {

  	 $route = explode('.', $route_match->getRouteName());
  	 
  	 if (($route[0] == 'restaurant_bookings') && ($route[1] == 'ajax')) {
  	 	return true;
  	 }
  	  if (($route[0] == 'restaurant_bookings') && ($route[1] == 'iframe')) {
  	 	return true;
  	 }
  	 return false;
  }

  /**
   * {@inheritdoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match)
  {
    $route = explode('.', $route_match->getRouteName());

    switch ($route[1]) {
      case 'ajax':
        return 'ajax';
      case 'iframe':
        return 'iframe';
    }
  }

}
