jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Environment/] [MessageArgs.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 JsonSerializable;
use Phem\Core\Object;

/**
 * @author kubapet
 * @Entity
 * @Table(name="admin_event_args")
 */
class MessageArgs extends Object implements JsonSerializable
{

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

    /**
     * @ManyToOne(targetEntity="Message",cascade={"persist"})
     * @JoinColumn(name="message", referencedColumnName="id")
     */
    private $message;

    /**
     * @var String Description
     * @Column
     *      (type="string") 
     */
    private $actionUrl;

    /*
     * append
     * prepend
     * replace
     */

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

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

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

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

    public function getMessage()
    {
        return $this->message;
    }

    public function setMessage($message)
    {
        $this->message = $message;
    }

    public function getActionUrl()
    {
        return $this->actionUrl;
    }

    public function setActionUrl($actionUrl)
    {
        $this->actionUrl = $actionUrl;
    }

    public function getActionType()
    {
        return $this->actionType;
    }

    public function setActionType($actionType)
    {
        $this->actionType = $actionType;
    }

    public function getActionTarget()
    {
        return $this->actionTarget;
    }

    public function setActionTarget($actionTarget)
    {
        $this->actionTarget = $actionTarget;
    }

    public function jsonSerialize()
    {

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

        foreach ($getters as $getter)
        {
            if (strpos($getter, "get") === 0)
            {
                $propName = preg_replace('/get/', '', $getter, 1);
                $propName{0} = strtolower($propName{0});
                if ($propName == "message")
                $result[$propName] = $this->$getter()->getId();
                else
                $result[$propName] = $this->$getter();
            }
        }

        return $result;
    }

}

Powered by WebSVN 2.2.1