2017 © Pedro Peláez
 

symfony-bundle crud-bundle

image

fle/crud-bundle

  • Monday, November 28, 2016
  • by flecomte
  • Repository
  • 1 Watchers
  • 0 Stars
  • 327 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 37 Versions
  • 4 % Grown

The README.md

FLECrudBundle

Build Status, (*1)

Dependency Status, (*2)

Coverage Status, (*3)

SensioLabsInsight, (*4)

Overview

Installation

Add the bundle to your composer.json file:, (*5)

require: {
    "jms/di-extra-bundle": "dev-master",
    "fle/crud-bundle": "1.*@dev"
}

Then run a composer update:, (*6)

composer.phar update fle/crud-bundle

Register the bundle with your kernel in AppKernel::registerBundles():, (*7)

<?php
$bundles = array(
    // ...
    new JMS\DiExtraBundle\JMSDiExtraBundle($this),
    new JMS\AopBundle\JMSAopBundle(),
    new FLE\Bundle\CrudBundle\FLECrudBundle(),
    // ...
);

Add Configuration in app/config/config.yml:, (*8)

jms_di_extra:
    locations:
        bundles:
            - FLECrudBundle

twig:
    form_themes:
        - 'FLECrudBundle::Form/fields.html.twig'

Usage

{% extends 'FLECrudBundle::base.html.twig' %}

Filter

Custom Filter, (*9)

<?php

use FLE\Bundle\CrudBundle\Annotation as CRUD;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="AppBundle\Repository\ObjectRepository")
 * @CRUD\FormFilter(class="AppBundle\Filter\ObjectFilterType")
 */
class Object
{
    //...
}
<?php

use FLE\Bundle\CrudBundle\Filter\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Doctrine\ORM\QueryBuilder;

class ObjectFilterType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('articleType', ChoiceType::class, [
            'choices' => [
                'withArticle' => function (QueryBuilder $qb, $rootAlias) {
                    return $qb
                        ->andWhere("$rootAlias.article IS NOT NULL");
                },
                'all' => null
            ],
            'mapped' => false
        ]);
    }
}

The Versions