Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Girard committed Aug 13, 2015
1 parent bc38ae9 commit 7f14f83
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Event/ApplyFilterConditionEvent.php
Expand Up @@ -6,7 +6,7 @@
use Symfony\Component\EventDispatcher\Event;

/**
* Event class used XxxApplyFilterListener classe to compute the WHERE clause from the conditions.
* Event class to compute the WHERE clause from the conditions.
*
* @author Cédric Girard <c.girard@lexik.fr>
*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@ Overview
========

This Symfony2 bundle aims to provide classes to build some form types dedicated to filter an entity.
One you created your form type you will be able to update a doctrine query builder conditions from a form type.
Once you created your form type you will be able to update a doctrine query builder conditions from a form type.

[![Build Status](https://travis-ci.org/lexik/LexikFormFilterBundle.png?branch=master)](https://travis-ci.org/lexik/LexikFormFilterBundle)
![Project Status](http://stillmaintained.com/lexik/LexikFormFilterBundle.png)
Expand Down
20 changes: 17 additions & 3 deletions Resources/doc/configuration.md
Expand Up @@ -10,14 +10,27 @@ You only need to add the following lines in your `app/config/config.yml`. This f
```yaml
# app/config/config.yml
twig:
form:
resources:
- LexikFormFilterBundle:Form:form_div_layout.html.twig
form_themes:
- LexikFormFilterBundle:Form:form_div_layout.html.twig
```

Bundle's options
----------------

* Enable listeners you need:

The bundle provides some listener to apply conditions on Doctrine ORM, DBAL and MongoDB query builders.
By default only Doctrine ORM listeners are enabled.

```yaml
# app/config/config.yml
lexik_form_filter:
listeners:
doctrine_orm: true
doctrine_dbal: false
doctrine_mongodb: false
```

* Case insensitivity:

If your RDBMS is Postgres, case insensitivity will be forced for LIKE comparisons.
Expand All @@ -34,6 +47,7 @@ anyway, set it to `true`.

* Query builder method:

**For Doctrine ORM and DBAL only.**
This option will define which method to use on the (doctrine) query builder to add the **entire** condition computed from the form type (this option is not about the operator between each filter condition).
By default this option is set to `and`, so the bundle will call the `andWhere()` method to set the entire condition on the doctrine query builder.
If you set it to `null` or `or`, the bundle will use the `where()` or `orWhere()` method to set the entire condition.
Expand Down
8 changes: 8 additions & 0 deletions Resources/doc/installation.md
Expand Up @@ -12,6 +12,14 @@ require: {
}
```

Or install directly through composer with:

```
composer.phar require lexik/translation-bundle ~4.0
# For latest version
composer.phar require lexik/translation-bundle dev-master
```

Then run a composer update:

```shell
Expand Down
12 changes: 7 additions & 5 deletions Resources/doc/provided-types.md
Expand Up @@ -29,7 +29,7 @@ Parent type: _date_
---
**filter_date_range:**

This type is composed of two filter_date types (left_date and right_date).
This type is composed of two `filter_date` types (left_date and right_date).

Parent type: _form_

Expand All @@ -46,7 +46,7 @@ Parent type: _datetime_
---
**filter_datetime_range:**

This type is composed of two filter_datetime types (left_datetime and right_datetime).
This type is composed of two `filter_datetime` types (left_datetime and right_datetime).

Parent type: _form_

Expand All @@ -69,13 +69,14 @@ Parent type: _number_

Options:

* `condition_operator`: this option allows you to configure the operator you want to use, the default operator is FilterOperands::OPERATOR_EQUAL. See the FilterOperands::OPERATOR_xxx constants for all available operators.
* `condition_operator`: this option allows you to configure the operator you want to use, the default operator is FilterOperands::OPERATOR_EQUAL.
See the FilterOperands::OPERATOR_xxx constants for all available operators (greater than, lower than, ...).
You can also use FilterOperands::OPERAND_SELECTOR, this will display a combo box with the available operators in addition to the input text.

---
**filter_number_range:**

This type is composed of two filter_number types (left_number and right_number).
This type is composed of two `filter_number` types (left_number and right_number).

Parent type: _form_

Expand All @@ -91,7 +92,8 @@ Parent type: _text_

Options:

* `condition_pattern`: this option allows you to configure the way you to filter the string. The default pattern is FilterOperands::STRING_STARTS. See the FilterOperands::STRING_xxx constants for all available patterns.
* `condition_pattern`: this option allows you to configure the way you to filter the string. The default pattern is FilterOperands::STRING_STARTS.
See the FilterOperands::STRING_xxx constants for all available patterns (starts with, ends with or contains).
You can also use FilterOperands::OPERAND_SELECTOR, this will display a combo box with available patterns in addition to the input text.

***
Expand Down
10 changes: 7 additions & 3 deletions Resources/doc/working-with-the-bundle.md
Expand Up @@ -5,7 +5,7 @@
i. Simple example
-----------------

Here an example of how to use the bundle. Let's use the following entity:
Here an example of how to use the bundle (with doctrine ORM). Let's use the following entity:

```php
<?php
Expand Down Expand Up @@ -128,7 +128,7 @@ ii. Inner workings

A filter is applied by using events. Basically the `lexik_form_filter.query_builder_updater` service will trigger a default event named according to the form type to get the condition for a given filter.
Then once all condition have been gotten another event will be triggered to add these conditions to the (doctrine) query builder.
We provide a event/listener that supports Doctrine ORM and DBAL.
We provide a event/listener that supports Doctrine ORM, DBAL and MongoDB.

The default event name pattern is `lexik_form_filter.apply.<query_builder_type>.<form_type_name>`.

Expand All @@ -147,17 +147,21 @@ The event name that will be triggered to get conditions to apply will be:

* `lexik_form_filter.apply.dbal.filter_text` if you provide a `Doctrine\DBAL\Query\QueryBuilder`

* `lexik_form_filter.apply.mongodb.filter_text` if you provide a `Doctrine\ODM\MongoDB\Query\Builder`

Then another event will be triggered to add all the conditions to the (doctrine) query builder instance:

* `lexik_filter.apply_filters.orm` if you provide a `Doctrine\ORM\QueryBuilder`

* `lexik_filter.apply_filters.dbal` if you provide a `Doctrine\DBAL\Query\QueryBuilder`

* `lexik_filter.apply_filters.mongodb` if you provide a `Doctrine\ODM\MongoDB\Query\Builder`

iii. Customize condition operator
---------------------------------

By default the `lexik_form_filter.query_builder_updater` service will add conditions by using AND.
But you can customize the operator (and/or) to use between conditions when its added to the (doctrine) query builder.
But you can customize the operator (and/or) to use between each conditions when its added to the (doctrine) query builder.
To do so you will have to use the `filter_condition_builder` option in your main type class.

Here a simple example, the main type `ItemFilterType` is composed of 2 simple fields and a sub type (RelatedOptionsType).
Expand Down

0 comments on commit 7f14f83

Please sign in to comment.