Example #1
0
 protected function _process()
 {
     $path = $this->getRequest()->getPath();
     $content = null;
     $mimeType = null;
     if ($pathRaw = $this->getRender()->getLayoutPath('resource/' . $path, null, null, true, false)) {
         $file = new CM_File($pathRaw);
         if (in_array($file->getExtension(), $this->_getFiletypesForbidden())) {
             throw new CM_Exception_Nonexistent('Forbidden filetype', CM_Exception::WARN, ['path' => $path]);
         }
         $content = $file->read();
         $mimeType = $file->getMimeType();
     } elseif ($pathTpl = $this->getRender()->getLayoutPath('resource/' . $path . '.smarty', null, null, true, false)) {
         $content = $this->getRender()->fetchTemplate($pathTpl);
         $mimeType = CM_File::getMimeTypeByContent($content);
     } else {
         throw new CM_Exception_Nonexistent('Invalid filename', CM_Exception::WARN, ['path' => $path]);
     }
     $this->setHeader('Content-Type', $mimeType);
     $this->_setContent($content);
 }