コード例 #1
0
 private function _renderSearchContextParameter($context)
 {
     if (!SearchParameterService::isKnownContext($context)) {
         throw SearchWidgetException::unknownContext($context);
     }
     return '<input type="hidden" name="' . SearchParameterService::PARAMETER_KEY_CONTEXT . '" value="' . $context . '" />';
 }
コード例 #2
0
 /**
  * Convert request parameters to SearchParameterBag
  * 
  * @param array $requestParameters
  * @return SearchParameterBag
  */
 public function getParameterBag(Request $request)
 {
     $context = $request->get(self::PARAMETER_KEY_CONTEXT, 0);
     $parameterBag = null;
     switch ($context) {
         case self::CONTEXT_BROAD_SEARCH:
             $parameterBag = new BroadSearchParameterBag($request->get('broadSearch', array()));
             break;
         case self::CONTEXT_NARROW_SEARCH:
             $parameterBag = new NarrowSearchParameterBag($request->get('narrowSearch', array()));
             break;
         default:
             throw SearchWidgetException::unknownContext($context);
             // unknown context
     }
     return $parameterBag;
 }