You are here

class EntityPagerFactory in Entity Pager 8

Same name and namespace in other branches
  1. 2.0.x src/EntityPagerFactory.php \Drupal\entity_pager\EntityPagerFactory

Factory for entity pager objects.

Hierarchy

Expanded class hierarchy of EntityPagerFactory

1 string reference to 'EntityPagerFactory'
entity_pager.services.yml in ./entity_pager.services.yml
entity_pager.services.yml
1 service uses EntityPagerFactory
entity_pager.factory in ./entity_pager.services.yml
Drupal\entity_pager\EntityPagerFactory

File

src/EntityPagerFactory.php, line 11

Namespace

Drupal\entity_pager
View source
class EntityPagerFactory {

  /**
   * The token service.
   *
   * @var \Drupal\Core\Utility\Token
   */
  protected $token;

  /**
   * Default options.
   *
   * @var array
   */

  // phpcs:ignore -- Cannot change member name as this would be an API change.
  protected $default_options = [
    'link_next' => 'next >',
    'link_prev' => '< prev',
    'link_all_url' => '<front>',
    'link_all_text' => 'Home',
    'display_all' => TRUE,
    'display_count' => TRUE,
    'show_disabled_links' => TRUE,
    'circular_paging' => FALSE,
    'log_performance' => TRUE,
  ];

  /**
   * EntityPagerFactory constructor.
   *
   * @param \Drupal\Core\Utility\Token $token
   *   The token service.
   */
  public function __construct(Token $token) {
    $this->token = $token;
  }

  /**
   * Returns a newly constructed entity pager.
   *
   * @param \Drupal\views\ViewExecutable $view
   *   The executable to construct an entity pager for.
   * @param array $options
   *   (optional) Options for the entity pager.
   *
   * @return \Drupal\entity_pager\EntityPagerInterface
   *   The entity pager object.
   */
  public function get(ViewExecutable $view, array $options = []) {
    $options = empty($options) ? $this->default_options : array_merge($this->default_options, $options);
    return new EntityPager($view, $options, $this->token);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityPagerFactory::$default_options protected property
EntityPagerFactory::$token protected property The token service.
EntityPagerFactory::get public function Returns a newly constructed entity pager.
EntityPagerFactory::__construct public function EntityPagerFactory constructor.