Skip to content

Instantly share code, notes, and snippets.

@m4rcsch
Created December 11, 2011 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4rcsch/1459916 to your computer and use it in GitHub Desktop.
Save m4rcsch/1459916 to your computer and use it in GitHub Desktop.
custom li3 save with validation
<?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