Created
December 11, 2011 10:51
-
-
Save m4rcsch/1459916 to your computer and use it in GitHub Desktop.
custom li3 save with validation
This file contains 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 characters
<?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' | |
) | |
$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); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment