public function __construct() { require_once APPPATH . 'models/dto/page.php'; require_once APPPATH . 'libraries/JsonLoader.php'; $ci =& get_instance(); $ci->load->helper('url'); $ci->load->helper('directory'); $jsonLoader = new \JsonLoader(); $this->videos = array(); $fileStructure = directory_map(FCPATH . 'videos'); foreach ($fileStructure as $key => $structure) { if (is_array($structure)) { $metadata = $jsonLoader->Get(FCPATH . "videos/" . $key . "/metadata.json"); $page = new dto\Page(); $page->Name = $metadata->title; $page->Url = base_url() . $key; $page->Image = base_url() . "videos/" . $key . "/image.jpg"; $this->videos[] = $page; } } }