2015-01-06 23:52:52 +01:00
|
|
|
<?php
|
|
|
|
namespace Framadate\Services;
|
|
|
|
|
2015-04-03 00:11:36 +02:00
|
|
|
use Framadate\Repositories\RepositoryFactory;
|
2015-01-06 23:52:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The class provides action for application administrators.
|
|
|
|
*
|
|
|
|
* @package Framadate\Services
|
|
|
|
*/
|
|
|
|
class SuperAdminService {
|
|
|
|
|
2015-04-03 00:11:36 +02:00
|
|
|
private $pollRepository;
|
2015-01-06 23:52:52 +01:00
|
|
|
|
2015-04-03 00:11:36 +02:00
|
|
|
function __construct() {
|
|
|
|
$this->pollRepository = RepositoryFactory::pollRepository();
|
2015-01-06 23:52:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the list of all polls.
|
|
|
|
*
|
2015-03-27 12:55:32 +01:00
|
|
|
* @param array $search Array of search : ['id'=>..., 'title'=>..., 'name'=>...]
|
|
|
|
* @param int $page The page index (O = first page)
|
|
|
|
* @param int $limit The limit size
|
|
|
|
* @return array ['polls' => The {$limit} polls, 'count' => Entries found by the query, 'total' => Total count]
|
2015-01-06 23:52:52 +01:00
|
|
|
*/
|
2015-03-27 12:55:32 +01:00
|
|
|
public function findAllPolls($search, $page, $limit) {
|
2015-03-29 12:59:47 +02:00
|
|
|
$start = $page * $limit;
|
2015-09-13 00:53:03 +02:00
|
|
|
$polls = $this->pollRepository->findAll($search, $start, $limit);
|
|
|
|
$count = $this->pollRepository->count($search);
|
2015-04-03 00:11:36 +02:00
|
|
|
$total = $this->pollRepository->count();
|
2015-03-29 12:59:47 +02:00
|
|
|
|
|
|
|
|
2015-09-13 00:53:03 +02:00
|
|
|
return ['polls' => $polls, 'count' => $count, 'total' => $total];
|
2015-01-06 23:52:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|