Frontend\Core\Engine\Base\AjaxAction::execute PHP Method

execute() public method

Execute the action
public execute ( )
    public function execute()
    {
        return $this->getContent();
    }

Usage Example

Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     // validate search term
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // previous search result
         $previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : '';
         \SpoonSession::set('searchTerm', '');
         // save this term?
         if ($previousTerm != $term) {
             // format data
             $this->statistics = array();
             $this->statistics['term'] = $term;
             $this->statistics['language'] = LANGUAGE;
             $this->statistics['time'] = FrontendModel::getUTCDate();
             $this->statistics['data'] = serialize(array('server' => $_SERVER));
             $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
             // save data
             FrontendSearchModel::save($this->statistics);
         }
         // save current search term in cookie
         \SpoonSession::set('searchTerm', $term);
         // output
         $this->output(self::OK);
     }
 }
All Usage Examples Of Frontend\Core\Engine\Base\AjaxAction::execute