Browse files

[Listener] Revise is_indexable_callback documentation

  • Loading branch information...
1 parent 86cdaa7 commit a15dd2a411e0d00fa0bb0de60a169f71febd5c64 @jmikola jmikola committed Apr 16, 2012
Showing with 20 additions and 8 deletions.
  1. +20 −8
@@ -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:
- 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
+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.

0 comments on commit a15dd2a

Please sign in to comment.