本文整理汇总了PHP中Zend\Stdlib\Parameters类的典型用法代码示例。如果您正苦于以下问题:PHP Parameters类的具体用法?PHP Parameters怎么用?PHP Parameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createQuery
/**
* @param Parameters $params
* @param Builder $queryBuilder
*
* @return Builder
*/
public function createQuery($params, $queryBuilder)
{
$this->value = $params->toArray();
/*
* search jobs by keywords
*/
if (isset($this->value['params']['search']) && !empty($this->value['params']['search'])) {
$search = strtolower($this->value['params']['search']);
$expression = $queryBuilder->expr()->operator('$text', ['$search' => $search]);
$queryBuilder->field(null)->equals($expression->getQuery());
}
if (isset($this->value['params']['status']) && !empty($this->value['params']['status'])) {
if ($this->value['params']['status'] != 'all') {
$queryBuilder->field('status.name')->equals($this->value['params']['status']);
}
} else {
$queryBuilder->field('status.name')->equals(Status::CREATED);
}
if (isset($this->value['params']['companyId']) && !empty($this->value['params']['companyId'])) {
$queryBuilder->field('organization')->equals(new \MongoId($this->value['params']['companyId']));
}
if (isset($this->value['sort'])) {
foreach (explode(",", $this->value['sort']) as $sort) {
$queryBuilder->sort($this->filterSort($sort));
}
}
return $queryBuilder;
}
示例2: 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();
}
示例3: 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));
}
}
示例4: 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);
}
示例5: login
/**
* @param $request
* @return array|mixed|User
* @throws \Exception
*/
public function login($request)
{
$adapter = $this->getAuthPlugin()->getAuthAdapter();
$pin = $request->get('pin');
$accountId = $request->get('accountId');
if (!empty($pin)) {
$user = $this->getUserByPin($pin, $accountId);
$credentials = array('username' => $user->getUsername(), 'password' => $user->getPassword());
} else {
$credentials = array('username' => $request->get('username'), 'password' => $request->get('password'));
}
$params = new Parameters();
$params->set('identity', $credentials['username']);
$params->set('credential', $credentials['password']);
$emulatedRequest = new Request();
$emulatedRequest->setPost($params);
$result = $adapter->prepareForAuthentication($emulatedRequest);
if ($result instanceof Response) {
return $result;
}
$auth = $this->getAuthPlugin()->getAuthService()->authenticate($adapter);
if (!$auth->isValid()) {
$isRegistered = $this->isRegistered($credentials);
$accountUser = $this->getAccountUsersByParams($params);
if ($accountUser != null && !$isRegistered) {
if ($this->getAgencyIsDeleted($accountUser->getAccountId())) {
throw new \Exception(self::AGENCY_DELETED_MESSAGE);
}
return $this->createUserFromAccountUsers($accountUser);
}
$account = $this->getAccountByParams($params);
if ($account != null && !$isRegistered) {
return $this->createUserFromAccount($account);
}
if ($accountUser != null && $isRegistered) {
return $this->updateUser($accountUser);
}
$result = $auth->getMessages();
$message = "Bad request.";
if (isset($result[0])) {
$message = $result[0];
}
throw new \Exception($message);
}
$accountUser = $this->getAccountUsersByParams($params);
if ($this->getAgencyIsDeleted($accountUser->getAccountId())) {
throw new \Exception(self::AGENCY_DELETED_MESSAGE);
}
if ($this->getUserIsDeleted($credentials['username'])) {
throw new \Exception(self::USER_DELETED_MESSAGE);
}
$user = $this->getAuthPlugin()->getIdentity();
return $user;
}
示例6: 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;
}
示例7: 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();
}
示例8: testPagesActionCanBeAccessedByPost
public function testPagesActionCanBeAccessedByPost()
{
$this->routeMatch->setParam('action', 'pages');
$this->request->setMethod('POST');
$p = new Parameters();
$p->set('role_id', '1');
$this->request->setPost($p);
$result = $this->controller->dispatch($this->request);
$response = $this->controller->getResponse();
$this->assertInstanceOf('Zend\\Http\\Response', $result);
$this->assertEquals(302, $response->getStatusCode());
}
示例9: 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;
}
示例10: testRunActionWithParams
public function testRunActionWithParams()
{
$params = array('strict' => true, 'verbose' => true, 'debug' => true);
$runner = $this->getMockForAbstractClass('HumusPHPUnitModule\\RunnerInterface');
$runner->expects($this->once())->method('setParams')->with($params);
$runner->expects($this->once())->method('run');
$params = new Parameters();
$params->set('strict', true);
$params->set('verbose', true);
$params->set('debug', true);
$this->request->setParams($params);
$this->controller->setRunner($runner);
$response = new Response();
$this->controller->dispatch($this->request, $response);
}
示例11: __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]));
}
示例12: 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;
}
示例13: 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)) : [];
}
示例14: testWithProjectPathSet
/**
* Test with project path set
*/
public function testWithProjectPathSet()
{
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_working_path_mandatory'));
$this->parameters->set('workingPath', '/path/to/project/');
$task = new ProjectPathMandatory();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
示例15: 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>";
}