diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php index 5912c76..14cadfd 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php @@ -279,11 +279,6 @@ protected function caseTransform($string, $option) { } /** - * Validate the options form. - */ - public function validateOptionsForm(&$form, &$form_state) { } - - /** * Build the options form. */ public function buildOptionsForm(&$form, &$form_state) { @@ -328,12 +323,6 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Perform any necessary changes to the form values prior to storage. - * There is no need for this function to actually store the data. - */ - public function submitOptionsForm(&$form, &$form_state) { } - - /** * Provides the handler some groupby. */ public function usesGroupBy() { @@ -498,7 +487,14 @@ public function access() { * This gives all the handlers some time to set up before any handler has * been fully run. */ - public function preQuery() { } + public function preQuery() { + } + + /** + * Don't run a query by default. + */ + public function query() { + } /** * Run after the view is executed, before the result is cached. @@ -561,7 +557,7 @@ public function ensureMyTable() { } /** - * Provide text for the administrative summary + * Provide text for the administrative summary. */ public function adminSummary() { } @@ -634,10 +630,12 @@ public function getJoin() { public function validate() { return array(); } /** - * Determine if the handler is considered 'broken', meaning it's a + * Determines if the handler is considered 'broken', meaning it's a * a placeholder used when a handler can't be found. */ - public function broken() { } + public function broken() { + return FALSE; + } /** * Creates cross-database SQL date formatting. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php index 056aeef..329d44f 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php @@ -9,7 +9,6 @@ use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; -use Drupal\views\Plugin\views\PluginBase; use Drupal\views\Plugin\views\HandlerBase; /** @@ -47,6 +46,16 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o } } + /** + * {@inheritdoc} + */ + public function usesGroupBy() { + return FALSE; + } + + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -59,15 +68,14 @@ protected function defineOptions() { } /** - * Provide extra data to the administration form + * {@inheritdoc} */ public function adminSummary() { return $this->adminLabel(); } /** - * Default options form that provides the label widget that all fields - * should have. + * {@inheritdoc} */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); @@ -82,11 +90,6 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Don't run a query - */ - public function query() { } - - /** * Performs any operations needed before full rendering. * * @param array $results @@ -106,13 +109,6 @@ public function preRender(array $results) { */ public abstract function render($empty = FALSE); - /** - * Area handlers shouldn't have groupby. - */ - public function usesGroupBy() { - return FALSE; - } - } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php index 08d3069..dff668b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php @@ -7,9 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use Drupal\Component\Annotation\PluginID; -use Drupal\views\ViewExecutable; - /** * A special handler to take the place of missing or broken handlers. * @@ -19,6 +16,9 @@ */ class Broken extends AreaPluginBase { + /** + * {@inheritdoc} + */ public function adminLabel($short = FALSE) { $args = array( '@module' => $this->definition['original_configuration']['provider'], @@ -26,11 +26,22 @@ public function adminLabel($short = FALSE) { return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); } - public function defineOptions() { return array(); } - public function ensureMyTable() { /* No table to ensure! */ } - public function query($group_by = FALSE) { /* No query to run */ } /** - * Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} + */ + public function defineOptions() { + return array(); + } + + /** + * {@inheritdoc} + */ + public function ensureMyTable() { + // No table to ensure. + } + + /** + * {@inheritdoc} */ public function render($empty = FALSE) { // Simply render nothing by returning an empty render array. @@ -75,7 +86,7 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ public function broken() { return TRUE; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php index 2684476..3d416d1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php @@ -9,7 +9,6 @@ use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; -use Drupal\Component\Annotation\PluginID; /** * Provides an area handler which renders an entity in a certain view mode. @@ -89,7 +88,7 @@ protected function buildViewModeOptions() { } /** - * Overrides \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} */ public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php index d448876..f79b2fc 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/HTTPStatusCode.php @@ -8,7 +8,6 @@ namespace Drupal\views\Plugin\views\area; use Symfony\Component\HttpFoundation\Response; -use Drupal\Component\Annotation\PluginID; /** * Alter the HTTP response status code used by the view. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php index f1276ca..b6a63ba 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Result.php @@ -7,7 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use Drupal\Component\Annotation\PluginID; use Drupal\Component\Utility\String; use Drupal\Component\Utility\Xss; use Drupal\views\Plugin\views\style\DefaultSummary; @@ -21,6 +20,9 @@ */ class Result extends AreaPluginBase { + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -32,6 +34,9 @@ protected function defineOptions() { return $options; } + /** + * {@inheritdoc} + */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); $item_list = array( @@ -67,7 +72,7 @@ public function query() { } /** - * Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} */ public function render($empty = FALSE) { // Must have options and does not work on summaries. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Text.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Text.php index a9dd6c5..7206e5b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Text.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Text.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use Drupal\Component\Annotation\PluginID; - /** * Views area text handler. * @@ -19,7 +17,7 @@ class Text extends TokenizeAreaPluginBase { /** - * Overrides \Drupal\views\Plugin\views\area\TokenizeAreaPluginBase::defineOptions(). + * {@inheritdoc} */ protected function defineOptions() { $options = parent::defineOptions(); @@ -29,7 +27,7 @@ protected function defineOptions() { } /** - * Overrides \Drupal\views\Plugin\views\area\TokenizeAreaPluginBase::buildOptionsForm(). + * {@inheritdoc} */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); @@ -44,6 +42,9 @@ public function buildOptionsForm(&$form, &$form_state) { ); } + /** + * {@inheritdoc} + */ public function submitOptionsForm(&$form, &$form_state) { $form_state['values']['options']['format'] = $form_state['values']['options']['content']['format']; $form_state['values']['options']['content'] = $form_state['values']['options']['content']['value']; @@ -51,7 +52,7 @@ public function submitOptionsForm(&$form, &$form_state) { } /** - * Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} */ public function render($empty = FALSE) { $format = isset($this->options['format']) ? $this->options['format'] : filter_default_format(); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/TextCustom.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/TextCustom.php index dac9815..4494caa 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/TextCustom.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/TextCustom.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use Drupal\Component\Annotation\PluginID; - /** * Views area text handler. * @@ -42,7 +40,7 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} */ public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php index 7ee0197..66f3495 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use Drupal\Component\Annotation\PluginID; - /** * Views area title override handler. * @@ -19,7 +17,7 @@ class Title extends AreaPluginBase { /** - * Overrides Drupal\views\Plugin\views\AreaPluginBase::defineOptions(). + * {@inheritdoc} */ protected function defineOptions() { $options = parent::defineOptions(); @@ -28,7 +26,7 @@ protected function defineOptions() { } /** - * Overrides Drupal\views\Plugin\views\AreaPluginBase::buildOptionsForm(). + * {@inheritdoc} */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); @@ -45,7 +43,7 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Overrides Drupal\views\Plugin\views\AreaPluginBase::preRender(). + * {@inheritdoc} */ public function preRender(array $results) { parent::preRender($results); @@ -58,7 +56,7 @@ public function preRender(array $results) { } /** - * Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} */ public function render($empty = FALSE) { // Do nothing for this handler by returning an empty render array. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php index 103df0a..3f2b17b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php @@ -2,12 +2,13 @@ /** * @file - * Definition of Drupal\views\Plugin\views\area\View. + * Contains \Drupal\views\Plugin\views\area\View. */ namespace Drupal\views\Plugin\views\area; -use Drupal\Component\Annotation\PluginID; +use Drupal\Core\Entity\EntityStorageControllerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Views area handlers. Insert a view inside of an area. @@ -18,6 +19,46 @@ */ class View extends AreaPluginBase { + /** + * The view storage controller. + * + * @var \Drupal\Core\Entity\EntityStorageControllerInterface + */ + protected $viewStorage; + + /** + * Constructs a View object. + * + * @param array $configuration + * An array of configuration data. + * @param string $plugin_id + * The plugin ID. + * @param array $plugin_definition + * The plugin definition. + * @param \Drupal\Core\Entity\EntityStorageControllerInterface $view_storage + * The view storage controller. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageControllerInterface $view_storage) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->viewStorage = $view_storage; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity.manager')->getStorageController('view') + ); + } + + /** + * {@inheritdoc} + */ protected function defineOptions() { $options = parent::defineOptions(); @@ -27,8 +68,7 @@ protected function defineOptions() { } /** - * Default options form that provides the label widget that all fields - * should have. + * {@inheritdoc} */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); @@ -54,13 +94,14 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Implements \Drupal\views\Plugin\views\area\AreaPluginBase::render(). + * {@inheritdoc} */ public function render($empty = FALSE) { if (!empty($this->options['view_to_insert'])) { list($view_name, $display_id) = explode(':', $this->options['view_to_insert']); - $view = views_get_view($view_name); + $view = $this->viewStorage->load($view_name); + if (empty($view) || !$view->access($display_id)) { return array(); }