Skip to content

Instantly share code, notes, and snippets.

@riscos
Last active December 30, 2015 08:19
Show Gist options
  • Save riscos/7801714 to your computer and use it in GitHub Desktop.
Save riscos/7801714 to your computer and use it in GitHub Desktop.
This my user model
<?php
namespace Vendor\Package\\Domain\Model\User;
/* *
* This script belongs to the TYPO3 Flow package "Vendor.Package". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;
/**
* A base user class.
*
* @Flow\Entity
* @ORM\MappedSuperclass
*/
class BaseUser {
/**
* @var \Doctrine\Common\Collections\Collection<\TYPO3\Flow\Security\Account>
* @ORM\ManyToMany()
*/
protected $accounts;
/**
* The user's first name.
*
* @var string
* @Flow\Validate(type="NotEmpty")
* @Flow\Validate(type="String")
* @Flow\Validate(type="StringLength", options={"minimum"=1, "maximum"=50})
* @Flow\Validate(type="\Vendor\Package\Validation\Validator\AnonValidator")
* @ORM\Column(length=50)
*/
protected $firstName = '';
/**
* The user's last name.
*
* @var string
* @Flow\Validate(type="NotEmpty")
* @Flow\Validate(type="String")
* @Flow\Validate(type="StringLength", options={"minimum"=1, "maximum"=50})
* @Flow\Validate(type="\Vendor\Package\Validation\Validator\AnonValidator")
* @ORM\Column(length=50)
*/
protected $lastName = '';
/**
* The user's email address.
*
* @var string
* @Flow\Validate(type="EmailAddress")
* @Flow\Validate(type="StringLength", options={"minimum"=5, "maximum"=150})
* @ORM\Column(length=150)
*/
protected $email = '';
/**
* The date/time that the record was last updated.
*
* @var \DateTime
* @ORM\Column(nullable=TRUE)
*/
protected $updated;
/**
* The date/time that the record was created.
*
* @var \DateTime
* @ORM\Column(nullable=TRUE)
*/
protected $created;
/**
* Constructor
*/
public function __construct() {
$now = new \TYPO3\Flow\Utility\Now();
$this->setUpdated($now);
$this->setCreated($now);
$this->accounts = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Gets user's first name.
*
* @return string The user's first name.
*/
public function getFirstName() {
return $this->firstName;
}
/**
* Sets user's first name.
*
* @param string $firstName The user's first name.
* @return void
*/
public function setFirstName($firstName) {
$this->firstName = $firstName;
}
/**
* Gets user's email address.
*
* @return string The user's email address.
*/
public function getLastName() {
return $this->lastName;
}
/**
* Sets user's last name.
*
* @param string $lastName The user's last name.
* @return void
*/
public function setLastName($lastName) {
$this->lastName = $lastName;
}
/**
* Sets user's email.
*
* @param string $email The user's email address.
* @return void
*/
public function setEmail($email) {
$this->email = $email;
}
/**
* Gets user's email.
*
* @return string The user's last name.
*/
public function getEmail() {
return $this->email;
}
/**
* Assigns the given account to this user.
*
* @param \TYPO3\Flow\Security\Account $account The account
* @return void
*/
public function addAccount(\TYPO3\Flow\Security\Account $account) {
$this->accounts->add($account);
}
/**
* Remove an account from this user.
*
* @param \TYPO3\Flow\Security\Account $account The account to remove
* @return void
*/
public function removeAccount(\TYPO3\Flow\Security\Account $account) {
$this->accounts->removeElement($account);
}
/**
* Returns the accounts of this user.
*
* @return \Doctrine\Common\Collections\Collection All assigned TYPO3\Flow\Security\Account objects for this user.
*/
public function getAccounts() {
return $this->accounts;
}
/**
* Gets user's full name: the first and last name.
*
* @return string The user's full name.
*/
public function getFullName() {
return $this->firstName . ' ' . $this->lastName;
}
/**
* Gets updated.
*
* @return \DateTime The date/time that the record was last updated.
*/
public function getUpdated() {
return $this->updated;
}
/**
* Sets updated.
*
* @param \DateTime $updated The date/time that the record was last updated.
* @return void
*/
public function setUpdated(\DateTime $updated) {
$this->updated = $updated;
}
/**
* Gets created.
*
* @return \DateTime The date/time that the record was created.
*/
public function getCreated() {
return $this->created;
}
/**
* Sets created.
*
* @param \DateTime $created The date/time that the record was created.
* @return void
*/
public function setCreated(\DateTime $created) {
$this->created = $created;
}
}
?>
@jpgreth
Copy link

jpgreth commented Dec 5, 2013

Line 2: namespace Vendor\Package\Domain\Model\User;
Shouldn't it be:

namespace Vendor\Package\Domain\Model\User;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment