Commit e77c8f48 authored by damiankloip's avatar damiankloip Committed by tim.plunkett
Browse files

Issue #1757464 by damiankloip | dawehner: Move accept_attachments from annotations.

parent 1d13655b
......@@ -24,8 +24,7 @@
* title = @Translation("Attachment"),
* help = @Translation("Attachments added to other displays to achieve multiple views in the same view."),
* theme = "views_view",
* contextual_links_locations = {""},
* accept_attachments = FALSE
* contextual_links_locations = {""}
* )
*/
class Attachment extends DisplayPluginBase {
......@@ -195,7 +194,7 @@ function options_form(&$form, &$form_state) {
$form['#title'] .= t('Attach to');
$displays = array();
foreach ($this->view->display as $display_id => $display) {
if (!empty($display->handler) && $display->handler->accept_attachments()) {
if (!empty($display->handler) && $display->handler->acceptAttachments()) {
$displays[$display_id] = $display->display_title;
}
}
......
......@@ -22,12 +22,18 @@
* theme = "views_view",
* uses_hook_block = TRUE,
* contextual_links_locations = {"block"},
* accept_attachments = TRUE,
* admin = @Translation("Block")
* )
*/
class Block extends DisplayPluginBase {
/**
* Whether the display allows attachments.
*
* @var bool
*/
protected $usesAttachments = TRUE;
function option_definition() {
$options = parent::option_definition();
......
......@@ -20,12 +20,18 @@
* title = @Translation("Master"),
* help = @Translation("Default settings for this view."),
* theme = "views_view",
* no_ui = TRUE,
* accept_attachments = TRUE
* no_ui = TRUE
* )
*/
class DefaultDisplay extends DisplayPluginBase {
/**
* Whether the display allows attachments.
*
* @var bool
*/
protected $usesAttachments = TRUE;
/**
* Determine if this display is the 'default' display which contains
* fallback settings
......
......@@ -78,6 +78,14 @@ abstract class DisplayPluginBase extends PluginBase {
*/
protected $usesMore = TRUE;
/**
* Whether the display allows attachments.
*
* @var bool
* TRUE if the display can use attachments, or FALSE otherwise.
*/
protected $usesAttachments = FALSE;
function init(&$view, &$display, $options = NULL) {
$this->view = &$view;
$this->display = &$display;
......@@ -306,10 +314,12 @@ function use_more_text() {
}
/**
* Can this display accept_attachments?
* Determines whether this display can use attachments.
*
* @return bool
*/
function accept_attachments() {
if (empty($this->definition['accept_attachments'])) {
function acceptAttachments() {
if (!$this->usesAttachments()) {
return FALSE;
}
if (!empty($this->view->argument) && $this->get_option('hide_attachment_summary')) {
......@@ -322,6 +332,15 @@ function accept_attachments() {
return TRUE;
}
/**
* Returns whether the display can use attachments.
*
* @return bool
*/
function usesAttachments() {
return $this->usesAttachments;
}
/**
* Allow displays to attach to other views.
*/
......@@ -1144,7 +1163,7 @@ function options_summary(&$categories, &$options) {
'desc' => t('Change whether or not this display will use AJAX.'),
);
}
if (!empty($this->definition['accept_attachments'])) {
if ($this->usesAttachments()) {
$options['hide_attachment_summary'] = array(
'category' => 'other',
'title' => t('Hide attachments in summary'),
......
......@@ -23,8 +23,7 @@
* title = @Translation("Embed"),
* help = @Translation("Provide a display which can be embedded using the views api."),
* theme = "views_view",
* uses_hook_menu = FALSE,
* accept_attachments = FALSE
* uses_hook_menu = FALSE
* )
*/
class Embed extends DisplayPluginBase {
......
......@@ -23,7 +23,6 @@
* title = @Translation("Feed"),
* help = @Translation("Display the view as a feed, such as an RSS feed."),
* uses_hook_menu = TRUE,
* accept_attachments = FALSE,
* admin = @Translation("Feed")
* )
*/
......@@ -197,7 +196,7 @@ function options_form(&$form, &$form_state) {
$form['#title'] .= t('Attach to');
$displays = array();
foreach ($this->view->display as $display_id => $display) {
if (!empty($display->handler) && $display->handler->accept_attachments()) {
if (!empty($display->handler) && $display->handler->acceptAttachments()) {
$displays[$display_id] = $display->display_title;
}
}
......
......@@ -22,12 +22,18 @@
* uses_hook_menu = TRUE,
* contextual_links_locations = {"page"},
* theme = "views_view",
* accept_attachments = TRUE,
* admin = @Translation("Page")
* )
*/
class Page extends DisplayPluginBase {
/**
* Whether the display allows attachments.
*
* @var bool
*/
protected $usesAttachments = TRUE;
/**
* The page display has a path.
*/
......
......@@ -1449,7 +1449,7 @@ function attach_displays() {
return;
}
if (!$this->display_handler->accept_attachments()) {
if (!$this->display_handler->acceptAttachments()) {
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment