Created
December 11, 2011 10:51
-
-
Save m4rcsch/1459916 to your computer and use it in GitHub Desktop.
Revisions
-
m4rcsch revised this gist
Dec 11, 2011 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,17 @@ <?php // ATTENTION: this is pseudocode alike! // witten inside the gist textbox without php validation! /** * This is a models vutsom save method * The models validation rules should contain at least one 'on' => 'publish' rule! * * @param Object $entity * @param mixed $data * @param array $options * @return booolean */ public function publish($entity, $data = null, array $options = array()) { $default_data = array( 'published' = 'true' @@ -17,4 +28,6 @@ public function publish($entity, $data = null, array $options = array()) { */ $valid = $this->validates($entity,$data,$options); return (!$valid)?:$this->save($entity,$data,$options); } ?> -
m4rcsch created this gist
Dec 11, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ // ATTENTION: this is pseudocode alike! // witten inside the gist textbox without php validation! public function publish($entity, $data = null, array $options = array()) { $default_data = array( 'published' = 'true' ) $default_options = array( 'events' = 'publish' ) $options += $default_options; $data += $default_data; /** * Validation would be obsolte, if saving does know about the 'event' */ $valid = $this->validates($entity,$data,$options); return (!$valid)?:$this->save($entity,$data,$options); }