本文整理汇总了PHP中sfRequest::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP sfRequest::getMethod方法的具体用法?PHP sfRequest::getMethod怎么用?PHP sfRequest::getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfRequest
的用法示例。
在下文中一共展示了sfRequest::getMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute any application/business logic for this component.
*
* @param sfRequest $request The current sfRequest object
*
* @return mixed A string containing the view name associated with this action
*/
function execute($request)
{
//pas de jenkins => pas de form
if (!$this->getJenkins()->isAvailable()) {
$this->redirect('jenkins/index');
}
if (is_array($buildRequest = $request->getParameter('build'))) {
$groupRunId = isset($buildRequest['group_run_id']) ? $buildRequest['group_run_id'] : null;
} else {
$groupRunId = $request->getParameter('group_run_id');
}
$this->forward404If($groupRunId === null, 'group_run_id parameter is required');
$jenkinsGroupRun = JenkinsGroupRunPeer::retrieveByPK($groupRunId);
$this->forward404Unless($jenkinsGroupRun instanceof JenkinsGroupRun, sprintf('Can\'t create JenkinsGroupRun with id %s', $groupRunId));
$defaults = array();
if ($request->hasParameter('auto_launch')) {
$autoLaunch = $request->getParameter('auto_launch');
if ('on' === $autoLaunch) {
$defaults = array('auto_launch' => true);
}
} else {
$defaults = array('auto_launch' => true);
}
$form = new BuildForm($defaults, array('jenkins' => $this->getJenkins(), 'group_run' => $jenkinsGroupRun));
if (sfRequest::POST === $request->getMethod()) {
$form->bind($buildRequest);
if ($form->isValid()) {
$jobName = $form->getValue('job');
$autoLaunch = 'on' === $form->getValue('auto_launch');
$extraParameters = $form->getValue('parameters');
$jobParameters = array();
if (isset($extraParameters[$jobName])) {
$jobParameters = $extraParameters[$jobName];
}
//créer les builds
$run = new JenkinsRun();
$run->setJenkinsGroupRun($jenkinsGroupRun);
$run->setJobName($jobName);
$run->encodeParameters($jobParameters);
$run->setLaunched($autoLaunch);
$run->save();
//launcher les builds
if ($autoLaunch) {
$run->launch($this->getJenkins(), $jobParameters);
$run->computeJobBuildNumber($this->getJenkins(), $this->getUser());
}
$this->getUser()->setFlash('info', sprintf('Build [%s] has been added to build branch [%s]', $run->getJobName(), $jenkinsGroupRun->getLabel()));
if ($request->hasParameter('add_and_continue')) {
$urlRedirect = sprintf('jenkins/addBuild?auto_launch=%s&group_run_id=%s', $autoLaunch ? 'on' : 'off', $jenkinsGroupRun->getId());
} else {
$urlRedirect = $this->generateUrl('branch_view', $jenkinsGroupRun);
}
$this->redirect($urlRedirect);
}
}
$this->setVar('form', $form);
$this->setVar('group_run', array('label' => $jenkinsGroupRun->getLabel(), 'git_branch' => $jenkinsGroupRun->getGitBranch(), 'git_branch_slug' => $jenkinsGroupRun->getGitBranchSlug(), 'result' => $jenkinsGroupRun->getResult($this->getJenkins()), 'url' => $this->generateUrl('branch_view', $jenkinsGroupRun)));
}
示例2: execute
/**
* @param sfRequest $request The current sfRequest object
*
* @return mixed A string containing the view name associated with this action
*/
function execute($request)
{
$runs = JenkinsRunPeer::getDelayed($this->getUser());
$form = new DelayedRunForm(array(), array('runs' => $runs));
$jenkins = $this->getJenkins();
if (sfRequest::POST === $request->getMethod()) {
$form->bind($request->getParameter('delayed_run'));
if ($form->isValid()) {
$messages = array();
foreach ($form->getValue('runs') as $id => $datas) {
$run = JenkinsRunPeer::retrieveByPK($id);
if ('on' !== $datas['launch_job']) {
$run->setLaunchDelayed(null);
$run->save();
continue;
}
$launchAt = null;
if (strlen($datas['scheduled_at']) > 0) {
$launchAt = strtotime($datas['scheduled_at']);
}
if (null === $launchAt) {
$run->launchDelayed($this->getJenkins());
$messages[] = sprintf('The job [%s] in build branch has been launched', $run->getJobName(), $run->getGitBranch());
} else {
$run->setLaunchDelayed($launchAt);
$run->save();
$messages[] = sprintf('The job [%s] in build %s branch will be launched at %s ', $run->getJobName(), $run->getGitBranch(), $run->getLaunchDelayed('Y-m-d H:i'));
}
}
$this->getUser()->setFlash('info', $messages);
$this->redirect('jenkins/index');
}
}
$delayedRuns = array();
$durationFormatter = new durationFormatter();
foreach ($runs as $run) {
$groupRun = $run->getJenkinsGroupRun();
$parameters = $run->getParameters();
$build = $run->getJenkinsJob($jenkins)->getLastSuccessfulBuild($jenkins);
$lastDuration = 0;
if (null !== $build) {
$lastDuration = $build->getDuration();
}
$delayedRuns[$run->getId()] = array('group_run_label' => $groupRun->getLabel(), 'group_run_url' => $this->generateUrl('branch_view', $groupRun), 'group_run_result' => $groupRun->getResult($jenkins), 'last_duration' => $lastDuration, 'parameters' => null === $parameters ? $parameters : json_decode($run->getParameters(), true));
}
$this->setVar('form', $form);
$this->setVar('delayed_runs', $delayedRuns);
$this->setVar('duration_formatter', $durationFormatter);
}
示例3: execute
/**
*
* @param sfRequest $request The current sfRequest object
*
* @return mixed A string containing the view name associated with this action
*/
public function execute($request)
{
$profile = $this->getUser()->getProfile();
$form = new ConfigureUserProfileForm($profile);
if (sfRequest::PUT === $request->getMethod()) {
$form->bind($request->getParameter('profile'));
if ($form->isValid()) {
$form->save();
$this->getUser()->setFlash('notice', 'Your profile has been saved');
$this->redirect('user/configure');
}
}
$this->setVar('form', $form);
$this->setVar('api_enabled', Configuration::get('api_enabled', false));
$this->setVar('api_key', $profile->getApiKey());
}
示例4: execute
/**
* Execute any application/business logic for this component.
*
* @param sfRequest $request The current sfRequest object
*
* @return mixed A string containing the view name associated with this action
*/
function execute($request)
{
//pas de jenkins => pas de form
if (!$this->getJenkins()->isAvailable()) {
$this->redirect('jenkins/index');
}
$default = array('sf_guard_user_id' => $this->getUser()->getUserId());
if ($request->hasParameter('from_group_run_id')) {
//duplication de la configuration
$groupRun = JenkinsGroupRunPeer::retrieveByPK($request->getParameter('from_group_run_id'));
if (null !== $groupRun) {
$default = $groupRun->buildDefaultFormValue($this->getJenkins(), $default);
}
}
if ($request->hasParameter('branch')) {
$branch = $request->getParameter('branch');
$default['git_branch'] = $branch;
$default['label'] = $branch;
}
$form = new GroupRunForm($default, array('jenkins' => $this->getJenkins(), 'sf_guard_user_id' => $this->getUser()->getUserId()));
if (sfRequest::POST === $request->getMethod()) {
$form->bind($request->getParameter('group_run'));
if ($form->isValid()) {
$autoLaunch = 'on' === $form->getValue('auto_launch');
//création du group run
$runGroup = new JenkinsGroupRun();
$runGroup->setSfGuardUserId($this->getUser()->getUserId());
$runGroup->setDate(new DateTime());
$runGroup->setGitBranch($form->getValue('git_branch'));
$runGroup->setLabel($form->getValue('label'));
$runGroup->save();
$nbJobs = 0;
foreach ($form->getValue('builds') as $jobName => $jobInfo) {
if (!$jobInfo['job_name']) {
continue;
}
$parameters = array();
if (isset($jobInfo['parameters'])) {
$parameters = $jobInfo['parameters'];
}
//créer les builds
$run = new JenkinsRun();
$run->setJenkinsGroupRun($runGroup);
$run->setJobName($jobName);
$run->encodeParameters($parameters);
$run->setLaunched($autoLaunch);
$run->save();
$nbJobs++;
if ($autoLaunch) {
//launcher les builds
$run->launch($this->getJenkins(), $parameters);
$run->computeJobBuildNumber($this->getJenkins(), $this->getUser());
}
}
if (0 === $nbJobs) {
$this->getUser()->setFlash('info', sprintf('Build branch [%s] has been created', $runGroup->getLabel()));
} else {
$label = 1 === $nbJobs ? 'Job has ' : 'Jobs have ';
$this->getUser()->setFlash('info', $label . ($autoLaunch ? "been launched" : "been registered in delayed list"));
}
$this->redirect($this->generateUrl('branch_view', $runGroup));
}
}
$views = $this->getViews($this->getJenkins());
$defaultView = $this->getJenkins()->getPrimaryView();
$this->setVar('form', $form);
$this->setVar('view_by_jobs', $this->buildViewByJobs($this->getJenkins()));
$this->setVar('views', $views);
$this->setVar('default_active_view', null === $defaultView ? null : $defaultView->getName());
}