Skip to content

Instantly share code, notes, and snippets.

@HellPat
Created September 13, 2012 19:32
Show Gist options
  • Save HellPat/3716979 to your computer and use it in GitHub Desktop.
Save HellPat/3716979 to your computer and use it in GitHub Desktop.
Doctrine Annotation-Driver - Problem with inheritance of LifecycleCallbacks
<?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