PHP code example of creativestyle / admin-list-bundle

1. Go to this page and download the library: Download creativestyle/admin-list-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

creativestyle / admin-list-bundle example snippets


/** @var FilterManager $filters */
$filters = $this->get('creativestyle_admin_list.filter_manager');

$filters
    ->registerFilter(new SomeFilter('filterid', ['some_config' => 'value']);
    ->registerFilter(new SomeFilter('otherfilterid', ['some_config' => 'value'])
;

$filters
    ->setPaginator(new SimplePaginator([
        'order_by' => 'location.address.name',
    ]))
;

$qb = $repository->createQueryBuilder('product');
$filters->applyFilters($qb);

$results = $this->getFilterManager()->getPaginatedResults($queryBuilder);

return $this->render('template.html.twig', [
    'results' => $results,
    'filters' => $filters,
]);

new ChoiceFilter('id', [
    'choices' => [
        'black' => 'Dark',
        'white' => 'Light',
    ],
    'callback' => function (QueryBuilder $qb, $value) {
        if ($value) {
            $qb->andWhere('product.color = :choice')
               ->setParameter('choice', $value);
        }
    }
]);