示例#1
0
 /**
  * Constructor
  *
  * @param \Munee\Request $Request
  *
  * @throws NotFoundException
  */
 public function __construct(Request $Request)
 {
     $this->request = $Request;
     // Pull in filters based on the raw params that were passed in
     $rawParams = $Request->getRawParams();
     $assetShortName = preg_replace('%^.*\\\\%', '', get_class($this));
     $allowedParams = array();
     foreach (array_keys($rawParams) as $filterName) {
         $filterClass = 'Munee\\Asset\\Filter\\' . $assetShortName . '\\' . ucfirst($filterName);
         if (class_exists($filterClass)) {
             $Filter = new $filterClass();
             $allowedParams += $Filter->getAllowedParams();
             $this->filters[$filterName] = $Filter;
         }
     }
     // Parse the raw params based on a map of allowedParams for those filters
     $this->request->parseParams($allowedParams);
     $this->cacheDir = MUNEE_CACHE . DS . $assetShortName;
     $optionsKey = strtolower($assetShortName);
     // Set the AssetType options if someone were passed in through the Request Class
     if (isset($this->request->options[$optionsKey])) {
         $this->options = array_merge($this->options, $this->request->options[$optionsKey]);
     }
     // Create cache dir if needed
     Utils::createDir($this->cacheDir);
 }
示例#2
0
 /**
  * Make sure the param validation is working properly
  */
 public function testWrongParamValue()
 {
     $_GET = array('files' => '/js/foo.js', 'foo' => 'not good');
     $Request = new Request();
     $Request->init();
     $allowedParams = array('foo' => array('alias' => 'f', 'regex' => 'true|false', 'default' => 'false', 'cast' => 'boolean'));
     $this->setExpectedException('Munee\\ErrorException');
     $Request->parseParams($allowedParams);
 }