本文整理汇总了PHP中Zend\Stdlib\Parameters::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Parameters::get方法的具体用法?PHP Parameters::get怎么用?PHP Parameters::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Stdlib\Parameters
的用法示例。
在下文中一共展示了Parameters::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSuggestions
/**
* getSuggestions
*
* This returns an array of suggestions based on current request parameters.
* This logic is present in the factory class so that it can be easily shared
* by multiple AJAX handlers.
*
* @param \Zend\Stdlib\Parameters $request The user request
* @param string $typeParam Request parameter containing search
* type
* @param string $queryParam Request parameter containing query
* string
*
* @return array
*/
public function getSuggestions($request, $typeParam = 'type', $queryParam = 'q')
{
// Process incoming parameters:
$type = $request->get($typeParam, '');
$query = $request->get($queryParam, '');
// get Autocomplete_Type config
$searcher = $request->get('searcher', 'Solr');
$options = $this->getServiceLocator()->get('SearchManager')->setSearchClassId($searcher)->getOptionsInstance();
$config = ConfigReader::getConfig($options->getSearchIni());
$types = isset($config->Autocomplete_Types) ? $config->Autocomplete_Types->toArray() : array();
// Figure out which handler to use:
if (!empty($type) && isset($types[$type])) {
$module = $types[$type];
} else {
if (isset($config->Autocomplete->default_handler)) {
$module = $config->Autocomplete->default_handler;
} else {
$module = false;
}
}
// Get suggestions:
if ($module) {
if (strpos($module, ':') === false) {
$module .= ':';
// force colon to avoid warning in explode below
}
list($name, $params) = explode(':', $module, 2);
$handler = $this->get($name);
$handler->setConfig($params);
}
return isset($handler) && is_object($handler) ? array_values($handler->getSuggestions($query)) : array();
}
示例2: initDefaults
/**
* @param Parameters $params
*
* @return Parameters
*/
protected function initDefaults(Parameters $params)
{
if (is_null($params->get('quality')) || !strlen(trim($params->get('quality')))) {
$params->set('quality', QualityInterface::QUALITY_THUMBNAIL);
}
if (is_null($params->get('source')) || !strlen(trim($params->get('source')))) {
$params->set('source', SourceNameInterface::SOURCE_USER);
}
return $params;
}
示例3: render
/**
* @param UploaderModelInterface $model
* @param null $values
* @return string
* @throws InvalidArgumentException
*/
public function render($model, $values = null)
{
if (!$model instanceof UploaderModelInterface) {
throw new InvalidArgumentException("Unsupportable type of model, required type UploaderModelInterface");
}
$resources = $model->getResourcePaths();
$url = array_pop($resources);
$funcNum = $this->params->get('CKEditorFuncNum', 0);
return "<script type='text/javascript'>\n window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . $url . "', '');\n </script>";
}
示例4: getHttpClient
/**
* @return Http\Client
*/
public function getHttpClient()
{
if (!$this->httpClient instanceof Http\Client) {
$this->httpClient = $this->getHttpClientFactory()->createHttpClient($this->options->get(self::OPT_HTTP_CLIENT, array()));
}
return $this->httpClient;
}
示例5: initSearch
/**
* Initialize the object's search settings from a request object.
*
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return void
*/
protected function initSearch($request)
{
// Convert special 'id' parameter into a standard hidden filter:
$idParam = $request->get('id', []);
if (!empty($idParam)) {
$this->addHiddenFilter('ids:' . implode("\t", $idParam));
}
}
示例6: initFilters
/**
* Add filters to the object based on values found in the request object.
*
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return void
*/
protected function initFilters($request)
{
// Special filter -- if the "id" parameter is set, limit to a specific list:
$id = $request->get('id');
if (!empty($id)) {
$this->addFilter("lists:{$id}");
}
// Otherwise use standard parent behavior:
return parent::initFilters($request);
}
示例7: getSuggestions
/**
* This returns an array of suggestions based on current request parameters.
* This logic is present in the factory class so that it can be easily shared
* by multiple AJAX handlers.
*
* @param \Zend\Stdlib\Parameters $request The user request
* @param string $typeParam Request parameter containing search
* type
* @param string $queryParam Request parameter containing query
* string
*
* @return array
*/
public function getSuggestions($request, $typeParam = 'type', $queryParam = 'q')
{
// Process incoming parameters:
$type = $request->get($typeParam, '');
$query = $request->get($queryParam, '');
$searcher = $request->get('searcher', 'Solr');
$hiddenFilters = $request->get('hiddenFilters', []);
// If we're using a combined search box, we need to override the searcher
// and type settings.
if (substr($type, 0, 7) == 'VuFind:') {
list(, $tmp) = explode(':', $type, 2);
list($searcher, $type) = explode('|', $tmp, 2);
}
// get Autocomplete_Type config
$options = $this->getServiceLocator()->get('VuFind\\SearchOptionsPluginManager')->get($searcher);
$config = $this->getServiceLocator()->get('VuFind\\Config')->get($options->getSearchIni());
$types = isset($config->Autocomplete_Types) ? $config->Autocomplete_Types->toArray() : [];
// Figure out which handler to use:
if (!empty($type) && isset($types[$type])) {
$module = $types[$type];
} else {
if (isset($config->Autocomplete->default_handler)) {
$module = $config->Autocomplete->default_handler;
} else {
$module = false;
}
}
// Get suggestions:
if ($module) {
if (strpos($module, ':') === false) {
$module .= ':';
// force colon to avoid warning in explode below
}
list($name, $params) = explode(':', $module, 2);
$handler = $this->get($name);
$handler->setConfig($params);
}
if (is_callable([$handler, 'addFilters'])) {
$handler->addFilters($hiddenFilters);
}
return isset($handler) && is_object($handler) ? array_values($handler->getSuggestions($query)) : [];
}
示例8: initBasicSearch
/**
* Support method for _initSearch() -- handle basic settings.
*
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return boolean True if search settings were found, false if not.
*/
protected function initBasicSearch($request)
{
// If no lookfor parameter was found, we have no search terms to
// add to our array!
if (is_null($lookfor = $request->get('lookfor'))) {
return false;
}
// Set the search (handler is always Author for this module):
$this->setBasicSearch($lookfor, 'Author');
return true;
}
示例9: init
/**
* init
*
* Called at the end of the Search Params objects' initFromRequest() method.
* This method is responsible for setting search parameters needed by the
* recommendation module and for reading any existing search parameters that may
* be needed.
*
* @param \VuFind\Search\Base\Params $params Search parameter object
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return void
*/
public function init($params, $request)
{
// Build a search parameters object:
$sm = $this->getSearchManager()->setSearchClassId($this->getSearchClassId());
$params = $sm->getParams();
$params->setLimit($this->limit);
$params->setBasicSearch($request->get($this->requestParam));
// Perform the search:
$this->results = $sm->setSearchClassId($this->getSearchClassId())->getResults($params);
$this->results->performAndProcessSearch();
}
示例10: sendHttpRequest
/**
* Sends the HTTP request and returns the response.
*
* @param Http\Request $httpRequest
* @throws HttpClientException
* @return Http\Response
*/
public function sendHttpRequest(Http\Request $httpRequest)
{
$this->setLastHttpRequest($httpRequest);
$this->httpClient->setOptions($this->options->get(self::OPT_HTTP_OPTIONS, array()));
try {
$httpResponse = $this->httpClient->send($httpRequest);
} catch (\Exception $e) {
throw new HttpClientException(sprintf("Exception during HTTP request: [%s] %s", get_class($e), $e->getMessage()));
}
$this->setLastHttpResponse($httpResponse);
return $httpResponse;
}
示例11: processRenewals
/**
* Process renewal requests.
*
* @param \Zend\Stdlib\Parameters $request Request object
* @param \VuFind\ILS\Connection $catalog ILS connection object
* @param array $patron Current logged in patron
*
* @return array The result of the renewal, an
* associative array keyed by item ID (empty if no renewals performed)
*/
public function processRenewals($request, $catalog, $patron)
{
// Pick IDs to renew based on which button was pressed:
$all = $request->get('renewAll');
$selected = $request->get('renewSelected');
if (!empty($all)) {
$ids = $request->get('renewAllIDS');
} else {
if (!empty($selected)) {
$ids = $request->get('renewSelectedIDS');
} else {
$ids = [];
}
}
// Retrieve the flashMessenger helper:
$flashMsg = $this->getController()->flashMessenger();
// If there is actually something to renew, attempt the renewal action:
if (is_array($ids) && !empty($ids)) {
$renewResult = $catalog->renewMyItems(['details' => $ids, 'patron' => $patron]);
if ($renewResult !== false) {
// Assign Blocks to the Template
if (isset($renewResult['blocks']) && is_array($renewResult['blocks'])) {
foreach ($renewResult['blocks'] as $block) {
$flashMsg->setNamespace('info')->addMessage($block);
}
}
// Send back result details:
return $renewResult['details'];
} else {
// System failure:
$flashMsg->setNamespace('error')->addMessage('renew_error');
}
} else {
if (!empty($all) || !empty($selected)) {
// Button was clicked but no items were selected:
$flashMsg->setNamespace('error')->addMessage('renew_empty_selection');
}
}
return [];
}
示例12: initBasicSearch
/**
* Support method for _initSearch() -- handle basic settings.
*
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return boolean True if search settings were found, false if not.
*/
protected function initBasicSearch($request)
{
// If no lookfor parameter was found, we have no search terms to
// add to our array!
if (is_null($lookfor = $request->get('author'))) {
return false;
}
// Force the search to be a phrase:
$lookfor = '"' . str_replace('"', '\\"', $lookfor) . '"';
// Set the search (handler is always Author for this module):
$this->setBasicSearch($lookfor, 'Author');
return true;
}
示例13: handleSort
public function handleSort(Manager $manager, Parameters $request, $defaultSort, $target)
{
$user = $manager->isLoggedIn();
$requestParams = $request->toArray();
if ($user) {
//in case user changed the the sort settings on the result list with a specialized UI control
//we want to serialize the new value in database
if (array_key_exists('sortControlElement', $requestParams)) {
if (array_key_exists('sort', $requestParams)) {
$sort = $requestParams['sort'];
$dbSort = unserialize($user->default_sort);
$dbSort[$target] = $requestParams['sort'];
$user->default_sort = serialize($dbSort);
$user->save();
} else {
$tSort = $request->get('sort');
$sort = !empty($tSort) ? $tSort : $defaultSort;
}
} else {
$tSort = $request->get('sort');
$sort = !empty($tSort) ? $tSort : $defaultSort;
//overwrite sort if value is set in database
if ($user->default_sort) {
$userDefaultSort = unserialize($user->default_sort);
if (isset($userDefaultSort[$target])) {
$sort = $userDefaultSort[$target];
}
}
}
} else {
$sort = $request->get('sort');
}
// Check for special parameter only relevant in RSS mode:
if ($request->get('skip_rss_sort', 'unset') != 'unset') {
$this->skipRssSort = true;
}
return $sort;
}
示例14: __invoke
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*
* @return HtmlResponse|RedirectResponse
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
try {
$album = (array) $this->albumService->getAlbum($request->getAttribute('id'));
} catch (\Exception $e) {
return new HtmlResponse($this->template->render('error::404'), 404);
}
if ($request->getMethod() === 'POST') {
$body = new Parameters($request->getParsedBody());
$del = $body->get('del', 'No');
if (strtolower($del) === 'yes') {
$this->albumService->deleteAlbum($album);
}
return new RedirectResponse($this->router->generateUri('album.index'));
}
return new HtmlResponse($this->template->render('album::delete', ['album' => $album]));
}
示例15: __invoke
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
try {
$album = $this->albumService->getAlbum($request->getAttribute('id'));
if ($request->getMethod() === 'POST') {
$body = new Parameters($request->getParsedBody());
$del = $body->get('del', 'No');
if (strtolower($del) === 'yes') {
$this->albumService->deleteAlbum($album);
/**
* @var Session $session
*/
$session = $request->getAttribute('session');
$session->getSegment('App\\Album')->setFlash('flash', ['type' => 'success', 'message' => sprintf('Successfully deleted album %s (%s)', $album->getTitle(), $album->getArtist())]);
}
// Redirect to list of albums
return new RedirectResponse($this->router->generateUri('album.index'));
}
} catch (\Exception $e) {
// do something useful
}
return new HtmlResponse($this->template->render('album::delete', compact('album')));
}