Same name in other branches
- 7.x-3.x plugins/QuickCallbackContent.inc \QuickCallbackContent
Class for tab content of type "callback" - this is for rendering the contents of some menu callback function as tab content. @QuicktabFormat{ id = "quickcallbackcontent"
Hierarchy
- class \Drupal\quicktabs\QuickContent implements \Drupal\quicktabs\QuickContentRenderableInterface
- class \Drupal\quicktabs\Plugin\QuickContent\QuickCallbackContent extends \Drupal\quicktabs\QuickContent implements \Drupal\quicktabs\QuicktabContentInterface
Expanded class hierarchy of QuickCallbackContent
1 string reference to 'QuickCallbackContent'
- quicktabs_quicktabs_contents in ./
quicktabs.module - Implements hook_quicktabs_contents().
File
-
src/
Plugin/ QuickContent/ QuickCallbackContent.php, line 22
Namespace
Drupal\quicktabs\Plugin\QuickContentView source
class QuickCallbackContent extends QuickContent implements QuicktabContentInterface {
/**
* {@inheritdoc}
*/
public static function getType() {
return 'callback';
}
/**
* @param $item
*/
public function __construct($item) {
parent::__construct($item);
if (isset($item['path'])) {
$url_args = arg();
$path = $item['path'];
foreach ($url_args as $id => $arg) {
$path = str_replace("%{$id}", $arg, $path);
}
$path = preg_replace(',/?(%\\d),', '', $path);
if (!empty($path)) {
$this->settings['ajax_path'] = rawurlencode($path);
}
else {
$this->settings['ajax_path'] = '';
}
$this->settings['actual_path'] = $path;
}
}
/**
* {@inheritdoc}
*/
public function optionsForm($delta, $qt, $form_state) {
$tab = $this->settings;
$form = array();
$form['callback']['path'] = array(
'#type' => 'textfield',
'#default_value' => isset($tab['path']) ? $tab['path'] : '',
'#title' => t('Path'),
'#element_validate' => array(
'quicktabs_callback_element_validate',
),
);
$form['callback']['use_title'] = array(
'#type' => 'checkbox',
'#return_value' => TRUE,
'#title' => 'Use callback title',
'#default_value' => isset($tab['use_title']) ? $tab['use_title'] : FALSE,
'#description' => t('Should quicktabs use the rendered title of the callback?'),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function render($hide_empty = FALSE, $args = array()) {
if ($this->rendered_content) {
return $this->rendered_content;
}
$item = $this->settings;
if (!empty($args)) {
// The args have been passed in from an ajax request.
// The first element of the args array is the qt_name, which we don't need
// for this content type.
array_shift($args);
$item['actual_path'] = rawurldecode($args[0]);
//$_GET['q'] = $item['actual_path'];
}
$output = array();
if (isset($item['actual_path'])) {
// Retain the current page title as we'll need to set it back after
// calling menu_execute_active_handler().
$request = \Drupal::request();
$route_match = \Drupal::routeMatch();
$page_title = \Drupal::service('title_resolver')->getTitle($request, $route_match);
$request = \Drupal::service('request_stack');
$subrequest = Request::create($item['actual_path'], 'GET', $request->query
->all(), $request->cookies
->all(), array(), $request->server
->all());
$response = \Drupal::service('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST);
//$response = menu_execute_active_handler($item['actual_path'], FALSE);
// Revert the page title.
if ($this->settings['use_title']) {
$temp_request = \Drupal::request();
$temp_route_match = \Drupal::routeMatch();
$this->title = \Drupal::service('title_resolver')->getTitle($temp_request, $temp_route_match);
}
drupal_set_title($page_title);
if (!is_array($response)) {
if (is_int($response)) {
if (MENU_ACCESS_DENIED == $response && !$hide_empty) {
$output['#markup'] = theme('quicktabs_tab_access_denied', array(
'tab' => $item,
));
}
// For any other integer response form the menu callback, we'll just
// return an empty array.
}
else {
$output = array(
'#markup' => $response,
);
}
}
else {
$output = $response;
}
}
$this->rendered_content = $output;
return $output;
}
/**
* {@inheritdoc}
*/
public function getAjaxKeys() {
return array(
'ajax_path',
);
}
/**
* {@inheritdoc}
*/
public function getUniqueKeys() {
return array(
'ajax_path',
);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
QuickCallbackContent::getAjaxKeys | public | function | Returns an array of keys to use for constructing the correct arguments for an ajax callback to retrieve content of this type. The order of the keys returned affects the order of the args passed in to the render method when called via ajax (see theā¦ |
Overrides QuickContentRenderableInterface::getAjaxKeys |
QuickCallbackContent::getType | public static | function | Returns the short type name of the content plugin, e.g. 'block', 'node', 'prerendered'. |
Overrides QuickContentRenderableInterface::getType |
QuickCallbackContent::getUniqueKeys | public | function | Returns an array of keys, sufficient to represent the content uniquely. | Overrides QuickContentRenderableInterface::getUniqueKeys |
QuickCallbackContent::optionsForm | public | function | Method for returning the form elements to display for this tab type on the admin form. |
Overrides QuickContent::optionsForm |
QuickCallbackContent::render | public | function | Renders the content. | Overrides QuickContentRenderableInterface::render |
QuickCallbackContent::__construct | public | function | Overrides QuickContent::__construct | |
QuickContent::$rendered_content | protected | property | A render array of the contents. | |
QuickContent::$settings | protected | property | An array containing the information that defines the tab content, specific to its type. |
|
QuickContent::$title | protected | property | Used as the title of the tab. | |
QuickContent::factory | public static | function | Instantiate a content type object. | |
QuickContent::getSettings | public | function | Accessor for the tab settings. | Overrides QuickContentRenderableInterface::getSettings |
QuickContent::getTitle | public | function | Accessor for the tab title. | Overrides QuickContentRenderableInterface::getTitle |