upgraded to symfony 4 #74 (#81)

This commit is contained in:
Kevin Papst
2018-01-12 20:39:07 +01:00
committed by GitHub
parent c011b83b73
commit a87355695e
232 changed files with 5260 additions and 4231 deletions

196
src/Entity/Activity.php Normal file
View File

@@ -0,0 +1,196 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Activity
*
* @ORM\Table(name="activities")
* @ORM\Entity(repositoryClass="App\Repository\ActivityRepository")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Activity
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var Project
*
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="activities")
* @ORM\JoinColumn(onDelete="CASCADE")
* @Assert\NotNull()
*/
private $project;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $visible = true;
/**
* @var Timesheet[]
*
* @ORM\OneToMany(targetEntity="App\Entity\Timesheet", mappedBy="activity")
*/
private $timesheets;
/**
* @return Timesheet[]
*/
public function getTimesheets()
{
return $this->timesheets;
}
/**
* @param Timesheet[] $timesheets
* @return Activity
*/
public function setTimesheets($timesheets)
{
$this->timesheets = $timesheets;
return $this;
}
/**
* @return Project
*/
public function getProject()
{
return $this->project;
}
/**
* @param Project $project
* @return Activity
*/
public function setProject($project)
{
$this->project = $project;
return $this;
}
/**
* Set name
*
* @param string $name
* @return Activity
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set comment
*
* @param string $comment
* @return Activity
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return Activity
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Get activity id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function __toString()
{
return $this->getName();
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Configuration
*
* @ORM\Table(name="configuration")
* @ORM\Entity
*/
class Configuration
{
/**
* @var string
*
* @ORM\Column(name="option", type="string", length=255)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $option;
/**
* @var string
*
* @ORM\Column(name="value", type="string", length=255, nullable=false)
*/
private $value;
/**
* Set value
*
* @param string $value
*
* @return Configuration
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Get option
*
* @return string
*/
public function getOption()
{
return $this->option;
}
}

543
src/Entity/Customer.php Normal file
View File

@@ -0,0 +1,543 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Customer
*
* @ORM\Table(name="customers")
* @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Customer
{
const DEFAULT_CURRENCY = 'EUR';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var Project[]
*
* @ORM\OneToMany(targetEntity="App\Entity\Project", mappedBy="customer")
*/
private $projects;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $visible = true;
/**
* @var string
*
* @ORM\Column(name="company", type="string", length=255, nullable=true)
*/
private $company;
/**
* @var integer
*
* @ORM\Column(name="vat", type="integer", length=2, nullable=true)
* @Assert\Range(min = 0, max = 99)
*
*/
private $vat;
/**
* @var string
*
* @ORM\Column(name="contact", type="string", length=255, nullable=true)
*/
private $contact;
/**
* @var string
*
* @ORM\Column(name="street", type="text", length=65535, nullable=true)
*/
private $address;
/**
* @var string
*
* @ORM\Column(name="country", type="string", length=2, nullable=true)
* @Assert\NotBlank()
*/
private $country;
/**
* @var string
*
* @ORM\Column(name="currency", type="string", length=3, nullable=false)
* @Assert\NotBlank()
*/
private $currency = self::DEFAULT_CURRENCY;
/**
* @var string
*
* @ORM\Column(name="phone", type="string", length=255, nullable=true)
*/
private $phone;
/**
* @var string
*
* @ORM\Column(name="fax", type="string", length=255, nullable=true)
*/
private $fax;
/**
* @var string
*
* @ORM\Column(name="mobile", type="string", length=255, nullable=true)
*/
private $mobile;
/**
* @var string
*
* @ORM\Column(name="mail", type="string", length=255, nullable=true)
*/
private $mail;
/**
* @var string
*
* @ORM\Column(name="homepage", type="string", length=255, nullable=true)
*/
private $homepage;
/**
* @var string
*
* @ORM\Column(name="timezone", type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $timezone;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return Customer
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set comment
*
* @param string $comment
*
* @return Customer
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return Customer
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set company
*
* @param string $company
*
* @return Customer
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* Get company
*
* @return string
*/
public function getCompany()
{
return $this->company;
}
/**
* Set vat
*
* @param integer $vat
*
* @return Customer
*/
public function setVat($vat)
{
$this->vat = $vat;
return $this;
}
/**
* Get vat
*
* @return integer
*/
public function getVat()
{
return $this->vat;
}
/**
* Set contact
*
* @param string $contact
*
* @return Customer
*/
public function setContact($contact)
{
$this->contact = $contact;
return $this;
}
/**
* Get contact
*
* @return string
*/
public function getContact()
{
return $this->contact;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @param string $address
*
* @return Customer
*/
public function setAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Set country
*
* @param string $country
*
* @return Customer
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* @return string
*/
public function getCountry()
{
return $this->country;
}
/**
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @param string $currency
* @return $this
*/
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}
/**
* Set phone
*
* @param string $phone
*
* @return Customer
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Get phone
*
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* Set fax
*
* @param string $fax
*
* @return Customer
*/
public function setFax($fax)
{
$this->fax = $fax;
return $this;
}
/**
* Get fax
*
* @return string
*/
public function getFax()
{
return $this->fax;
}
/**
* Set mobile
*
* @param string $mobile
*
* @return Customer
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
return $this;
}
/**
* Get mobile
*
* @return string
*/
public function getMobile()
{
return $this->mobile;
}
/**
* Set mail
*
* @param string $mail
*
* @return Customer
*/
public function setMail($mail)
{
$this->mail = $mail;
return $this;
}
/**
* Get mail
*
* @return string
*/
public function getMail()
{
return $this->mail;
}
/**
* Set homepage
*
* @param string $homepage
*
* @return Customer
*/
public function setHomepage($homepage)
{
$this->homepage = $homepage;
return $this;
}
/**
* Get homepage
*
* @return string
*/
public function getHomepage()
{
return $this->homepage;
}
/**
* Set timezone
*
* @param string $timezone
*
* @return Customer
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;
return $this;
}
/**
* Get timezone
*
* @return string
*/
public function getTimezone()
{
return $this->timezone;
}
/**
* @param Project[] $projects
* @return $this
*/
public function setProjects($projects)
{
$this->projects = $projects;
return $this;
}
/**
* @return Project[]
*/
public function getProjects()
{
return $this->projects;
}
/**
* @return string
*/
public function __toString()
{
return $this->getName();
}
}

