gist/src/Gist/Model/User.php
2016-08-22 02:31:44 +02:00

52 lines
1.3 KiB
PHP

<?php
namespace Gist\Model;
use Gist\Model\Base\User as BaseUser;
use Symfony\Component\Security\Core\User\UserInterface;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Connection\ConnectionInterface;
class User extends BaseUser implements UserInterface
{
public function eraseCredentials()
{
}
public function getRoles()
{
return explode(',', parent::getRoles());
}
public function getGists(Criteria $criteria = null, ConnectionInterface $con = null)
{
if ($criteria === null) {
$criteria = GistQuery::create()->orderById(Criteria::DESC);
}
return parent::getGists($criteria, $con);
}
public function getGistsPager($page, $options = array(), $maxPerPage = 10)
{
$query = GistQuery::create()
->filterByUser($this)
->orderByCreatedAt(Criteria::DESC);
if (!empty($options['type']) && $options['type'] !== 'all') {
$query->filterByType($options['type']);
}
if (!empty($options['cipher']) && $options['cipher'] !== 'anyway') {
$bools = array(
'yes' => true,
'no' => false,
);
$query->filterByCipher($bools[$options['cipher']]);
}
return $query->paginate($page, $maxPerPage);
}
}