$files->filterByExtension('pdf'); isn't working :/

Permalink
I'm working on a task that requires pulling back certain files types in the file manager and making them accessible via the UI.

I am working through the documentation and need to bring back examples of files that have the extension .pdf. I'm just echoing them out to start with, but nothing is showing up. This filter is taking place in a block, which I have created and am calling the following classes in my controller:

use Concrete\Core\Block\BlockController;
use Concrete\Core\File\FileList;
use FileSet;
use Core;


For now, I will clean this up later, in my view.php:

<?php 
    $files = new \Concrete\Core\File\FileList();
    $fileList = $files->filterByExtension('pdf');
    print_r($fileList);
?>


I'm not getting any errors and as I can see, the core classes are being called properly, so not sure based on my journey through the docs, where I am going wrong. I know for fact that files in the file manager do exist as .pdf files.

Any advice would be greatly appreciated.

 
Parasek replied on at Permalink Best Answer Reply
Parasek
Your code should look something like that:

<?php
$list = new \Concrete\Core\File\FileList();
$list->filterByExtension('pdf');
$files = $list->getResults();
?>
BenSegniPH replied on at Permalink Reply
thanks, this is bringing back an array when echoed out, so I'm moving again. Thanks very much!