234
src/Entity/Project.php Normal file
View File

@@ -0,0 +1,234 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Project
*
* @ORM\Table(name="projects")
* @ORM\Entity(repositoryClass="App\Repository\ProjectRepository")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Project
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var Customer
*
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="projects")
* @ORM\JoinColumn(onDelete="CASCADE")
* @Assert\NotNull()
*/
private $customer;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
* @Assert\NotNull()
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
*/
private $comment;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $visible = true;
/**
* @var string
*
* @ORM\Column(name="budget", type="decimal", precision=10, scale=2, nullable=false)
* @Assert\NotNull()
*/
private $budget = 0.00;
/**
* @var Activity[]
*
* @ORM\OneToMany(targetEntity="App\Entity\Activity", mappedBy="project")
*/
private $activities;
/**
* Get projectid
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param $customer
* @return $this
*/
public function setCustomer($customer)
{
$this->customer = $customer;
return $this;
}
/**
* Set name
*
* @param string $name
*
* @return Project
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set comment
*
* @param string $comment
*
* @return Project
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return Project
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set budget
*
* @param string $budget
*
* @return Project
*/
public function setBudget($budget)
{
$this->budget = $budget;
return $this;
}
/**
* Get budget
*
* @return string
*/
public function getBudget()
{
return $this->budget;
}
/**
* @param Activity[] $activities
* @return $this
*/
public function setActivities($activities)
{
$this->activities = $activities;
return $this;
}
/**
* @return Activity[]
*/
public function getActivities()
{
return $this->activities;
}
/**
* @return string
*/
public function __toString()
{
return $this->getName();
}
}

272
src/Entity/Timesheet.php Normal file
View File

