Created
September 13, 2012 19:32
-
-
Save HellPat/3716979 to your computer and use it in GitHub Desktop.
Doctrine Annotation-Driver - Problem with inheritance of LifecycleCallbacks
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 characters
<?php | |
namespace App\Model\Base; | |
use \App\Uuid; | |
/** | |
* @MappedSuperclass | |
* @HasLifecycleCallbacks | |
*/ | |
abstract class Model { | |
/*------------------------------------------------------------------------------------------------------ | |
| Class Variables | |
------------------------------------------------------------------------------------------------------*/ | |
/** | |
* @Id | |
* @Column(type="string", length=50, nullable=false) | |
*/ | |
private $id; | |
/*------------------------------------------------------------------------------------------------------ | |
| Getters | |
------------------------------------------------------------------------------------------------------*/ | |
/** | |
* getId function. | |
* | |
* @access public | |
* @return int the users id | |
*/ | |
public function getId(){ | |
return $this->id; | |
} | |
/*------------------------------------------------------------------------------------------------------ | |
| Callbacks | |
------------------------------------------------------------------------------------------------------*/ | |
/** | |
* setId function | |
* | |
* sets the objects id to an uuid (universal unique identifier) | |
* | |
* @PrePersist | |
*/ | |
public function setUuid() { | |
$uuid = Uuid::v4(); | |
$this->setId($uuid); | |
} | |
} | |
/** | |
* Class User | |
* | |
* A User | |
* has an id (varchar). It has to be universial unique | |
* optionally has a username (string) | |
* has an email adress (string) | |
* has a password (string). It has to be crypted | |
* | |
* @Entity | |
*/ | |
class User extends \App\Model\Base\Model { | |
........ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment