Example #1
0
             */
            if (!isset($params['options']['request_params']['admin']) || empty($params['options']['request_params']['admin'])) {
                $params['options']['conditions']['published'] = true;
            }
            return $chain->next($self, $params, $chain);
            // NOTE: could be applying access rules here and checking against them
            //$record = $chain->next($self, $params, $chain);
            // Here would be an "afterFind" don't forget to return $record; instead of to the chain
            //var_dump($record);
        });
        // Put any desired filters here
        parent::__init();
    }
}
// Apply a filter to Minerva's Access class.
// The Access class will determine if the, already authenticated at this point, user has access to the requested location.
/*Access::applyFilter('check', function($self, $params, $chain) {
        var_dump('filter on check, applied from /libraries/minerva_gallery/models/Page.php');
	exit();
        return $chain->next($self, $params, $chain);
});*/
/* MODEL FILTERS GO HERE
 *
 * Any filters must be set down here outside the class because of the class extension by libraries.
 * If the filter was applied within __init() it would run more than once.
 *
*/
Page::applyFilter('find', function ($self, $params, $chain) {
    $params['options']['order'] = array('created' => 'desc');
    return $chain->next($self, $params, $chain);
});