@@ -0,0 +1,272 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use App\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Timesheet entity.
*
* @ORM\Table(
* name="timesheet",
* indexes={
* @ORM\Index(columns={"user"}),
* @ORM\Index(columns={"activity_id"})
* }
* )
* @ORM\Entity(repositoryClass="App\Repository\TimesheetRepository")
* @ORM\HasLifecycleCallbacks()
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class Timesheet
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="start_time", type="datetime", nullable=false)
* @Assert\NotNull()
*/
private $begin;
/**
* @var \DateTime
*
* @ORM\Column(name="end_time", type="datetime", nullable=true)
*/
private $end;
/**
* @var integer
*
* @ORM\Column(name="duration", type="integer", nullable=true)
*/
private $duration = 0;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(name="user", referencedColumnName="id")
* @Assert\NotNull()
*/
private $user;
/**
* @var Activity
*
* @ORM\ManyToOne(targetEntity="App\Entity\Activity", inversedBy="timesheets")
* @ORM\JoinColumn(onDelete="CASCADE")
* @Assert\NotNull()
*/
private $activity;
/**
* @var string
*
* @ORM\Column(name="description", type="text", length=65535, nullable=true)
*/
private $description;
/**
* @var string
*
* @ORM\Column(name="rate", type="decimal", precision=10, scale=2, nullable=false)
*/
private $rate = 0.00;
/**
* Get entry id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return \DateTime
*/
public function getBegin()
{
return $this->begin;
}
/**
* @param \DateTime $begin
* @return Timesheet
*/
public function setBegin($begin)
{
$this->begin = $begin;
return $this;
}
/**
* @return \DateTime
*/
public function getEnd()
{
return $this->end;
}
/**
* @param \DateTime $end
* @return Timesheet
*/
public function setEnd($end)
{
$this->end = $end;
if ($end === null) {
$this->duration = 0;
}
return $this;
}
/**
* Set duration
*
* @param integer $duration
*
* @return Timesheet
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
/**
* Get duration
*
* @return integer
*/
public function getDuration()
{
if ($this->begin === null) {
return 0;
}
if ($this->end === null) {
$current = new \DateTime();
return $current->getTimestamp() - $this->begin->getTimestamp();
}
return $this->duration;
}
/**
* Set user
*
* @param User $user
*
* @return Timesheet
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* Set activity
*
* @param Activity $activity
*
* @return Timesheet
*/
public function setActivity($activity)
{
$this->activity = $activity;
return $this;
}
/**
* Get Activity
*
* @return Activity
*/
public function getActivity()
{
return $this->activity;
}
/**
* Set description
*
* @param string $description
*
* @return Timesheet
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set rate
*
* @param string $rate
*
* @return Timesheet
*/
public function setRate($rate)
{
$this->rate = $rate;
return $this;
}
/**
* Get rate
*
* @return string
*/
public function getRate()
{
return $this->rate;
}
}

432
src/Entity/User.php Normal file
View File

