1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
<?php
/*
* This file is part of the ICanBoogie package.
*
* (c) Olivier Laviale <olivier.laviale@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ICanBoogie\Facets;
use ICanBoogie\ActiveRecord\Query;
/**
* Interface for an active record fetcher that supports external conditions.
*/
interface FetcherInterface
{
/**
* Alter the {@link CriterionList} instance usually provided during construct.
*
* @param CriterionList $criterion_list
*/
public function alter_criterion_list(CriterionList $criterion_list);
/**
* Alter the conditions with the specified modifiers.
*
* A {@link CriterionList} instance is usually used to alter the conditions.
*
* @param array $conditions The conditions to alter, usually initialized
* @param array $modifiers
*
* @return array The altered conditions.
*/
public function alter_conditions(array &$conditions, array $modifiers);
/**
* Parse the query string.
*
* The query string is usually specified by the `q` condition.
*
* The conditions extracted from the query string are merged in the conditions.
*
* A {@link CriterionList} instance is usually used to parse the query string.
*
* @param QueryString $q
*/
public function parse_query_string($q);
/**
* Alter the initial query.
*
* A {@link CriterionList} instance is usually used to alter the initial query.
*
* @param Query $query
*
* @return Query The altered initial query.
*/
public function alter_query(Query $query);
/**
* Alter the query with conditions.
*
* A {@link CriterionList} instance is usually used to alter the query with conditions.
*
* @param Query $query
* @param array $conditions
*
* @return Query The altered query.
*/
public function alter_query_with_conditions(Query $query, array $conditions);
/**
* Alter the query with an order.
*
* A {@link CriterionList} instance is usually used to alter the query with an order.
*
* @param Query $query
* @param string $criterion_id
* @param int $order_direction
*
* @return Query The altered query.
*/
public function alter_query_with_order(Query $query, $criterion_id, $order_direction = 1);
/**
* Counts the number of records that are matching the query.
*
* The method is invoked before the query is altered with a limit, thus the number returned
* is the total number of records matching the query.
*
* @param Query $query
*
* @return int
*/
public function count_records(Query $query);
/**
* Alter the query with an offset and limit.
*
* @param Query $query
* @param int $offset
* @param int $limit
*
* @return Query The altered query.
*/
public function alter_query_with_limit(Query $query, $offset, $limit);
/**
* Fetch the records matching the query.
*
* @param Query $query
*
* @return array
*/
public function fetch_records(Query $query);
/**
* Alter the fetched records.
*
* A {@link CriterionList} instance is usually used to alter the records.
*
* @param array $records
*/
public function alter_records(array &$records);
}