jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Environment/] [Message.php] - Rev 2

Compare with Previous - Blame - Download


<?php

namespace Phem\Environment;

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\OneToMany;
use Phem\Environment\Application;
use Phem\Libraries\ImportExport\Json\JsonSerializableObject;
use Phem\ToolSuite;

/**
 * @author kubapet
 * @Entity
 * @Table(name="admin_event")
 */
class Message extends JsonSerializableObject
{

    /**
     * @Id
     * @GeneratedValue
     * @Column
     *      (type="integer") 
     */
    private $id;

    /**
     * @GeneratedValue
     * @Column(type="datetime") 
     */
    private $date;

    /** @Column(type="string") */
    private $fromUsr;

    /**
     * @Column(type="string")
     */
    private $toUsr;

    /**
     * @Column(type="string")
     */
    private $subject;

    /**
     * @Column(type="string")
     */
    private $text;
    
    /** @OneToMany(targetEntity="MessageArgs", mappedBy="message",cascade={"persist"}) */
    private $args;

    /**
     * @ManyToOne(targetEntity="Srovnavac\Models\Entities\Session", cascade={"persist", "remove"}, fetch="EAGER")
     * @JoinColumn(name="session", referencedColumnName="id") 
     * @var Srovnavac\Models\Entities\Session   
     */
    private $session;
    
    /**
     * @Column (type="integer")
     */
    private $processed;

    function __construct()
    {
        $this->args = new \Doctrine\Common\Collections\ArrayCollection();
        $this->processed = 1;
    }

    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getDate()
    {
        return $this->date;
    }

    public function setDate($date)
    {
        $this->date = $date;
    }

    public function getFromUsr()
    {
        return $this->fromUsr;
    }

    public function setFromUsr($fromUsr)
    {
        $this->fromUsr = $fromUsr;
    }

    public function getToUsr()
    {
        return $this->toUsr;
    }

    public function setToUsr($toUsr)
    {
        $this->toUsr = $toUsr;
    }

    public function getSubject()
    {
        return $this->subject;
    }

    public function setSubject($subject)
    {
        $this->subject = $subject;
    }

    public function getText()
    {
        return $this->text;
    }

    public function setText($text)
    {
        $this->text = $text;
    }

    public function getArgs()
    {
        return $this->args;
    }

    public function setArgs($args)
    {
        $this->args = $args;
    }

    public function getSession()
    {
        return $this->session;
    }

    public function setSession(\Srovnavac\Models\Entities\Session $session)
    {
        $this->session = $session;
    }

    public function getUsers()
    {
        return ToolSuite::getSubCollection(Application::getLoggedUsers(), 'Username', 'Username');
    }

    public function jsonSerialize()
    {

        $getters = get_class_methods($this);
        $result = array();

        foreach ($getters as $getter)
        {
            if (strpos($getter, "get") === 0)
            {
                $propName = str_replace("get", "", $getter);
                $propName{0} = strtolower($propName{0});
//              $result[$propName] = json_encode($this->$getter(),JSON_UNESCAPED_UNICODE);
                if ($propName == "args")
                    $result[$propName] = $this->$getter()->toArray();
                else
                    $result[$propName] = $this->$getter();
            }
        }

        return $result;
    }
    
    public function getProcessed()
    {
        return $this->processed;
    }

    public function setProcessed($processed)
    {
        $this->processed = $processed;
    }


}

Powered by WebSVN 2.2.1