Maslosoft Mangan API
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
<?php
/**
* This software package is licensed under AGPL or Commercial license.
*
* @package maslosoft/mangan
* @licence AGPL or Commercial
* @copyright Copyright (c) Piotr Masełkowski <pmaselkowski@gmail.com>
* @copyright Copyright (c) Maslosoft
* @copyright Copyright (c) Others as mentioned in code
* @link https://maslosoft.com/mangan/
*/
namespace Maslosoft\Mangan\Interfaces;
use Maslosoft\Mangan\Document;
/**
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
interface ScopeManagerInterface
{
/**
* Returns the declaration of named scopes.
* A named scope represents a query criteria that can be chained together with
* other named scopes and applied to a query. This method should be overridden
* by child classes to declare named scopes for the particular document classes.
* For example, the following code declares two named scopes: 'recently' and
* 'published'.
* <pre>
* return array(
* 'published'=>array(
* 'conditions'=>array(
* 'status'=>array('==', 1),
* ),
* ),
* 'recently'=>array(
* 'sort'=>array('create_time'=>Criteria::SortDesc),
* 'limit'=>5,
* ),
* );
* </pre>
* If the above scopes are declared in a 'Post' model, we can perform the following
* queries:
* <pre>
* $posts=Post::model()->published()->findAll();
* $posts=Post::model()->published()->recently()->findAll();
* $posts=Post::model()->published()->published()->recently()->find();
* </pre>
*
* @return array the scope definition. The array keys are scope names; the array
* values are the corresponding scope definitions. Each scope definition is represented
* as an array whose keys must be properties of {@link Criteria}.
* @since v1.0
*/
public function scopes();
/**
* Returns the default named scope that should be implicitly applied to all queries for this model.
* Note, default scope only applies to SELECT queries. It is ignored for INSERT, UPDATE and DELETE queries.
* The default implementation simply returns an empty array. You may override this method
* if the model needs to be queried with some default criteria (e.g. only active records should be returned).
* @return array the mongo criteria. This will be used as the parameter to the constructor
* of {@link Criteria}.
* @since v1.2.2
*/
public function defaultScope();
/**
* Resets all scopes and criteria applied including default scope.
*
* @return Document
* @since v1.0
*/
public function resetScope();
/**
* Apply scopes to criteria, will create criteria object if not provided and pass it by reference
* @param CriteriaInterface|array|null $criteria
* @return CriteriaInterface
*/
public function apply(&$criteria = null);
public function reset();
public function getNewCriteria($criteria = null);
}
API documentation generated by ApiGen