Download the PHP package aplia/query without Composer
On this page you can find all versions of the php package aplia/query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package query
Short Description Simplified API for doing content queries in eZ publish legacy
License MIT
Homepage https://github.com/Aplia/ezp-query
Informations about the package query
Aplia Content Query
Simplified API for doing content queries in eZ publish legacy.
Installation
Install with Composer:
Overview
It is divided in three main areas.
- pagination
- sorting
- filtering
All classes support the eZ template attribute system and can be passed directly to templates.
QuerySet
This class combines the functionality of all the other system into one easy to use interface. Once instantiated there are several methods which can be used to filter the set and return a new queryset instance.
Iterator usage
The query-set acts as an iterator and can be passed to foreach statements directly.
The query-set is lazy and will only evaluate when needed. It will also cache results so iterating a second time without changing any filters will not access the database.
Chaining and cloning
Most methods are designed to return a query-set instance upon completion to allow for chaining multiple methods.
For instance:
The query-set can also be instructed to create new clones for each change that is made to it, this means that the chaining methods will create new copies and that the original instance is kept as-is.
To explicitly create a new clone call copy()
:
List all children
Example, list all children of the root node:
List specific content class
List only articles of the root node:
List tree structure
List entire tree of a given node (node id 42):
List specific depth
List a specific depth using an operator:
Change sort order
Change sort order to alphabetical:
Creating a new sort field and sorting on that:
Use a regular sort array:
Paginate results
Use pagination and fetch specific page:
Filter on fields
Filter by fields:
Filters may also define modifiers on the field or value by using the advanced syntax from NestedFilter.
e.g. to use a modifier called first_letter
change the
attribute name to include a colon
and then the modifier
followed by another colon
and the operator. The modifier
must first be defined in filter.ini
and point to a valid
static method, see aplia/query
package for more details
on modifiers.
Example which finds all articles that starts with M
Define filters from database
Load filters from the content class:
Custom nested filters
If the default filter system is too limiting then the
custom filters may be used instead. They are nested
filters which are passed to the NestedFilter system
(aplia/query
package) which supports arbitrary
nesting of AND/OR structures with filters.
Call the addFilter
method on the query set and
pass the filters you want. Calling it multiple times
will AND the filters together.
Custom filters can be used together with normal filters.
Accessing result object
To explicitly get the result object (e.g. for templates) use result()
.
The result object contains enough information to be used in a template, for instance showing the total count, used filters and listing items.
Accessing items explicitly
The query-set acts as an iterator but if you need the item list
directly call items()
:
Control visibilty
Turn off default visibilty rules:
Only list hidden items (this turns off default rules):
Limit to main nodes
Limit result to only main nodes:
Control roles/policies
Turn off all role-based policies:
Filter based on a custom policy array:
Pagination
BaseNumPagination
defines the main interface for all pagination concrete classes.
A concrete implementation is PageNumPagination
which provides pagination based
on numeric page numbers (1 and up).
Sorting
Sorting is handled by the SortOrder
class, it provides a way to define possible
sort columns for an API and also which sort column and order has been chosen.
Filtering
...
Results
After running the query a result object is returned, it is of type Result
and contains all the results of the query, including items, total count,
page object, sort order and filters.
License
The helper library is open-sourced software licensed under the MIT license.