Based on the discussion you'll need to implement a fetch
function similar like Craft does it with the ElementCriteriaModel
/ ElementQuery
. So you'll return some kind of search object until you execute the .find()
/fetch()
(or whatever you like to call it) function
class ClassName{
/** @var array $_searchObjects */
private $_searchObjects;
/**
* @param $something
*
* @return $this
*/
public function exampleFunction($something){
$this->_searchObjects = ['test', 'insert', 'your', 'array', 'here'];
return $this;
}
/**
* @param $string
*
* @return $this
*/
public function hide($string){
// filter your elements
$this->_searchObjects = ...//
return $this;
}
/**
* @return array
*/
public function find(){
return $this->_searchObjects;
}
}
You can then use it like
{% set elements = craft.plugin.exampleFunction.find() %}
{% set filterElements = craft.plugin.exampleFunction.hide('something').find() %}
exampleFunction
return? It should be an object with the functionhide
in it