@@ -0,0 +1,432 @@
<?php
namespace App\Entity;
use App\Validator\Constraints as KimaiAssert;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* User
*
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table(
* name="users",
* uniqueConstraints={
* @ORM\UniqueConstraint(columns={"name"}),
* @ORM\UniqueConstraint(columns={"mail"})
* }
* )
* @UniqueEntity("username")
* @UniqueEntity("email")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class User implements UserInterface, AdvancedUserInterface
{
const DEFAULT_ROLE = 'ROLE_USER';
const DEFAULT_LANGUAGE = 'de';
/**
* @var int
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="id", type="integer")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=60, nullable=false, unique=true)
* @Assert\NotBlank()
* @Assert\Length(min=6, max=160)
*/
private $username;
/**
* @var string
*
* @ORM\Column(name="mail", type="string", length=160, nullable=false, unique=true)
* @Assert\NotBlank()
* @Assert\Email()
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=254, nullable=true)
*/
private $password;
/**
* @var string
*
* @Assert\NotBlank(groups={"registration", "passwordUpdate"})
* @Assert\Length(min=6, max=4096, groups={"registration", "passwordUpdate"})
*/
private $plainPassword;
/**
* @var string
*
* @ORM\Column(name="alias", type="string", length=60, nullable=true)
* @Assert\Length(max=160)
*/
private $alias;
/**
* @var string
*
* @ORM\Column(name="language", type="string", length=5, nullable=true)
* @Assert\Language()
*/
private $language = self::DEFAULT_LANGUAGE;
/**
* @var boolean
*
* @ORM\Column(name="active", type="boolean", nullable=false)
* @Assert\NotNull()
*/
private $active = true;
/**
* @var \DateTime
*
* @ORM\Column(name="registration_date", type="datetime", nullable=true)
*/
private $registeredAt;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=50, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="avatar", type="string", length=255, nullable=true)
*/
private $avatar;
/**
* @var string[]
*
* @ORM\Column(type="json_array")
* @KimaiAssert\Role()
*/
private $roles = [];
/**
* User constructor.
*/
public function __construct()
{
$this->registeredAt = new \DateTime();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return \DateTime
*/
public function getRegisteredAt()
{
return $this->registeredAt;
}
/**
* @param $registeredAt
* @return $this
*/
public function setRegisteredAt($registeredAt)
{
$this->registeredAt = $registeredAt;
return $this;
}
/**
* @param string $alias
* @return $this
*/
public function setAlias($alias)
{
$this->alias = $alias;
return $this;
}
/**
* @return string
*/
public function getAlias()
{
return $this->alias;
}
/**
* @param boolean $active
* @return $this
*/
public function setActive($active)
{
$this->active = (bool) $active;
return $this;
}
/**
* @return boolean
*/
public function isActive()
{
return $this->active;
}
/**
* @deprecated
* @return boolean
*/
public function getActive()
{
return $this->isActive();
}
/**
* @param string $password
* @return $this
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Only for form editing, you don't need this method!
*
* @return string
*/
public function getPlainPassword()
{
return $this->plainPassword;
}
/**
* Only for form editing, you don't need this method!
*
* @param string $password
* @return $this
*/
public function setPlainPassword($password)
{
$this->plainPassword = $password;
return $this;
}
/**
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* @param string $username
* @return $this
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
* @return $this
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
* @return $this
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* @param string $avatar
* @return $this
*/
public function setAvatar($avatar)
{
$this->avatar = $avatar;
return $this;
}
/**
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* @param string $language
* @return $this
*/
public function setLanguage($language)
{
$this->language = $language;
return $this;
}
/**
* Returns the roles or permissions granted to the user for security.
*
* @return string[]
*/
public function getRoles()
{
$roles = $this->roles;
// guarantees that a user always has at least one role for security
if (empty($roles)) {
$roles[] = 'ROLE_USER';
}
return array_unique($roles);
}
/**
* @param string[] $roles
* @return $this
*/
public function setRoles(array $roles)
{
$this->roles = $roles;
return $this;
}
/**
* @inheritdoc
*/
public function isAccountNonExpired()
{
return $this->isEnabled();
}
/**
* @inheritdoc
*/
public function isAccountNonLocked()
{
return $this->isEnabled();
}
/**
* @inheritdoc
*/
public function isCredentialsNonExpired()
{
return $this->isEnabled();
}
/**
* @return bool
*/
public function isEnabled()
{
return $this->isActive();
}
/**
* Returns the salt that was originally used to encode the password.
*/
public function getSalt()
{
// See "Do you need to use a Salt?" at http://symfony.com/doc/current/cookbook/security/entity_provider.html
// we're using bcrypt in security.yml to encode the password, so
// the salt value is built-in and you don't have to generate one
return;
}
/**
* Removes sensitive data from the user.
*/
public function eraseCredentials()
{
// if you had a plainPassword property, you'd nullify it here
// $this->plainPassword = null;
}
/**
* @return string
*/
public function __toString()
{
return $this->getAlias() ?: $this->getUsername();
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* UserPreference
*
* @ORM\Table(name="preferences",indexes={@ORM\Index(columns={"userid", "option"})}))
* @ORM\Entity
*/
class UserPreference
{
/**
* @var integer
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="userID", type="integer")
*/
private $userid;
/**
* @var string
*
* @ORM\Column(name="option", type="string", length=255)
*/
private $option;
/**
* @var string
*
* @ORM\Column(name="value", type="string", length=255, nullable=false)
*/
private $value;
/**
* Set value
*
* @param string $value
*
* @return UserPreference
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Set option
*
* @param string $option
*
* @return UserPreference
*/
public function setOption($option)
{
$this->option = $option;
return $this;
}
/**
* Get option
*
* @return string
*/
public function getOption()
{
return $this->option;
}
/**
* Set userid
*
* @param integer $userid
*
* @return UserPreference
*/
public function setUserid($userid)
{
$this->userid = $userid;
return $this;
}
/**
* Get userid
*
* @return integer
*/
public function getUserid()
{
return $this->userid;
}
}