[Listener] Revise is_indexable_callback documentation

This commit is contained in:
Jeremy Mikola 2012-04-16 12:45:10 -04:00
parent 86cdaa7c3c
commit a15dd2a411

View file

@ -479,18 +479,30 @@ You can also choose to only listen for some of the events:
### Checking an entity method for listener
If you use listeners to update your index, you may need to validate your entities before you put them to the
index (e.g. is the entity public). You can do this with the is_indexable_callback config param.
If you use listeners to update your index, you may need to validate your
entities before you index them (e.g. only index "public" entities). Typically,
you'll want the listener to be consistent with the provider's query criteria.
This may be achieved by using the `is_indexable_callback` config parameter:
persistence:
listener:
is_indexable_callback: "isPublic"
is_indexable_callback: "isPublic"
This is optional, but if you set the is_indexable_callback and the entity has a method with the specified name, your
entities will go into the index only if the method returns true. If you update an entity and the update
listener is active, it will check the method again, and if it returns true, the entity will be removed from
the index. If it returns true, it will be updated in the index of course. Delete listener disregards the
is_indexable_callback.
If `is_indexable_callback` is a string and the entity has a method with the
specified name, the listener will only index entities for which the method
returns `true`. Additionally, you may provide a service and method name pair:
persistence:
listener:
is_indexable_callback: [ "%custom_service_id%", "isIndexable" ]
In this case, the callback will be the `isIndexable()` method on the specified
service. This allows you to do more complex validation (e.g. ACL checks).
As you might expect, new entities will only be indexed if the callback returns
`true`. Additionally, modified entities will be updated or removed from the
index depending on whether the callback returns `true` or `false`, respectively.
The delete listener disregards the callback.
> **Propel** doesn't support this feature yet.