filterViewable()

Admin

Administrator

filterViewable()


$items = $itemFinder->fetch()->filterViewable();

Code:
namespace XF\Mvc\Entity;
abstract class AbstractCollection

public function filterViewable()
{
        return $this->filter(function($entity)
        {
            // TODO: ideally type hint the viewable interface
            return $entity->canView();
       });
}

Ergo ein canView in Entity festlegen um fetch()->filterViewable zu nutzen.

Code:
    public function canView(&$error = null)
    {
        $visitor = XF::visitor();

        if (!$this->hasPermission('viewItem'))
        {
            return false;
        }
 
Top