Browse Source

Merge pull request #5705 from cakephp/before-marshall-docs

Add documentation and event mapping for beforeMarshal event.
José Lorenzo Rodríguez 11 years ago
parent
commit
da10b6b33a
2 changed files with 13 additions and 0 deletions
  1. 1 0
      src/ORM/Behavior.php
  2. 12 0
      src/ORM/Table.php

+ 1 - 0
src/ORM/Behavior.php

@@ -249,6 +249,7 @@ class Behavior implements EventListenerInterface
     public function implementedEvents()
     {
         $eventMap = [
+            'Model.beforeMarshal' => 'beforeMarshal',
             'Model.beforeFind' => 'beforeFind',
             'Model.beforeSave' => 'beforeSave',
             'Model.afterSave' => 'afterSave',

+ 12 - 0
src/ORM/Table.php

@@ -1813,6 +1813,9 @@ class Table implements RepositoryInterface, EventListenerInterface
      * You can also pass the name of the validator to use in the `validate` option.
      * If `null` is passed to the first param of this function, no validation will
      * be performed.
+     *
+     * You can use the `Model.beforeMarshal` event to modify request data
+     * before it is converted into entities.
      */
     public function newEntity($data = null, array $options = [])
     {
@@ -1854,6 +1857,8 @@ class Table implements RepositoryInterface, EventListenerInterface
      * );
      * ```
      *
+     * You can use the `Model.beforeMarshal` event to modify request data
+     * before it is converted into entities.
      */
     public function newEntities(array $data, array $options = [])
     {
@@ -1891,6 +1896,9 @@ class Table implements RepositoryInterface, EventListenerInterface
      *  'validate' => false
      * ]);
      * ```
+     *
+     * You can use the `Model.beforeMarshal` event to modify request data
+     * before it is converted into entities.
      */
     public function patchEntity(EntityInterface $entity, array $data, array $options = [])
     {
@@ -1922,6 +1930,9 @@ class Table implements RepositoryInterface, EventListenerInterface
      *  ]
      * );
      * ```
+     *
+     * You can use the `Model.beforeMarshal` event to modify request data
+     * before it is converted into entities.
      */
     public function patchEntities($entities, array $data, array $options = [])
     {
@@ -2063,6 +2074,7 @@ class Table implements RepositoryInterface, EventListenerInterface
     public function implementedEvents()
     {
         $eventMap = [
+            'Model.beforeMarshal' => 'beforeMarshal',
             'Model.beforeFind' => 'beforeFind',
             'Model.beforeSave' => 'beforeSave',
             'Model.afterSave' => 'afterSave',