Commit ca6549b0 authored by Anwoon's avatar Anwoon
Browse files

Feature #3092175 - Added entity list filter

parent 7f16afe4
Loading
Loading
Loading
Loading
+7 −47
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ The module allows you to:
* Choose the type of entity you want 
* Choose the language of the elements to be uploaded
* Choose the number of items to display per page
* Added custom filter with EntityListFilters (custom configuration, custom rendering ...)

The display of the list is divided into regions: Header - Before - Content - 
After. 
@@ -33,7 +34,7 @@ Once your list is created, all you have to do is place it either through a block
REQUIREMENTS
------------
This module requires the following modules:
 * Layout Discovery (in core Drupal 8)
 * Layout Discovery (in core Drupal 8 / 9)
    
RECOMMENDED MODULES
-------------------
@@ -54,53 +55,11 @@ enabled, the module will prevent the links from appearing. To get the links
back, disable the module and clear caches.
    admin/structure/entity_list

If you want to customize the entity list display : 
### Documentation Developer

`entity_list` define the plugin type `EntityListDisplay` to manage the list 
render.

You can extend `DefaultEntityListDisplay` or `EntityListDisplayBase` plugin to 
make your own.

Once the plugin is created, you can now choose your plugin in the display 
vertical tab in the entity list form.

Example of extending the `DefaultEntityListDisplay`:

```php
<?php

/**
 * Create Custom Entity List Display.
 *
 * @EntityListDisplay(
 *   id = "my_entity_list_display",
 *   label = @Translation("My entity list display")
 * )
 */
class MyEntityListDisplay extends DefaultEntityListDisplay {

  /**
   * {@inheritdoc}
   */
  public function render() {
    return [
      '#markup' => $this->t("This method is reponsible for creating the render array of the list."),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(FormStateInterface $form_state, EntityListInterface $entity_list) {
    $form = parent::settingsForm($form_state, $entity_list);
    // Add custom settings.
    return $form;
  }

}

```
 - [EntityListDisplay Plugin](/README_entity_list_display.md)
 - [EntityListQuery Plugin](/README_entity_list_query.md)
 - [EntityListFilter Plugin](/README_entity_list_filter.md)

MAINTAINERS
-----------
@@ -108,6 +67,7 @@ MAINTAINERS
Current maintainers:
 * Marc-Antoine Marty (Martygraphie) - https://www.drupal.org/u/martygraphie
 * Leonard Treille (leonardT) - https://www.drupal.org/u/leonardt
 * Alexis Iannone (Anwoon) - https://www.drupal.org/u/anwoon

This project has been sponsored by:
 * Ecedi
+52 −0
Original line number Diff line number Diff line
EntityListDisplay
-----------------

#### If you want to customize the EntityListDisplay :

`entity_list` define the plugin type `EntityListDisplay` to manage the list
render.

You can extend `DefaultEntityListDisplay` or `EntityListDisplayBase` plugin to
make your own.

Once the plugin is created, you can now choose your plugin in the display
vertical tab in the entity list form.

Example of extending the `DefaultEntityListDisplay`:

```php
<?php

namespace Drupal\mymodule\Plugin\EntityListDisplay;

/**
 * Create Custom Entity List Display.
 *
 * @EntityListDisplay(
 *   id = "my_entity_list_display",
 *   label = @Translation("My Entity List Display")
 * )
 */
class MyEntityListDisplay extends DefaultEntityListDisplay {

  /**
   * {@inheritdoc}
   */
  public function render() {
    return [
      '#markup' => $this->t("This method is reponsible for creating the render array of the list."),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(FormStateInterface $form_state, EntityListInterface $entity_list) {
    $form = parent::settingsForm($form_state, $entity_list);
    // Add custom settings.
    return $form;
  }

}

```
+54 −0
Original line number Diff line number Diff line
EntityListFilter
----------------

#### Create your custom EntityListFilter plugin :

`entity_list` define the plugin type `EntityListQuery` to manage multiple filters.

You can extend `EntityListFilterBase` or other default filter plugin to make your own.

Example of extending the `EntityListFilterBase`:

```php
<?php

namespace Drupal\mymodule\Plugin\EntityListFilter;

/**
 * Class MyEntityListFilter.
 *
 * @package Drupal\entity_list\Plugin
 *
 * @EntityListFilter(
 *   id = "my_entity_list_filter",
 *   label = @Translation("My Entity List Filter"),
 *   content_type = {},
 *   entity_type = {},
 * )
 */
class MyEntityListFilter extends EntityListFilterBase {

  /**
   * {@inheritdoc}
   */
  public function buildFilter(array $parameters, EntityList $entity_list) {
    return parent::buildFilter($parameters, $entity_list);
  }

  /**
   * {@inheritdoc}
   */
  public function setFields(array $settings) {
    return parent::setFields($settings);
  }

  /**
   * {@inheritdoc}
   */
  public function configurationFilter(array $default_value, EntityList $entity_list) {
    return parent::configurationFilter($default_value, $entity_list);
  }

}

```
+42 −0
Original line number Diff line number Diff line
EntityListQuery
-----------------

#### If you want to customize the EntityListQuery :

`entity_list` define the plugin type `EntityListQuery` to manage the query.

You can extend `DefaultEntityListQuery` or `EntityListQueryBase` plugin to
make your own.

Example of extending the `DefaultEntityListQuery`:


```php
<?php

namespace Drupal\mymodule\Plugin\EntityListQuery;

/**
 * Class MyEntityListQuery.
 *
 * Use a Drupal\Core\Entity\Query\QueryInterface implementation by default.
 *
 * @package Drupal\entity_list\Plugin
 *
 * @EntityListQuery(
 *   id = "my_entity_list_query",
 *   label = @Translation("My Entity List Query")
 * )
 */
class MyEnityListQuery extends DefaultEntityListQuery {

  /**
   * {@inheritdoc}
   */
  public function buildQuery() {
    parent::buildQuery();
  }

}

```
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ entity_list.entity_list.*:
    label:
      type: label
      label: 'Label'
    step:
      type: string
      label: 'Step'
    uuid:
      type: string
    query:
Loading