Skip to content

Instantly share code, notes, and snippets.

@notomato
Created August 17, 2012 08:01
Show Gist options
  • Save notomato/3376880 to your computer and use it in GitHub Desktop.
Save notomato/3376880 to your computer and use it in GitHub Desktop.
Using a base subclass
<?php
class Base extends lithium\data\Model {
public function save($entity, $data = null, array $options = array()) {
if ($data) {
$entity->set($data);
}
if (!$entity->exists()) {
$entity->created = new MongoDate();
}
$entity->updated = new MongoDate();
return parent::save($entity, null, $options);
}
}
class Posts extends Base {
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment