Files
fdn2/private/lib/dao/models/StatisticModel.php
T

47 lines
1.1 KiB
PHP

<?php
/*
Author: Riccardo Di Dato
Creation Date: 27/gen/2016
*/
/**
* {user:{id, isNew}, ip, content, source, data}
* @author Riccardo Di Dato
*/
class StatisticModel extends Model {
const STAT_TYPE_PAGE = 1;
const STAT_TYPE_NOTIZIA = 2;
public static $STAT_TYPES = array(
self::STAT_TYPE_PAGE=>array("label"=>"Statistiche pagina"),
self::STAT_TYPE_NOTIZIA=>array("label"=>"Statistiche notizia")
);
public function __construct($saveableObject = null){
parent::__construct($saveableObject);
$requiredProps = array("user","content","source", "ip", "statType");
if (!$this->hasProperty("date")){
$this->date = new MongoDate();
}
foreach ($requiredProps as $prop){
if (!$this->hasProperty($prop)){
throw new CoreException("Missing parameter '$prop' while calling ".get_called_class()."::__construct()");
}
}
if (!array_key_exists($this->statType, self::$STAT_TYPES)){
throw new CoreException("Invalid statistic type '".$this->statType."' while calling ".get_called_class()."::__construct()");
}
}
public static function getCollectionName(){
return "statistics";
}
}
?>