src/Daikin/BaseBundle/Entity/AbstractUserOwnedEntity.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Daikin\BaseBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\MappedSuperclass
  6.  */
  7. abstract class AbstractUserOwnedEntity extends AbstractDeleteableEntity
  8. {
  9.     /**
  10.      * @ORM\Column(type="text", length=65000, nullable=true)
  11.      */
  12.     protected $user_comments;
  13.     /**
  14.      * set the user comments text, overwriting everything
  15.      *
  16.      * @param string $text
  17.      * @return $this
  18.      */
  19.     public function setUserComments($text)
  20.     {
  21.         $this->user_comments $text;
  22.         return $this;
  23.     }
  24.     /**
  25.      * get the user comments text
  26.      *
  27.      * @return string
  28.      */
  29.     public function getUserComments()
  30.     {
  31.         return $this->user_comments;
  32.     }
  33.     /**
  34.      * add a comment by User
  35.      *
  36.      * @param User $user
  37.      * @param string $text
  38.      * @return $this
  39.      */
  40.     public function addComment(User $user$text)
  41.     {
  42.         if (null === $this->user_comments /* || preg_match( '#^\s*$#m', $this->user_comments ) */)
  43.             $this->user_comments '';
  44.         else
  45.             $this->user_comments .= "\n\n";
  46.         $this->user_comments .= '[' date('d.m.Y H:i') . '] ' $user ': ' trim($text);
  47.         return $this;
  48.     }
  49.     /**
  50.      * this object belongs to Company $company?
  51.      *
  52.      * @param Company $company
  53.      * @return bool
  54.      */
  55.     public function belongsToCompany(Company $company)
  56.     {
  57.         return ($company->getId() == $this->getCompanyid());
  58.     }
  59.     /**
  60.      * get the ID of the company this object belongs to
  61.      *
  62.      * @return integer
  63.      */
  64.     abstract public function getCompanyid();
  65. }