Same name in other branches
  1. 4.x src/Controller/QuickTabsController.php \Drupal\quicktabs\Controller\QuickTabsController
  2. 8.x-1.x src/Controller/QuickTabsController.php \Drupal\quicktabs\Controller\QuickTabsController

Provides a controller for content retrieved through AJAX.

Hierarchy

  • class \Drupal\quicktabs\Controller\QuickTabsController extends \Drupal\Core\Controller\ControllerBase

Expanded class hierarchy of QuickTabsController

File

src/Controller/QuickTabsController.php, line 15

Namespace

Drupal\quicktabs\Controller
View source
class QuickTabsController extends ControllerBase {
    
    /**
     * The tab type manager.
     *
     * @var \Drupal\quicktabs\TabTypeManager
     */
    protected $tabTypeManager;
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * Creates a BlockComponentRenderArray object.
     *
     * @param \Drupal\quicktabs\TabTypeManager $tab_type
     *   The tab type manager.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     */
    public function __construct(TabTypeManager $tab_type, EntityTypeManagerInterface $entity_type_manager) {
        $this->tabTypeManager = $tab_type;
        $this->entityTypeManager = $entity_type_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container) {
        return new static($container->get('plugin.manager.tab_type'), $container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function ajaxContent($js, $instance, $tab) {
        if ($js === 'nojs') {
            return [];
        }
        else {
            $qt = $this->entityTypeManager
                ->getStorage('quicktabs_instance')
                ->load($instance);
            $configuration_data = $qt->getConfigurationData();
            $object = $this->tabTypeManager
                ->createInstance($configuration_data[$tab]['type']);
            $render = $object->render($configuration_data[$tab]);
            $element_id = '#quicktabs-tabpage-' . $instance . '-' . $tab;
            $ajax_response = new AjaxResponse();
            $ajax_response->addCommand(new HtmlCommand($element_id, $render));
            return $ajax_response;
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
QuickTabsController::$entityTypeManager protected property The entity type manager.
QuickTabsController::$tabTypeManager protected property The tab type manager.
QuickTabsController::ajaxContent public function
QuickTabsController::create public static function
QuickTabsController::__construct public function Creates a BlockComponentRenderArray object.