initial commit
This commit is contained in:
commit
e869a1cab4
107 changed files with 9029 additions and 0 deletions
169
app/models/Data/RequestMeta.php
Normal file
169
app/models/Data/RequestMeta.php
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
namespace Model\Data;
|
||||
|
||||
use Phalcon\Mvc\Model;
|
||||
|
||||
class RequestMeta extends Model
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $callbackid;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $timestamp;
|
||||
|
||||
/**
|
||||
* Initialize method for model.
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
$this->skipAttributes(array('request_object_id'));
|
||||
$this->setSource('request_meta');
|
||||
$this->useDynamicUpdate(true);
|
||||
|
||||
// Relationships
|
||||
|
||||
$this->belongsTo('callbackid', 'Model\Data\Callback', 'id', array('alias' => 'Callback'));
|
||||
$this->hasOne('id', 'Model\Data\Request', 'id', array('alias' => 'RequestObject'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the value of field id
|
||||
*
|
||||
* @param integer $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the value of field callbackid
|
||||
*
|
||||
* @param integer $callbackid
|
||||
* @return $this
|
||||
*/
|
||||
public function setCallbackid($callbackid)
|
||||
{
|
||||
$this->callbackid = $callbackid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the value of field Timestamp
|
||||
*
|
||||
* @param string $Timestamp
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimestamp($timestamp)
|
||||
{
|
||||
$this->timestamp = $timestamp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of field id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of field callbackid
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCallbackid()
|
||||
{
|
||||
return $this->callbackid;
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
$headers = $this->getHeaders();
|
||||
|
||||
foreach($headers as $k => $v) {
|
||||
|
||||
if ($k == 'Content-Length') {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
$headers = $this->getHeaders();
|
||||
|
||||
foreach($headers as $k => $v) {
|
||||
|
||||
if ($k == 'Content-Type') {
|
||||
return substr($v, strrpos($v, '/') + 1);
|
||||
}
|
||||
}
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->getRequestObject()->getHeaders();
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->getRequestObject()->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of field Timestamp
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Callback $callback
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return \Phalcon\Paginator\AdapterInterface
|
||||
*/
|
||||
static public function getPaginator(Callback $callback, $page = 1, $limit = 30)
|
||||
{
|
||||
$builder = (new self())->getModelsManager()->createBuilder();
|
||||
|
||||
$builder->from('Model\Data\RequestMeta')
|
||||
->where('callbackid = :cid:', array('cid' => $callback->getId()))
|
||||
->orderBy('timestamp desc');
|
||||
|
||||
$paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
|
||||
'builder' => $builder,
|
||||
'page' => $page,
|
||||
'limit' => $limit
|
||||
));
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
}
|
||||
Reference in a new issue