Skip to content

Commit dd4330d

Browse files
committed
Merge branch 'T12676-add-methods-to-interfaces' of https://github.com/niden/cphalcon into niden-T12676-add-methods-to-interfaces
* 'T12676-add-methods-to-interfaces' of https://github.com/niden/cphalcon: [#12676] - Updated the changelog [#12676] - Changes to the interfaces
2 parents 5f27851 + a80fec1 commit dd4330d

16 files changed

+416
-9
lines changed

CHANGELOG-4.0.md

+20-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@
2727
- Added `Phalcon\Paginator\RepositoryInterface` for repository the current state of `paginator` and also optional sets the aliases for properties repository [#10985](https://github.com/phalcon/cphalcon/pull/10985), [#10957](https://github.com/phalcon/cphalcon/issues/10957)
2828
- Added bind support to `Phalcon\Mvc\Model\Query\Builder`. The Query Builder has the same methods as `Phalcon\Mvc\Model\Query`; `getBindParams`, `setBindParams`, `getBindTypes` and `setBindTypes`. [#13368](https://github.com/phalcon/cphalcon/issues/13368)
2929
- Added `Phalcon\Html\Breadcrumbs`, a component that creates HTML code for breadcrumbs. [#13680](https://github.com/phalcon/cphalcon/issues/13680)
30+
- Added more methods to interfaces.
31+
- `Phalcon\Cli\Router\RouteInterface` - `delimiter`, `getDelimiter`
32+
- `Phalcon\Cli\DispatcherInterface` - `setOptions`, `getOptions`
33+
- `Phalcon\Db\AdapterInterface` - `fetchColumn`, `insertAsDict`, `updateAsDict`
34+
- `Phalcon\Db\DialectInterface` - `registerCustomFunction`, `getCustomFunctions`, `getSqlExpression`
35+
- `Phalcon\Di\ServiceInterface` - `getParameter`, `isResolved`
36+
- `Phalcon\Events\ManagerInterface` - `hasListeners`
37+
- `Phalcon\Mvc\Model\Query\BuilderInterface` - `distinct`, `getDistinct`, `forUpdate`, `offset`, `getOffset`
38+
- `Phalcon\Mvc\Model\Transaction\ManagerInterface` - `setDbService`, `getDbService`, `setRollbackPendent`, `getRollbackPendent`
39+
- `Phalcon\Mvc\Model\CriteriaInterface` - `distinct`, `leftJoin`, `innerJoin`, `rightJoin`, `groupBy`, `having`, `cache`, `getColumns`, `getGroupBy`, `getHaving`
40+
- `Phalcon\Mvc\Model\ManagerInterface` - `isVisibleModelProperty`, `keepSnapshots`, `isKeepingSnapshots`, `useDynamicUpdate`, `isUsingDynamicUpdate`, `addHasManyToMany`, `existsHasManyToMany`, `getRelationRecords`, `getHasManyToMany`, `registerNamespaceAlias`, `getNamespaceAlias`
41+
- `Phalcon\Mvc\Model\MessageInterface` - `setModel`, `getModel`, `setCode`, `getCode`
42+
- `Phalcon\Mvc\Model\QueryInterface` - `getSingleResult`, `setBindParams`, `getBindParams`, `setBindTypes`, `setSharedLock`, `getBindTypes`, `getSql`
43+
- `Phalcon\Mvc\Model\RelationInterface` - `getParams`
44+
- `Phalcon\Mvc\Model\ResultsetInterface` - `setHydrateMode`, `getHydrateMode`, `getMessages`, `update`, `delete`, `filter`
45+
- `Phalcon\Mvc\ModelInterface` - `getModelsMetaData`
46+
- `Phalcon\Session\AdapterInterface` - `setId`, `status`
47+
- `Phalcon\Validation\MessageInteraface` - `getCode`, `setCode`
48+
- `Phalcon\CryptInterface` - `setPadding`
3049
- Added `attach()` to `Phalcon\Mvc\RouterInterface`
3150
- Added `Phalcon\Container`, a proxy container class to the `Phalcon\DI` implementing PSR-11 [#12295](https://github.com/phalcon/cphalcon/issues/12295)
3251
- Added `Phalcon\Acl\Adapter\Memory::getActiveKey`, `Phalcon\Acl\Adapter\Memory::activeFunctionCustomArgumentsCount` and `Phalcon\Acl\Adapter\Memory::getActiveFunction` to get latest key, number of custom arguments, and function used to acquire access
@@ -97,12 +116,7 @@
97116
- the `Phalcon\Session\Adapter\Files` using the name `session`
98117
- the `Phalcon\Session\Bag` using the name `sessionBag`
99118
[#12921](https://github.com/phalcon/cphalcon/issues/12921)
100-
- Changed the `Phalcon\Session` namespace by refactoring the component. `Phalcon\Session\Manager` is now the single component offering session manipulation by using adapters. Each adapter implements PHP's `SessionHandlerInterface`. Available adapters are `Phalcon\Session\Files`, `Phalcon\Session\Libmemcached`, `Phalcon\Session\Noop` and `Phalcon\Session\Redis`. [#12921](https://github.com/phalcon/cphalcon/issues/12833), [11341](https://github.com/phalcon/cphalcon/issues/11341), [13535](https://github.com/phalcon/cphalcon/issues/13535)
101-
- Changed the `Phalcon\Tag` and `Phalcon\Html\Tag` to not output `type="text/javascript"` when the doctype is HTML5 [#13341](https://github.com/phalcon/cphalcon/issues/13341)
102-
- Changed `Phalcon\Http\RequestInterface::getUploadedFiles()` now returns an associative array if the second argument is passed as true
103-
- Changed the `Phalcon\Mvc\Url::get()` to correctly calculate the '/' and not produce URLs with double slashes [13495](https://github.com/phalcon/cphalcon/issues/13495)
104-
- Changed the license header for all `phalcon` files; Added same header in all tests as well as `declare(strict_types=1);` [#13684](https://github.com/phalcon/cphalcon/issues/13684)
105-
- Changed the `Phalcon\Mvc\Engine\Volt` to recognize `null` values when working with macros. [#13660](https://github.com/phalcon/cphalcon/issues/13660)
119+
- Changed the `Phalcon\Session` namespace by refactoring the component. `Phalcon\Session\Manager` is now the single component offering session manipulation by using adapters. Each adapter implements PHP's `SessionHandlerInterface`. Available adapters are `Phalcon\Session\Files`, `Phalcon\Session\Libmemcached`, `Phalcon\Session\Noop` and `Phalcon\Session\Redis`. [#12921](https://github.com/phalcon/cphalcon/issues/12833), (https://github.com/phalcon/cphalcon/issues/11341), (https://github.com/phalcon/cphalcon/issues/13535)
106120

107121
## Removed
108122
- PHP < 7.2 no longer supported

phalcon/cli/dispatcherinterface.zep

+10
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,14 @@ interface DispatcherInterface extends DispatcherInterfaceBase
5454
* Returns the active task in the dispatcher
5555
*/
5656
public function getActiveTask() -> <TaskInterface>;
57+
58+
/**
59+
* Set the options to be dispatched
60+
*/
61+
public function setOptions(array options);
62+
63+
/**
64+
* Get dispatched options
65+
*/
66+
public function getOptions() -> array;
5767
}

phalcon/cli/router/routeinterface.zep

+9
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ interface RouteInterface
6767
*/
6868
public static function reset() -> void;
6969

70+
/**
71+
* Set the routing delimiter
72+
*/
73+
public static function delimiter(string! delimiter = null);
74+
75+
/**
76+
* Get routing delimiter
77+
*/
78+
public static function getDelimiter() -> string;
7079
}

phalcon/cryptinterface.zep

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ namespace Phalcon;
1717
*/
1818
interface CryptInterface
1919
{
20+
/**
21+
* Changes the padding scheme used.
22+
*/
23+
public function setPadding(int! scheme) -> <CryptInterface>;
2024

2125
/**
2226
* Sets the cipher algorithm

phalcon/db/adapterinterface.zep

+66
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,26 @@ interface AdapterInterface
158158
*/
159159
public function fetchAll(string! sqlQuery, int fetchMode = 2, placeholders = null) -> array;
160160

161+
/**
162+
* Returns the n'th field of first row in a SQL query result
163+
*
164+
*<code>
165+
* // Getting count of robots
166+
* $robotsCount = $connection->fetchColumn("SELECT count(*) FROM robots");
167+
* print_r($robotsCount);
168+
*
169+
* // Getting name of last edited robot
170+
* $robot = $connection->fetchColumn(
171+
* "SELECT id, name FROM robots order by modified desc",
172+
* 1
173+
* );
174+
* print_r($robot);
175+
*</code>
176+
*
177+
* @param int|string column
178+
*/
179+
public function fetchColumn(string sqlQuery, array placeholders = [], var column = 0) -> string | bool;
180+
161181
/**
162182
* Returns the first row in a SQL query result
163183
*
@@ -250,6 +270,28 @@ interface AdapterInterface
250270
*/
251271
public function insert(string table, array! values, fields = null, dataTypes = null) -> bool;
252272

273+
/**
274+
* Inserts data into a table using custom RBDM SQL syntax
275+
*
276+
* <code>
277+
* // Inserting a new robot
278+
* $success = $connection->insertAsDict(
279+
* "robots",
280+
* [
281+
* "name" => "Astro Boy",
282+
* "year" => 1952,
283+
* ]
284+
* );
285+
*
286+
* // Next SQL sentence is sent to the database system
287+
* INSERT INTO `robots` (`name`, `year`) VALUES ("Astro boy", 1952);
288+
* </code>
289+
*
290+
* @param array data
291+
* @param array dataTypes
292+
*/
293+
public function insertAsDict(string table, data, var dataTypes = null) -> bool;
294+
253295
/**
254296
* Returns if nested transactions should use savepoints
255297
*/
@@ -344,6 +386,30 @@ interface AdapterInterface
344386
*/
345387
public function update(string table, fields, values, whereCondition = null, dataTypes = null) -> bool;
346388

389+
/**
390+
* Updates data on a table using custom RBDM SQL syntax
391+
* Another, more convenient syntax
392+
*
393+
* <code>
394+
* // Updating existing robot
395+
* $success = $connection->updateAsDict(
396+
* "robots",
397+
* [
398+
* "name" => "New Astro Boy",
399+
* ],
400+
* "id = 101"
401+
* );
402+
*
403+
* // Next SQL sentence is sent to the database system
404+
* UPDATE `robots` SET `name` = "Astro boy" WHERE id = 101
405+
* </code>
406+
*
407+
* @param array data
408+
* @param string whereCondition
409+
* @param array dataTypes
410+
*/
411+
public function updateAsDict(string table, var data, var whereCondition = null, var dataTypes = null) -> bool;
412+
347413
/**
348414
* Check whether the database system requires an explicit value for identity columns
349415
*/

phalcon/db/dialectinterface.zep

+14
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,18 @@ interface DialectInterface
179179
*/
180180
public function rollbackSavepoint(string! name) -> string;
181181

182+
/**
183+
* Registers custom SQL functions
184+
*/
185+
public function registerCustomFunction(string name, callable customFunction) -> <Dialect>;
186+
187+
/**
188+
* Returns registered functions
189+
*/
190+
public function getCustomFunctions() -> array;
191+
192+
/**
193+
* Transforms an intermediate representation for an expression into a database system valid expression
194+
*/
195+
public function getSqlExpression(array! expression, string escapeChar = null, bindCounts = null) -> string;
182196
}

phalcon/di/serviceinterface.zep

+12
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ interface ServiceInterface
5656
*/
5757
public function setParameter(int position, array! parameter) -> <ServiceInterface>;
5858

59+
/**
60+
* Returns a parameter in a specific position
61+
*
62+
* @return array
63+
*/
64+
public function getParameter(int position);
65+
66+
/**
67+
* Returns true if the service was resolved
68+
*/
69+
public function isResolved() -> bool;
70+
5971
/**
6072
* Restore the internal state of a service
6173
*/

phalcon/events/managerinterface.zep

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ interface ManagerInterface
4848
*/
4949
public function fire(string! eventType, source, data = null);
5050

51+
/**
52+
* Check whether certain type of event has listeners
53+
*/
54+
public function hasListeners(string! type) -> bool;
55+
5156
/**
5257
* Returns all the attached listeners of a certain type
5358
*/

phalcon/mvc/model/criteriainterface.zep

+66
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,70 @@ interface CriteriaInterface
173173
*/
174174
public function execute() -> <ResultsetInterface>;
175175

176+
/**
177+
* Sets SELECT DISTINCT / SELECT ALL flag
178+
*/
179+
public function distinct(var distinct) -> <CriteriaInterface>;
180+
181+
/**
182+
* Adds an INNER join to the query
183+
*
184+
*<code>
185+
* $criteria->innerJoin("Robots");
186+
* $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id");
187+
* $criteria->innerJoin("Robots", "r.id = RobotsParts.robots_id", "r");
188+
*</code>
189+
*/
190+
public function innerJoin(string! model, var conditions = null, var alias = null) -> <CriteriaInterface>;
191+
192+
/**
193+
* Adds a LEFT join to the query
194+
*
195+
*<code>
196+
* $criteria->leftJoin("Robots", "r.id = RobotsParts.robots_id", "r");
197+
*</code>
198+
*/
199+
public function leftJoin(string! model, var conditions = null, var alias = null) -> <CriteriaInterface>;
200+
201+
/**
202+
* Adds a RIGHT join to the query
203+
*
204+
*<code>
205+
* $criteria->rightJoin("Robots", "r.id = RobotsParts.robots_id", "r");
206+
*</code>
207+
*/
208+
public function rightJoin(string! model, conditions = null, alias = null) -> <CriteriaInterface>;
209+
210+
/**
211+
* Adds the group-by clause to the criteria
212+
*/
213+
public function groupBy(var group) -> <CriteriaInterface>;
214+
215+
/**
216+
* Adds the having clause to the criteria
217+
*/
218+
public function having(var having) -> <CriteriaInterface>;
219+
220+
/**
221+
* Sets the cache options in the criteria
222+
* This method replaces all previously set cache options
223+
*/
224+
public function cache(array! cache) -> <CriteriaInterface>;
225+
226+
/**
227+
* Returns the columns to be queried
228+
*
229+
* @return string|array|null
230+
*/
231+
public function getColumns() -> string | null;
232+
233+
/**
234+
* Returns the group clause in the criteria
235+
*/
236+
public function getGroupBy();
237+
238+
/**
239+
* Returns the having clause in the criteria
240+
*/
241+
public function getHaving();
176242
}

phalcon/mvc/model/managerinterface.zep

+70
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,74 @@ interface ManagerInterface
247247
*/
248248
public function getRelationByAlias(string! modelName, string! alias) -> <Relation> | bool;
249249

250+
/**
251+
* Check whether a model property is declared as public.
252+
*
253+
* <code>
254+
* $isPublic = $manager->isVisibleModelProperty(
255+
* new Robots(),
256+
* "name"
257+
* );
258+
* </code>
259+
*/
260+
public final function isVisibleModelProperty(<ModelInterface> model, string property) -> bool;
261+
262+
/**
263+
* Sets if a model must keep snapshots
264+
*/
265+
public function keepSnapshots(<ModelInterface> model, bool keepSnapshots) -> void;
266+
267+
/**
268+
* Checks if a model is keeping snapshots for the queried records
269+
*/
270+
public function isKeepingSnapshots(<ModelInterface> model) -> bool;
271+
272+
/**
273+
* Sets if a model must use dynamic update instead of the all-field update
274+
*/
275+
public function useDynamicUpdate(<ModelInterface> model, bool dynamicUpdate);
276+
277+
/**
278+
* Checks if a model is using dynamic update instead of all-field update
279+
*/
280+
public function isUsingDynamicUpdate(<ModelInterface> model) -> bool;
281+
282+
/**
283+
* Setups a relation n-m between two models
284+
*
285+
* @param string fields
286+
* @param string intermediateFields
287+
* @param string intermediateReferencedFields
288+
* @param string referencedFields
289+
* @param array options
290+
*/
291+
public function addHasManyToMany(<ModelInterface> model, var fields, string! intermediateModel,
292+
var intermediateFields, var intermediateReferencedFields, string! referencedModel, var referencedFields, var options = null) -> <RelationInterface>;
293+
294+
/**
295+
* Checks whether a model has a hasManyToMany relation with another model
296+
*/
297+
public function existsHasManyToMany(string! modelName, string! modelRelation) -> bool;
298+
299+
/**
300+
* Helper method to query records based on a relation definition
301+
*
302+
* @return \Phalcon\Mvc\Model\Resultset\Simple|Phalcon\Mvc\Model\Resultset\Simple|int|false
303+
*/
304+
public function getRelationRecords(<RelationInterface> relation, string! method, <ModelInterface> record, var parameters = null);
305+
306+
/**
307+
* Gets hasManyToMany relations defined on a model
308+
*/
309+
public function getHasManyToMany(<ModelInterface> model) -> <RelationInterface[]> | array;
310+
311+
/**
312+
* Registers shorter aliases for namespaces in PHQL statements
313+
*/
314+
public function registerNamespaceAlias(string alias, string namespaceName) -> void;
315+
316+
/**
317+
* Returns a real namespace from its alias
318+
*/
319+
public function getNamespaceAlias(string! alias) -> string;
250320
}

phalcon/mvc/model/query/builderinterface.zep

+30
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,34 @@ interface BuilderInterface
215215
* Returns default bind types
216216
*/
217217
public function getBindTypes() -> array;
218+
219+
/**
220+
* Sets SELECT DISTINCT / SELECT ALL flag
221+
*
222+
*<code>
223+
* $builder->distinct("status");
224+
* $builder->distinct(null);
225+
*</code>
226+
*/
227+
public function distinct(var distinct) -> <BuilderInterface>;
228+
229+
/**
230+
* Returns SELECT DISTINCT / SELECT ALL flag
231+
*/
232+
public function getDistinct() -> bool;
233+
234+
/**
235+
* Sets a FOR UPDATE clause
236+
*
237+
*<code>
238+
* $builder->forUpdate(true);
239+
*</code>
240+
*/
241+
public function forUpdate(bool forUpdate) -> <BuilderInterface>;
242+
243+
244+
/**
245+
* Returns the current OFFSET clause
246+
*/
247+
public function getOffset() -> int;
218248
}

0 commit comments

Comments
 (0)