public function autocomplete() {
		Configure::write('debug', 0);
		if (!$this->request->is('ajax') || !$this->request->is('post') ||
			!$this->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [];
		$query = $this->request->data('query');
		if (empty($query)) {
			$this->set(compact('data'));
			$this->set('_serialize', 'data');

			return;
		}

		$type = $this->request->data('type');
		$plugin = $this->request->data('plugin');
		$limit = $this->ConfigTheme->getAutocompleteLimitConfig();
		$data = $this->Filter->getAutocomplete($query, $type, $plugin, $limit);
		if (empty($data)) {
			$data = [];
		}

		$this->set(compact('data'));
		$this->set('_serialize', 'data');
	}