Ejemplo n.º 1
0
 /**
  * Lets see if we get an exception when an extension is not registered
  */
 public function testExtensionNotRegistered()
 {
     $MockRequest = new MockRequest();
     $MockRequest->ext = 'nope';
     $this->setExpectedException('Munee\\ErrorException');
     Registry::getClass($MockRequest);
 }
Ejemplo n.º 2
0
 /**
  * Process files with Munee library
  * http://mun.ee
  *
  * @param string $files
  * @param array $options Array with options for Munee class
  *
  * @return string
  */
 public function Munee($files, $options = array())
 {
     if (!defined('WEBROOT')) {
         define('WEBROOT', MODX_BASE_PATH);
     }
     if (!defined('MUNEE_CACHE')) {
         define('MUNEE_CACHE', $this->getTmpDir());
     }
     require_once $this->config['corePath'] . 'munee/vendor/autoload.php';
     try {
         $Request = new \Munee\Request($options);
         $Request->setFiles($files);
         foreach ($options as $k => $v) {
             $Request->setRawParam($k, $v);
         }
         $Request->init();
         /** @var \Munee\Asset\Type $AssetType */
         $AssetType = \Munee\Asset\Registry::getClass($Request);
         $AssetType->init();
         if (!empty($options['setHeaders'])) {
             if (isset($options['headerController']) && $options['headerController'] instanceof \Munee\Asset\HeaderSetter) {
                 $headerController = $options['headerController'];
             } else {
                 $headerController = new \Munee\Asset\HeaderSetter();
             }
             /** @var \Munee\Response $Response */
             $Response = new \Munee\Response($AssetType);
             $Response->setHeaderController($headerController);
             $Response->setHeaders(isset($options['maxAge']) ? $options['maxAge'] : 0);
         }
         return $AssetType->getContent();
     } catch (\Munee\ErrorException $e) {
         $error = $e->getMessage();
         if ($prev = $e->getPrevious()) {
             $error .= ': ' . $e->getPrevious()->getMessage();
         }
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[MinifyX] ' . $error);
         return '';
     }
 }