ZF-11968: Allow pre/post add/update/deletion logic to be applied to Zend_Ldap_Node

Description

{{Zend_Db_Table_Row_Abstract}} offers the ability to execute some specific logic before and after a {{Row}} creation, update and deletion via the following methods: * {{_preInsert()}} * {{_postInsert()}} * {{_preUpdate()}} * {{_postUpdate()}} * {{_preDelete()}} * {{_postDelete()}}

There is no such thing in {{Zend_Ldap_Node}} or {{Zend_Ldap_Node_Abstract}}. When one have subclassed {{Zend_Ldap_Node}} he could want to perform special actions when a LDAP entry/node gets updated (eg. recompute {{displayName}} from {{givenName}} and {{surname}}, password changed notification, etc.).

As {{Zend_Ldap_Node::update()}} performs all useful checks before calling the relevant {{Zend_Ldap}} methods ({{add()}}, ({{update()}} or ({{delete()}}) it would be fairly easy to add this feature.

+Patch file proposal:+ Here is a patch (based on {{Zend\Ldap\Node.php}} r24352) that adds pre/post add/update/rename/delete methods.


435a436
>                 $this->_preDelete();
436a438
>                 $this->_postDelete();
442a445
>             $this->_preAdd();
443a447
>             $this->_postAdd();
450a455
>             $this->_preRename();
451a457
>             $this->_postRename();
460a467
>             $this->_preUpdate();
461a469
>             $this->_postUpdate();
464a473,552
>     }
> 
>     /**
>     * Allows pre-add logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _preAdd ()
>     {
>     }
> 
>     /**
>     * Allows post-add logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _postAdd ()
>     {
>     }
> 
>     /**
>     * Allows pre-update logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _preUpdate ()
>     {
>     }
> 
>     /**
>     * Allows post-update logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _postUpdate ()
>     {
>     }
> 
>     /**
>     * Allows pre-rename logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _preRename ()
>     {
>     }
> 
>     /**
>     * Allows post-rename logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _postRename ()
>     {
>     }
> 
>     /**
>     * Allows pre-delete logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _preDelete ()
>     {
>     }
> 
>     /**
>     * Allows post-delete logic to be applied to node.
>     * Subclasses may override this method.
>     *
>     * @return void
>     */
>     protected function _postDelete ()
>     {

Comments

Minor typos

Fixed in ZF1 trunk and in 1.11 release branch. Patch implemented as provided by the OP

Also fixed in ZF2 - pull request https://github.com/zendframework/zf2/pull/745

Thanks

Stefan -- please back this out of the 1.11 release branch. New features should not be added within a bugfix release, only with new minor/major releases. We can release this with 1.12.0.

Stefan -- also, for ZF2, this functionality should be implemented using an EventManager instance instead. If you want some ideas on how that might be accomplished, ping me.

Re-opening, as the functionality needs to be backed out of the 1.11 release branch, and targetted for the 1.12.0 release.

removed fix from the 1.11 branch

Thanks, Stefan. If you need any assistance with the ZF2 version of the patch, let me know.