getUser($request); if (!Authority::canShowFolder($user, $folder)) { throw new AuthorizationFailedException(); } $subfolders = array_reduce( $folder->subfolders->getArrayCopy(), function ($result, $subfolder) use ($user) { $folder = $subfolder->getTypedFolder(); if (Authority::canShowFolder($user, $folder)) { $result[] = $folder; } return $result; }, [] ); list($offset, $limit) = $this->getOffsetAndLimit(); return $this->getPaginatedContentResponse( array_slice($subfolders, $offset, $limit), count($subfolders) ); } }