Skip to content
Browse files

moved hook methods

  • Loading branch information...
1 parent b95debe commit 58d9080d0495711c57e9d4f43f6c3d6808cab438 @mpscholten committed
Showing with 83 additions and 0 deletions.
  1. +83 −0 src/Propel/Generator/Builder/Om/templates/Object/_hookMethods.php.twig
View
83 src/Propel/Generator/Builder/Om/templates/Object/_hookMethods.php.twig
@@ -0,0 +1,83 @@
+{% for hook in ['pre', 'post'] %}
+ {% for action in ['insert', 'update', 'save', 'delete'] %}
+ {% set name = hook ~ action|ucfirst %}
+ {% if name == 'preSave' %}
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+ {% elseif name == 'postSave' %}
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+ {% elseif name == 'preInsert' %}
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+ {% elseif name == 'postInsert' %}
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+ {% elseif name == 'preUpdate' %}
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+ {% elseif name == 'postUpdate' %}
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+ {% elseif name == 'preDelete' %}
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+ {% elseif name == 'postDelete' %}
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+ {% endif %}
+ {% endfor %}
+
+{% endfor %}

0 comments on commit 58d9080

Please sign in to comment.
Something went wrong with that request. Please try again.