<?php
namespace App\Daikin\BaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\MappedSuperclass
*/
abstract class AbstractUserOwnedEntity extends AbstractDeleteableEntity
{
/**
* @ORM\Column(type="text", length=65000, nullable=true)
*/
protected $user_comments;
/**
* set the user comments text, overwriting everything
*
* @param string $text
* @return $this
*/
public function setUserComments($text)
{
$this->user_comments = $text;
return $this;
}
/**
* get the user comments text
*
* @return string
*/
public function getUserComments()
{
return $this->user_comments;
}
/**
* add a comment by User
*
* @param User $user
* @param string $text
* @return $this
*/
public function addComment(User $user, $text)
{
if (null === $this->user_comments /* || preg_match( '#^\s*$#m', $this->user_comments ) */)
$this->user_comments = '';
else
$this->user_comments .= "\n\n";
$this->user_comments .= '[' . date('d.m.Y H:i') . '] ' . $user . ': ' . trim($text);
return $this;
}
/**
* this object belongs to Company $company?
*
* @param Company $company
* @return bool
*/
public function belongsToCompany(Company $company)
{
return ($company->getId() == $this->getCompanyid());
}
/**
* get the ID of the company this object belongs to
*
* @return integer
*/
abstract public function getCompanyid();
}