%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/bbw/farmaci/kritik-portale/module/ReviewBase/src/ReviewBase/Model/
Upload File :
Create Path :
Current File : /var/www/html/bbw/farmaci/kritik-portale/module/ReviewBase/src/ReviewBase/Model/ClaimActivation.php

<?php
namespace ReviewBase\Model;

use Basis\Model\EventBasis;
use DateTime;
use ReviewBase\Event\ClaimActivation\ClaimActivationChangedHash;
use ReviewBase\Event\ClaimActivation\ClaimActivationChangedObjectID;
use ReviewBase\Event\ClaimActivation\ClaimActivationChangedRemind;
use ReviewBase\Event\ClaimActivation\ClaimActivationChangedUserID;
use ReviewBase\Event\ClaimActivation\ClaimActivationCreatedAt;
use ReviewBase\Event\ClaimActivation\ClaimActivationDeleted;
use Zend\Db\Adapter\Adapter;
use Zend\Json\Json;

/**
 * Description of ClaimActivation
 *
 * @author Florian Koller ( conlabz GmbH ) <florian.koller at conlabz.de>
 */
class ClaimActivation extends EventBasis
{
    protected $entityid;
    protected $userid;
    protected $objectid;
    protected $hash;
    protected $created_at;
    protected $remind;
    
    public function __construct()
    {
    }
    
    public function setId($id)
    {
        $this->entityid = $id;
    }
    
    public function getId()
    {
        return $this->entityid;
    }

    public function generateId()
    {
        $this->entityid = uniqid();
        
        //@todo claim create timestamp and save it as utc
        $now = new DateTime();
        $now = $now->format("Y-m-d H:i:s");
        $this->setCreatedAt($now);
    }
    
    /**
     * @param string $createdAt
     */
    public function setCreatedAt($createdAt)
    {
        if ($this->created_at !== $createdAt) {
            $this->created_at = $createdAt;
            $event = new ClaimActivationCreatedAt();
            $event->setParams(array(
                "created_at" => $createdAt
            ));
            $this->addEvent($event);
        }
    }

    /**
     * @return string
     */
    public function getCreatedAt()
    {
        return $this->created_at;
    }
    
    /**
     * @param $property
     * @param $value
     */
    protected function set($property, $value)
    {
        $this->$property = $value;
    }

    public function setHash($hash)
    {
        if ($this->hash !== $hash) {
            $this->hash = $hash;
            $event = new ClaimActivationChangedHash();
            $event->setParams(array(
                "hash" => $hash
            ));
            $this->addEvent($event);
        }
    }

    public function getHash()
    {
        return $this->hash;
    }

    public function generateHash()
    {
        return md5($this->entityid . $this->objectid . time());
    }
    
    public function setObjectID($objectid)
    {
        if ($this->objectid !== $objectid) {
            $this->objectid = $objectid;
            $event = new ClaimActivationChangedObjectID();
            $event->setParams(array(
                "objectid" => $objectid
            ));
            $this->addEvent($event);
        }
    }

    public function getObjectID()
    {
        return $this->objectid;
    }
    
    public function setUserID($userid)
    {
        if ($this->userid !== $userid) {
            $this->userid = $userid;
            $event = new ClaimActivationChangedUserID();
            $event->setParams(array(
                "userid" => $userid
            ));
            $this->addEvent($event);
        }
    }

    public function getUserID()
    {
        return $this->userid;
    }
    
    public function setRemind($remind)
    {
        if ($this->remind !== $remind) {
            $this->remind = $remind;
            $event = new ClaimActivationChangedRemind();
            $event->setParams(array(
                "remind" => $remind
            ));
            $this->addEvent($event);
        }
    }

    public function getRemind()
    {
        return $this->remind;
    }
    
    public function delete()
    {
        $event = new ClaimActivationDeleted();
        $event->setParams(array(
            "entityid" => $this->getId()
        ));
        $this->addEvent($event);
    }

    /**
     * @param array $events
     * @param \Basis\EventBus\EventBus $eventBus
     * @param Adapter $databaseAdapter
     */
    public function setFromEvents($events, \Basis\EventBus\EventBus $eventBus, Adapter $databaseAdapter)
    {
        foreach ($events as $event) {
            /* @var $event \Basis\Event\Event */
            $data = Json::decode($event->__get("domaindata"));
            switch ($event->__get("eventtype")) {
                default:
                    foreach ($data as $key => $value) {
                        $this->set($key, $value);
                    }
            }
        }
    }

}

Zerion Mini Shell 1.0