2017 © Pedro PelĂĄez
 

symfony-bundle components-bundle

Common components to all LCH bundles

image

lch/components-bundle

Common components to all LCH bundles

  • Tuesday, January 9, 2018
  • by lch
  • Repository
  • 3 Watchers
  • 0 Stars
  • 43 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 4 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

Components Bundle

This Symfony bundle provides all necessary bricks needed accross other LCH bundles., (*1)

Installation

composer require lch/components-bundle "^1.2.7", (*2)

Traits

UUID

Using the Uuidable will add to your entity a Ramsey UUID identity field. Note: This does not handle the configuration steps for you., (*3)

Repository traits

In order to gather some behavior une one places, we introduce following repository traits., (*4)

PaginableEntityRepository

This provides one public method to retrieve a Doctrine Paginator object. Below is the signature, (*5)

    /**
     * @param QueryBuilder $qb the QueryBuilder object containing the query description
     * @param int $page the page wanted (set to 1 by default)
     * @param int|null $maxResults the batch size, if any
     *
     * @return Paginator
     */
    public function getPaginator(QueryBuilder $qb, int $page = 1, int $maxResults = null)

Everything is straightforward here., (*6)

CountableEntityRepository

This provides a simple method to easily get total query items count., (*7)

SearchableEntityRepository

Full text search method

This is useful for example in AJAX actions (in a not-API context) where you need to retrieve a list of entity in large term context : classical AJAX search., (*8)

/**
     * Used to search in like mode in entity fields
     * @param array $fields the fields names wanted to be searched in
     * @param string $term the term to be searched
     * @param int|null $maxResults the batch size, if any.
     * @param string|null $language if any, ISO code language to filter items on
     *
     * @return array
     */
    public function findByFulltextTerm(
        array $fields,
        string $term,
        int $maxResults = null,
        string $language = null
    ): array

Twig

Macros

Simple admin pagination

If using PaginableEntityRepository above, you can then pass pagination object, (*9)

public function list(int $page): Response
    {
        // get items before with a repository method returning paginator

        return $this->render('admin/menu/list.html.twig', [
            'menus' => $menus,
            'pagination' => [
                'page' => $page,
                'nbPages' => ceil($menus->count() / $nbItemsPerPage)
            ]
        ]);
    }

Then in twig you can generate simple pagination component:, (*10)

{% import "@LchComponents/macros/lch-components-utils.html.twig" as lch_utils %}

...

{{ lch_utils.admin_paginate(pagination.page, pagination.nbPages) }}

The Versions

09/01 2018

dev-master

9999999-dev https://github.com/compagnie-hyperactive/ComponentsBundle

Common components to all LCH bundles

  Sources   Download

MIT

The Requires

 

The Development Requires

pagination list datagrid components

05/01 2018

dev-2.0-ALPHA1

dev-2.0-ALPHA1 https://github.com/compagnie-hyperactive/ComponentsBundle

Common components to all LCH bundles

  Sources   Download

MIT

The Requires

 

The Development Requires

by Matthieu LĂ©orat

pagination list datagrid components

21/11 2017

1.0

1.0.0.0 https://github.com/compagnie-hyperactive/ComponentsBundle

Common components to all LCH bundles

  Sources   Download

MIT

The Requires

 

The Development Requires

pagination list datagrid components

05/06 2017

0.5.6

0.5.6.0 https://github.com/compagnie-hyperactive/ComponentsBundle

Common components to all LCH bundles

  Sources   Download

MIT

The Requires

 

The Development Requires

pagination list datagrid components

24/05 2017

dev-develop

dev-develop https://github.com/compagnie-hyperactive/ComponentsBundle

Common components to all LCH bundles

  Sources   Download

MIT

The Requires

 

The Development Requires

pagination list datagrid components

24/05 2017

0.5.5

0.5.5.0 https://github.com/compagnie-hyperactive/ComponentsBundle

Common components to all LCH bundles

  Sources   Download

MIT

The Requires

 

The Development Requires

pagination list datagrid components