本文整理汇总了PHP中AgaviRequestDataHolder::getParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP AgaviRequestDataHolder::getParameters方法的具体用法?PHP AgaviRequestDataHolder::getParameters怎么用?PHP AgaviRequestDataHolder::getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AgaviRequestDataHolder
的用法示例。
在下文中一共展示了AgaviRequestDataHolder::getParameters方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: executeWrite
public function executeWrite(AgaviRequestDataHolder $request_data)
{
$parameters = $request_data->getParameters();
$skeleton_name = $request_data->getParameter('skeleton');
$target_path = $request_data->getParameter('target_path');
$type_name = $request_data->getParameter('type');
// in case of missing custom skeleton validation and missing CLI option, we need to use a default generator
$skeleton_generator = $request_data->getParameter('skeleton_generator', self::DEFAULT_SKELETON_GENERATOR);
$parameters['skeleton_generator'] = $skeleton_generator;
$parameters['reporting_enabled'] = !$request_data->getParameter('quiet');
try {
$report = [];
$report[] = 'Generating skeleton "' . $skeleton_name . '" using generator "' . $skeleton_generator . '".';
$report[] = 'Generator parameters used are: ';
$report[] = StringToolkit::getAsString($parameters, true);
$report[] = '';
$generator = new $skeleton_generator($skeleton_name, $target_path, $parameters);
$generator->generate();
$this->setAttribute('report', array_merge($report, $generator->getReport()));
} catch (Exception $e) {
$this->setAttribute('errors', $e->getMessage() . PHP_EOL);
return 'Error';
}
return 'Success';
}
示例3: executeRead
public function executeRead(AgaviRequestDataHolder $rd)
{
$filter = $this->getContext()->getModel("SLA.SLAFilter", "Api");
$params = $rd->getParameters();
foreach ($params as $name => $value) {
switch ($name) {
case 'starttime':
$filter->setStartTime($value);
break;
case 'endtime':
$filter->setEndTime($value);
break;
case 'hostsonly':
$filter->useOnlyHosts();
break;
case 'timespan':
$filter->setTimespan($value);
break;
case 'servicesonly':
$filter->useOnlyServices();
break;
case 'instanceIds':
$filter->setInstanceIds($value);
break;
case 'hostnames':
$filter->setHostnamePattern($value);
break;
case 'servicenames':
$filter->setServicenamePattern($value);
break;
case 'hostgroups':
$filter->setHostgroupnames($value);
break;
case 'servicegroups':
$filter->setServicegroupnames($value);
break;
case 'ids':
$filter->setObjectId($value);
break;
}
}
$this->addPrincipalsToFilter($filter);
$stmt = IcingaSlahistoryTable::getSummary(null, $filter);
$this->setAttribute("result", $stmt);
return "Success";
}
示例4: executeWrite
public function executeWrite(AgaviRequestDataHolder $rd)
{
$params = $rd->getParameters();
foreach ($params as $key => $param) {
if (!is_string($param)) {
continue;
}
$json = json_decode($param, true);
if ($json) {
$rd->setParameter($key, $json);
}
}
$model = $this->getDataStoreForTarget($params["target"], $rd);
if (!$model) {
return "Error";
}
$result = $model->execRead();
$r = $this->getContext()->getModel("Store.DataStoreResult", "Api", array("model" => $model));
$r->parseResult($result, $rd->getParameter("fields", array()));
$this->setAttribute("result", $r);
return $this->getDefaultViewName();
}
示例5: updateUserData
/**
* Updates the 'simple' userdata
* @param NsmUser $user
* @param AgaviRequestDataHolder $rd
* @return boolean
* @author Marius Hein
*/
public function updateUserData(NsmUser &$user, AgaviRequestDataHolder &$rd)
{
AppKitDoctrineUtil::updateRecordsetFromArray($user, $rd->getParameters(), self::$editableAttributes);
if (!$user->get("user_password")) {
$user->set("user_password", AppKitRandomUtil::initRand());
$user->set("user_salt", AppKitRandomUtil::initRand());
}
// Check the principal. Because we have nothing
// in some situations #3992
//
// Create one of missed here
if (!$user->principalIsValid()) {
$principal = new NsmPrincipal();
$principal->principal_type = NsmPrincipal::TYPE_USER;
$user->principal = $principal;
}
// Manually because we want write empty strings
$user->set('user_description', $rd->getParameter('user_description', new Doctrine_Null()));
$user->save();
return true;
}
示例6: mergeParameters
/**
* Merge in parameters from another request data holder.
*
* @param AgaviRequestDataHolder The other request data holder.
*
* @author David Zülke <dz@bitxtender.com>
* @since 0.11.0
*/
public function mergeParameters(AgaviRequestDataHolder $other)
{
$this->setParameters($other->getParameters());
}
示例7: updateRoleData
/**
* Updates the simple role data
* @param NsmRole $role
* @param AgaviRequestDataHolder $rd
* @return boolean
* @author Marius Hein
*/
public function updateRoleData(NsmRole &$role, AgaviRequestDataHolder &$rd)
{
AppKitDoctrineUtil::updateRecordsetFromArray($role, $rd->getParameters(), self::$editableAttributes);
// Checking the principal
if (!$role->NsmPrincipal->principal_id) {
$role->NsmPrincipal->principal_type = NsmPrincipal::TYPE_ROLE;
}
if ($role->role_id === null) {
// insert a new role
$role->save();
} else {
// update role
$parts = array();
$params = array();
foreach ($role as $property => $value) {
if ($property == "role_id" || !in_array($property, self::$editableAttributes)) {
continue;
}
if ($value === null) {
$parts[] = "{$property} = NULL";
} else {
$parts[] = "{$property} = ? ";
$params[] = $value;
}
}
$params[] = $role->role_id;
$dql = "UPDATE NsmRole SET " . implode(",", $parts) . " WHERE role_id = ?";
AppKitLogger::warn("Test: %s - %s", $dql, var_export($params, true));
$query = new Doctrine_Query();
$query->setConnection(AppKitDoctrineUtil::getConnection());
$query->parseDqlQuery($dql);
$query->execute($params);
}
return true;
}