2015-05-22 07:26:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Entity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Table(name="api_keys")
|
|
|
|
* @Entity
|
|
|
|
* @HasLifecycleCallbacks
|
|
|
|
*/
|
2016-05-02 08:18:32 +00:00
|
|
|
class ApiKey extends \App\Doctrine\Entity
|
2015-05-22 07:26:49 +00:00
|
|
|
{
|
2017-01-24 00:17:50 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->calls_made = 0;
|
|
|
|
$this->created = time();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @PrePersist */
|
|
|
|
public function preSave()
|
|
|
|
{
|
2017-01-24 00:35:16 +00:00
|
|
|
if (!$this->id) {
|
2017-01-24 00:17:50 +00:00
|
|
|
$this->id = sha1(mt_rand(0, microtime(true)));
|
2017-01-24 00:35:16 +00:00
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 07:26:49 +00:00
|
|
|
/**
|
|
|
|
* @Column(name="id", type="string", length=50)
|
|
|
|
* @Id
|
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/** @Column(name="owner", type="string", length=150, nullable=true) */
|
|
|
|
protected $owner;
|
|
|
|
|
|
|
|
/** @Column(name="calls_made", type="integer") */
|
|
|
|
protected $calls_made;
|
|
|
|
|
|
|
|
/** @Column(name="created", type="integer") */
|
|
|
|
protected $created;
|
|
|
|
}
|