Created
August 17, 2012 08:01
-
-
Save notomato/3376880 to your computer and use it in GitHub Desktop.
Using a base subclass
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 | |
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