Skip to content
Snippets Groups Projects
Verified Commit 0eca710d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3421004 by Ruturaj Chaubey, sorlov, quietone, smustgrave, larowlan,...

Issue #3421004 by Ruturaj Chaubey, sorlov, quietone, smustgrave, larowlan, alexpott: Convert ViewsPager plugin discovery to attributes
parent 64de6a69
No related branches found
No related tags found
32 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3478Issue #3337882: Deleted menus are not removed from content type config,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!213Issue #2906496: Give Media a menu item under Content
Pipeline #132403 canceled
Pipeline: drupal

#132408

    <?php
    namespace Drupal\views\Attribute;
    use Drupal\Component\Plugin\Attribute\Plugin;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    /**
    * Defines a views pager plugins type attribute for plugin discovery.
    *
    * @see \Drupal\views\Plugin\views\pager\PagerPluginBase
    *
    * @ingroup views_pager_plugins
    */
    #[\Attribute(\Attribute::TARGET_CLASS)]
    class ViewsPager extends Plugin {
    /**
    * Constructs a ViewsPager attribute.
    *
    * @param string $id
    * The plugin ID.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup $title
    * The plugin title used in the views UI.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $short_title
    * (optional) The short title used in the views UI.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $help
    * (optional) A short help string; this is displayed in the views UI.
    * @param string|null $theme
    * (optional) The theme function used to render the pager's output.
    * @param string[]|null $display_types
    * (optional) The types of the display this plugin can be used with.
    * For example the Feed display defines the type 'feed', so only rss style
    * and row plugins can be used in the views UI.
    * @param string[] $base
    * (optional) The base tables on which this access plugin can be used.
    * If no base table is specified the plugin can be used with all tables.
    * @param bool $no_ui
    * (optional) Whether the plugin should be not selectable in the UI.
    * If set to TRUE, you can still use it via the API in config files.
    * Defaults to FALSE.
    * @param bool $register_theme
    * (optional) Whether or not to register a theme function automatically.
    * @param class-string|null $deriver
    * (optional) The deriver class.
    */
    public function __construct(
    public readonly string $id,
    public readonly TranslatableMarkup $title,
    public readonly ?TranslatableMarkup $short_title = NULL,
    public readonly ?TranslatableMarkup $help = NULL,
    public readonly ?string $theme = NULL,
    public readonly ?array $display_types = NULL,
    public readonly array $base = [],
    public readonly bool $no_ui = FALSE,
    public readonly bool $register_theme = TRUE,
    public readonly ?string $deriver = NULL
    ) {}
    }
    ......@@ -3,21 +3,22 @@
    namespace Drupal\views\Plugin\views\pager;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\views\Attribute\ViewsPager;
    /**
    * The plugin to handle full pager.
    *
    * @ingroup views_pager_plugins
    *
    * @ViewsPager(
    * id = "full",
    * title = @Translation("Paged output, full pager"),
    * short_title = @Translation("Full"),
    * help = @Translation("Paged output, full Drupal style"),
    * theme = "pager",
    * register_theme = FALSE
    * )
    */
    #[ViewsPager(
    id: "full",
    title: new TranslatableMarkup("Paged output, full pager"),
    short_title: new TranslatableMarkup("Full"),
    help: new TranslatableMarkup("Paged output, full Drupal style"),
    theme: "pager",
    register_theme: FALSE
    )]
    class Full extends SqlBase {
    /**
    ......
    ......@@ -2,19 +2,21 @@
    namespace Drupal\views\Plugin\views\pager;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\views\Attribute\ViewsPager;
    /**
    * The plugin to handle mini pager.
    *
    * @ingroup views_pager_plugins
    *
    * @ViewsPager(
    * id = "mini",
    * title = @Translation("Paged output, mini pager"),
    * short_title = @Translation("Mini"),
    * help = @Translation("A simple pager containing previous and next links."),
    * theme = "views_mini_pager"
    * )
    */
    #[ViewsPager(
    id: "mini",
    title: new TranslatableMarkup("Paged output, mini pager"),
    short_title: new TranslatableMarkup("Mini"),
    help: new TranslatableMarkup("A simple pager containing previous and next links."),
    theme: "views_mini_pager",
    )]
    class Mini extends SqlBase {
    /**
    ......@@ -47,7 +49,7 @@ public function summaryTitle() {
    public function query() {
    parent::query();
    // Only modify the query if we don't want to do a total row count
    // Only modify the query if we don't want to do a total row count.
    if (!$this->view->get_total_rows) {
    // Don't query for the next page if we have a pager that has a limited
    // amount of pages.
    ......@@ -72,7 +74,7 @@ public function useCountQuery() {
    * {@inheritdoc}
    */
    public function postExecute(&$result) {
    // Only modify the result if we didn't do a total row count
    // Only modify the result if we didn't do a total row count.
    if (!$this->view->get_total_rows) {
    $this->total_items = $this->getCurrentPage() * $this->getItemsPerPage() + count($result);
    // query() checks if we need a next link by setting limit 1 record past
    ......
    ......@@ -3,6 +3,8 @@
    namespace Drupal\views\Plugin\views\pager;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\views\Attribute\ViewsPager;
    use Drupal\views\ViewExecutable;
    use Drupal\views\Plugin\views\display\DisplayPluginBase;
    ......@@ -10,14 +12,13 @@
    * Plugin for views without pagers.
    *
    * @ingroup views_pager_plugins
    *
    * @ViewsPager(
    * id = "none",
    * title = @Translation("Display all items"),
    * help = @Translation("Display all items that this view might find."),
    * display_types = {"basic"}
    * )
    */
    #[ViewsPager(
    id: "none",
    title: new TranslatableMarkup("Display all items"),
    help: new TranslatableMarkup("Display all items that this view might find."),
    display_types: ["basic"],
    )]
    class None extends PagerPluginBase {
    /**
    ......
    ......@@ -15,7 +15,7 @@
    * and setting up the pager.
    *
    * Pager plugins extend \Drupal\views\Plugin\views\pager\PagerPluginBase. They
    * must be annotated with \Drupal\views\Annotation\ViewsPager annotation,
    * must be attributed with \Drupal\views\Annotation\ViewsPager attribute,
    * and they must be in namespace directory Plugin\views\pager.
    *
    * @ingroup views_plugins
    ......
    ......@@ -3,19 +3,20 @@
    namespace Drupal\views\Plugin\views\pager;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    use Drupal\views\Attribute\ViewsPager;
    /**
    * Plugin for views without pagers.
    *
    * @ingroup views_pager_plugins
    *
    * @ViewsPager(
    * id = "some",
    * title = @Translation("Display a specified number of items"),
    * help = @Translation("Display a limited number items that this view might find."),
    * display_types = {"basic"}
    * )
    */
    #[ViewsPager(
    id: "some",
    title: new TranslatableMarkup("Display a specified number of items"),
    help: new TranslatableMarkup("Display a limited number items that this view might find."),
    display_types: ["basic"],
    )]
    class Some extends PagerPluginBase {
    public function summaryTitle() {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment