本文整理汇总了PHP中AgaviRequestDataHolder::getParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP AgaviRequestDataHolder::getParameter方法的具体用法?PHP AgaviRequestDataHolder::getParameter怎么用?PHP AgaviRequestDataHolder::getParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AgaviRequestDataHolder
的用法示例。
在下文中一共展示了AgaviRequestDataHolder::getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeConsole
public function executeConsole(AgaviRequestDataHolder $request_data)
{
$migration_description = $request_data->getParameter('description');
$migration_timestamp = date('YmdHis');
$migration_slug = StringToolkit::asSnakeCase(trim($request_data->getParameter('name', 'default')));
$migration_name = StringToolkit::asStudlyCaps($migration_slug);
$migration_dir = $this->getAttribute('migration_dir');
// Bit of a hack to build namespace
if (!preg_match('#.+/app/(?:modules|migration)/(\\w+_?)(?:$|/.+)#', $migration_dir, $matches)) {
throw new RuntimeError(sprintf('Could not find namespace info in path %s', $migration_dir));
}
$namespace_parts = explode('_', $matches[1]);
if (count($namespace_parts) == 1) {
// @todo app migration - introduce a project root namespace setting
$namespace_parts = ['Your', 'Application'];
}
// And a hack to determine the technology namespace
$target = $request_data->getParameter('target');
if (strpos($target, 'event_source')) {
$technology = 'CouchDb';
} elseif (strpos($target, 'view_store')) {
$technology = 'Elasticsearch';
} else {
$technology = 'RabbitMq';
}
$migration_filepath = sprintf('%1$s%2$s%3$s_%4$s%2$s%4$s.php', $migration_dir, DIRECTORY_SEPARATOR, $migration_timestamp, $migration_slug);
$twig_renderer = TwigRenderer::create(['template_paths' => [__DIR__]]);
$twig_renderer->renderToFile($technology . 'Migration.tpl.twig', $migration_filepath, ['name' => $migration_name, 'timestamp' => $migration_timestamp, 'description' => $migration_description, 'folder' => $migration_dir, 'filepath' => $migration_filepath, 'vendor_prefix' => $namespace_parts[0], 'package_prefix' => $namespace_parts[1], 'technology' => $technology, 'project_prefix' => AgaviConfig::get('core.project_prefix')]);
return $this->cliMessage('-> migration template was created here:' . PHP_EOL . $migration_filepath . PHP_EOL);
}
示例2: createDOM
protected function createDOM(AgaviRequestDataHolder $rd)
{
$results = $rd->getParameter("searchResult", null);
$count = $rd->getParameter("searchCount");
$DOM = new DOMDocument("1.0", "UTF-8");
$root = $DOM->createElement("results");
$DOM->appendChild($root);
foreach ($results as $result) {
$resultNode = $DOM->createElement("result");
$root->appendChild($resultNode);
foreach ($result as $fieldname => $field) {
$node = $DOM->createElement("column");
$node->nodeValue = $field;
$name = $DOM->createAttribute("name");
$name->nodeValue = $fieldname;
$node->appendChild($name);
$resultNode->appendChild($node);
}
}
if ($count) {
$count = array_values($count[0]);
$node = $DOM->createElement("total");
$node->nodeValue = $count[0];
$root->appendChild($node);
}
return $DOM;
}
示例3: executeWrite
public function executeWrite(AgaviRequestDataHolder $rd)
{
if (!$this->context->getUser()->isAuthenticated() || !$this->context->getUser()->hasCredential('icinga.user')) {
return array('Api', 'GenericError');
}
if ($this->context->getUser()->getNsmUser()->getTarget('IcingaCommandRo')) {
$errors = array('Commands are disabled for this user');
$this->getContainer()->setAttributeByRef('errors', $errors, 'org.icinga.api.auth');
$this->getContainer()->setAttribute('success', false, 'org.icinga.api.auth');
return array('Api', 'GenericError');
}
$command = $rd->getParameter("command");
$targets = json_decode($rd->getParameter("target"), true);
$data = json_decode($rd->getParameter("data"), true);
if (!is_array($data)) {
$this->setAttribute('error', 'Parameter data={} could not decoded from json');
return 'Error';
}
if (!is_array($targets)) {
$targets = array($targets);
}
$api = $this->getContext()->getModel("System.CommandSender", "Cronks");
$api->setCommandName($command);
$api->setData($data);
$api->setSelection($targets);
// send it
try {
$api->dispatchCommands();
$this->setAttribute("success", true);
} catch (Exception $e) {
$this->setAttribute("error", $e->getMessage());
return 'Error';
}
return 'Success';
}
示例4: executeHtml
public function executeHtml(AgaviRequestDataHolder $rd)
{
$customViewFields = array("cr_base" => false, "sortField" => false, "sortDir" => false, "groupField" => false, "groupDir" => false, "template" => false, "crname" => false, "filter" => false, "title" => false);
$requiredViewFields = array("template", "crname", "title");
$rd->setParameter("isURLView", true);
foreach ($customViewFields as $name => $val) {
$val = $rd->getParameter($name, null);
if ($val == null) {
if (in_array($name, $requiredViewFields)) {
$rd->setParameter("isURLView", false);
break;
} else {
unset($customViewFields[$name]);
}
} else {
$customViewFields[$name] = $val;
}
}
if ($rd->getParameter("isURLView")) {
if (isset($customViewFields["cr_base"]) and trim($customViewFields["cr_base"]) !== "") {
$this->formatFields($customViewFields);
}
$rd->setParameter("URLData", json_encode($customViewFields));
}
$this->setupHtml($rd);
$this->setAttribute('_title', 'Icinga.Cronks.CronkPortal');
}
示例5: executeJson
public function executeJson(AgaviRequestDataHolder $rd)
{
$factory = $this->getContext()->getModel('JasperSoapFactory', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig')));
$client = $factory->getSoapClientForWSDL(Reporting_JasperSoapFactoryModel::SERVICE_REPOSITORY);
$parameters = $this->getContext()->getModel('JasperParameterStruct', 'Reporting', array('client' => $client, 'uri' => $rd->getParameter('uri'), 'filter' => 'inputControl'));
return json_encode($parameters->getJsonStructure());
}
示例6: executeConsole
public function executeConsole(\AgaviRequestDataHolder $request_data)
{
$report = $this->getAttribute('report');
if ($request_data->getParameter('silent', false)) {
return;
}
$message = 'The following items were compiled:' . PHP_EOL . PHP_EOL;
foreach ($report as $directory => $data) {
$message .= '- ' . $data['name'] . PHP_EOL;
if ($request_data->getParameter('verbose', false)) {
$message .= 'Command: ' . $data['cmd'] . PHP_EOL;
if (!empty($data['stdout'])) {
$message .= 'STDOUT: ' . PHP_EOL . $data['stdout'] . PHP_EOL;
}
if (!empty($data['stderr'])) {
$message .= 'STDERR: ' . PHP_EOL . $data['stderr'] . PHP_EOL;
}
if (empty($data['stdout']) && empty($data['stderr'])) {
$message .= PHP_EOL;
}
if (!empty($data['autoprefixer']['stdout'])) {
$message .= 'Autoprefixer STDOUT: ' . PHP_EOL . $data['autoprefixer']['stdout'];
}
if (!empty($data['autoprefixer']['stderr'])) {
$message .= 'Autoprefixer STDERR: ' . PHP_EOL . $data['autoprefixer']['stderr'];
}
if (empty($data['autoprefixer']['autoprefixer']['stdout']) && empty($data['autoprefixer']['stderr'])) {
$message .= PHP_EOL;
}
}
}
return $message . PHP_EOL;
}
示例7: executeWrite
public function executeWrite(\AgaviRequestDataHolder $request_data)
{
$report = array();
try {
$style = $request_data->getParameter('style', AgaviConfig::get('sass.style', 'compressed'));
$themes = $request_data->getParameter('themes', []);
$packer = new AssetCompiler();
// just in case
$packer->symlinkModuleAssets();
if (empty($themes)) {
$compilation_succeeded = $packer->compileThemes($style, $report);
} else {
foreach ($themes as $theme) {
$compilation_succeeded = $packer->compileTheme($theme, $style, $report);
}
}
$compilation_succeeded &= $packer->compileModuleStyles($style, $report);
$this->setAttribute('report', $report);
} catch (\Exception $e) {
$this->setAttribute('error', $e->getMessage());
return 'Error';
}
if (!$compilation_succeeded) {
return 'Error';
}
return 'Success';
}
示例8: executeWrite
public function executeWrite(AgaviRequestDataHolder $rd)
{
$username = $rd->getParameter('username');
$password = $rd->getParameter('password');
$do = $rd->getParameter('dologin');
$this->setAttribute('authenticated', false);
$this->setAttribute('executed', false);
if ($do) {
$this->setAttribute('executed', true);
$user = $this->getContext()->getUser();
try {
$user->doLogin($username, $password);
/*
* Behaviour for blocking whole access if no icinga access
*/
//if(!$user->hasCredential("icinga.user")) {
// $user->doLogout();
// $this->setAttribute('authenticated', false);
//}
$this->setAttribute('authenticated', true);
} catch (AgaviSecurityException $e) {
$this->setAttribute('authenticated', false);
}
}
return $this->getDefaultViewName();
}
示例9: executeHtml
public function executeHtml(AgaviRequestDataHolder $rd)
{
$this->setAttribute('title', 'Icinga.CronkLoader');
$tm = $this->getContext()->getTranslationManager();
try {
$model = $this->getContext()->getModel('Provider.CronksData', 'Cronks');
$crname = $rd->getParameter('cronk');
/*
* Allow external initialization of cronk stubs
*/
$parameters = $rd->getParameter('p', array());
if ($model->hasCronk($crname)) {
$cronk = $model->getCronk($crname);
if (array_key_exists('ae:parameter', $cronk) && is_array($cronk['ae:parameter'])) {
$cronk['ae:parameter'] = $this->rebuildComplexData($cronk['ae:parameter']);
$parameters = (array) $cronk['ae:parameter'] + $parameters + array('module' => $cronk['module'], 'action' => $cronk['action']);
}
if (array_key_exists('state', $cronk) && isset($cronk['state'])) {
$parameters['state'] = $cronk['state'];
}
return $this->createForwardContainer($cronk['module'], $cronk['action'], $parameters, 'simple', 'write');
} else {
return $tm->_('Sorry, cronk "%s" not found', null, null, array($crname));
}
} catch (Exception $e) {
return $tm->_('Exception thrown: %s', null, null, array($e->getMessage()));
}
return 'Some strange error occured';
}
示例10: executeWrite
public function executeWrite(\AgaviRequestDataHolder $request_data)
{
$report = array();
$success = false;
try {
$optimize_style = $request_data->getParameter('optimize', AgaviConfig::get('requirejs.optimize_style', 'uglify2'));
$buildfile_path = $request_data->getParameter('buildfile', AgaviConfig::get('requirejs.buildfile_path', AgaviConfig::get('core.pub_dir') . "/static/buildconfig.js"));
$packer = new AssetCompiler();
// just in case
$packer->symlinkModuleAssets();
// render buildconfig.js and put it into the target location for compilation
$template_service = new ModuleTemplateRenderer();
$buildconfig_content = $template_service->render('rjs/buildconfig.js');
$success = file_put_contents($buildfile_path, $buildconfig_content, LOCK_EX);
if (!$success) {
$this->setAttribute('error', 'Could not write file: ' . $buildfile_path);
}
$success = $packer->compileJs($buildfile_path, $optimize_style, $report);
$this->setAttribute('report', $report);
} catch (\Exception $e) {
$this->setAttribute('error', $e->getMessage());
return 'Error';
}
if (!$success) {
return 'Error';
}
return 'Success';
}
示例11: authenticate
/**
* Tries to authenticate the user with the given request data.
*
* @param AgaviRequestDataHolder $request_data
*
* @return string name of agavi view to select
*/
protected function authenticate(AgaviRequestDataHolder $request_data)
{
$vm = $this->getContainer()->getValidationManager();
$tm = $this->getContext()->getTranslationManager();
$user = $this->getContext()->getUser();
$username = $request_data->getParameter('username');
$password = $request_data->getParameter('password');
$service_locator = $this->getContext()->getServiceLocator();
$authentication_service = $service_locator->getAuthenticationService();
$auth_response = $authentication_service->authenticate($username, $password);
$log_message = sprintf("username='%s' message='%s' auth_provider='%s' errors=''", $username, $auth_response->getMessage(), get_class($authentication_service), join(';', $auth_response->getErrors()));
if ($auth_response->getState() === AuthResponse::STATE_AUTHORIZED) {
$view_name = 'Success';
$user->setAttributes(array_merge(['acl_role' => AclService::ROLE_NON_PRIV], $auth_response->getAttributes()));
$user->setAuthenticated(true);
$this->logInfo('[AUTHORIZED] ' . $log_message);
} elseif ($auth_response->getState() === AuthResponse::STATE_UNAUTHORIZED) {
$view_name = 'Error';
$user->setAuthenticated(false);
$vm->addArgumentResult(new \AgaviValidationArgument('username'), AgaviValidator::ERROR);
$vm->addArgumentResult(new \AgaviValidationArgument('password'), AgaviValidator::ERROR);
$vm->setError('invalid_login', $tm->_('invalid_login', 'honeybee.system_account.user.errors'));
$this->logError('[UNAUTHORIZED] ' . $log_message);
} else {
$view_name = 'Error';
$user->setAuthenticated(false);
$this->setAttribute('errors', ['auth' => $auth_response->getMessage()]);
$vm->setError('invalid_login', $tm->_('invalid_login', 'honeybee.system_account.user.errors'));
$this->logError("[ERROR] state='" . $auth_response->getState() . "' " . $log_message);
}
return $view_name;
}
示例12: executeWrite
public function executeWrite(AgaviRequestDataHolder $request_data)
{
$size = $request_data->getParameter('size', 1);
$aggregate_root_type = $request_data->getParameter('type');
$fixture_service = $this->getServiceLocator()->getFixtureService();
$type_prefix = $aggregate_root_type->getPrefix();
$documents[$type_prefix] = $fixture_service->generate($type_prefix, $size);
$json = json_encode($documents, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$errors = [];
$report = [];
$success = true;
if ($request_data->hasParameter('target')) {
$target = $request_data->getParameter('target');
if (is_writable(dirname($target))) {
$success = file_put_contents($target, $json, LOCK_EX) !== false;
if (!$success) {
$errors[] = sprintf('failed to write to: %s', $target);
}
} else {
$errors[] = sprintf('target filename is not writable: %s', $target);
$success = false;
}
} else {
$this->setAttribute('data', $json);
}
$this->setAttribute('report', $report);
$this->setAttribute('size', count($documents[$type_prefix]));
if (!$success) {
$this->setAttribute('errors', $errors);
return 'Error';
}
return 'Success';
}
示例13: executeJson
public function executeJson(AgaviRequestDataHolder $rd)
{
try {
$modules = AgaviConfig::get("org.icinga.modules", array());
$fileName = $rd->getParameter('template');
$file = null;
foreach ($modules as $name => $path) {
if (file_exists($path . "/config/templates/" . $fileName . '.xml')) {
$file = AppKitFileUtil::getAlternateFilename($path . "/config/templates/", $fileName, '.xml');
}
}
if ($file === null) {
$file = AppKitFileUtil::getAlternateFilename(AgaviConfig::get('modules.cronks.xml.path.grid'), $rd->getParameter('template'), '.xml');
}
$template = new CronkGridTemplateXmlParser($file->getRealPath());
$template->parseTemplate();
$user = $this->getContext()->getUser()->getNsmUser();
$data = $template->getTemplateData();
if ($user->hasTarget('IcingaCommandRestrictions')) {
$template->removeRestrictedCommands();
}
return json_encode(array('template' => $template->getTemplateData(), 'fields' => $template->getFields(), 'keys' => $template->getFieldKeys(), 'params' => $rd->getParameters(), 'connections' => IcingaDoctrineDatabase::$icingaConnections));
} catch (AppKitFileUtilException $e) {
$msg = 'Could not find template for ' . $rd->getParameter('template');
AppKitAgaviUtil::log('Could not find template for ' . $rd->getParameter('template'), AgaviLogger::ERROR);
return $msg;
}
}
示例14: executeWrite
public function executeWrite(AgaviRequestDataHolder $rd)
{
$action = $rd->getParameter("action", null);
$instance = $rd->getParameter("instance", null);
$this->setAttribute("write", true);
if ($instance == null) {
$this->setAttribute("errorMsg", "Invalid request");
return "Success";
}
$icinga = $this->getContext()->getModel("IcingaControlTask", "Api", array("host" => $instance));
try {
switch ($action) {
case 'restart':
$icinga->restartIcinga();
return "Success";
break;
case 'shutdown':
$icinga->stopIcinga();
return "Success";
break;
default:
$this->setAttribute("errorMsg", "Invalid action");
return "Success";
}
} catch (Exception $e) {
$this->setAttribute("errorMsg", $e->getMessage());
return "Success";
}
}
示例15: executeConsole
public function executeConsole(AgaviRequestDataHolder $request_data)
{
$message = sprintf('-> failure generating code for skeleton "%s"', $request_data->getParameter('skeleton'));
if (!$request_data->getParameter('quiet')) {
$message .= PHP_EOL . ' - ' . $this->getAttribute('errors');
}
return $this->cliError($message);
}