本文整理汇总了PHP中sfWebRequest::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest::getMethod方法的具体用法?PHP sfWebRequest::getMethod怎么用?PHP sfWebRequest::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWebRequest
的用法示例。
在下文中一共展示了sfWebRequest::getMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executePush_endpoint
public function executePush_endpoint(sfWebRequest $request)
{
if ($request->getMethod() == sfWebRequest::GET && $request->getParameter("hub_mode") == 'subscribe' && $request->getParameter("hub_challenge", null)) {
sfContext::getInstance()->getLogger()->info("{TestPushApi} subscribed to '" . $request->getParameter("hub_topic") . "'");
$this->setLayout(false);
return $this->renderText($request->getParameter("hub_challenge"));
} elseif ($request->getMethod() == sfWebRequest::POST) {
$updates = json_decode(file_get_contents("php://input"), true);
sfContext::getInstance()->getLogger()->info("{TestPushApi} subscribed to '{$updates}'");
} else {
sfContext::getInstance()->getLogger()->err("{TestPushApi} " . print_r(file_get_contents("php://input"), true));
$this->setLayout(false);
return $this->renderText("geht net!");
}
}
示例2: executeCreate
public function executeCreate(sfWebRequest $request)
{
$this->form = new ServersForm();
if ($request->getMethod() == sfWebRequest::POST) {
$this->form->bind($request->getPostParameter($this->form->getName()));
if ($this->form->isValid()) {
if (!preg_match("!^\\d+.\\d+.\\d+.\\d+:\\d+\$!", $this->form->getValue("ip"))) {
$datas = $request->getPostParameter($this->form->getName());
$added = array();
$counter = 1;
$name = $this->form->getValue("hostname");
if (preg_match("!^(\\d+).(\\d+).(\\d+).(?<start>\\d+)\\-(?<end>\\d+):(\\d+)\$!", $this->form->getValue("ip"), $match)) {
for ($i = $match["start"]; $i <= $match["end"]; $i++) {
$ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $i . ":" . $match[6];
$datas["ip"] = $ip;
$datas["hostname"] = $name . " #" . $counter++;
$this->form = new ServersForm();
$this->form->bind($datas);
$this->form->save();
$added[] = $ip;
}
} elseif (preg_match("!^(\\d+).(\\d+).(\\d+).(?<start>\\d+)\\-(?<end>\\d+):(?<port>[0-9\\-]+)\$!", $this->form->getValue("ip"), $match)) {
$ports = explode("-", $match["port"]);
for ($i = $match["start"]; $i <= $match["end"]; $i++) {
foreach ($ports as $port) {
$ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $i . ":" . $port;
$datas["ip"] = $ip;
$datas["hostname"] = $name . " #" . $counter++;
$this->form = new ServersForm();
$this->form->bind($datas);
$this->form->save();
$added[] = $ip;
}
}
} elseif (preg_match("!^(\\d+).(\\d+).(\\d+).(\\d+):(?<port>[0-9\\-]+)\$!", $this->form->getValue("ip"), $match)) {
$ports = explode("-", $match["port"]);
foreach ($ports as $port) {
$ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $match[4] . ":" . $port;
$datas["ip"] = $ip;
$datas["hostname"] = $name . " #" . $counter++;
$this->form = new ServersForm();
$this->form->bind($datas);
$this->form->save();
$added[] = $ip;
}
} else {
$this->getUser()->setFlash("notification_error", $this->__("Unknown Server-Format"));
}
if (count($added) > 0) {
$this->getUser()->setFlash("notification_ok", count($added) . $this->__(" server were added ") . "(" . implode(", ", $added) . ")");
$this->redirect("servers_create");
}
} else {
$server = $this->form->save();
$this->getUser()->setFlash("notification_ok", $this->__("1 Server was added with IP (") . $server->getIp() . ")");
$this->redirect("servers_create");
}
}
}
}
示例3: executeNew
public function executeNew(sfWebRequest $request)
{
if ($request->getMethod() != "POST") {
return;
}
$this->username = $request->getPostParameter("username");
if (!$this->username) {
return $this->setErrorMsg("Username is a required field!");
}
$this->user = UserDAO::getUser($this->username);
if ($this->user) {
return $this->setErrorMsg("That username is already in use!");
}
$this->password1 = $request->getPostParameter("password1");
$this->password2 = $request->getPostParameter("password2");
if (!$this->password1 || !$this->password2) {
return $this->setErrorMsg("Password is a required field");
}
if ($this->password1 != $this->password2) {
return $this->setErrorMsg("Password and password confirm must match!");
}
$this->email = $request->getPostParameter("email");
$this->user = UserDAO::createUser($this->username, $this->password1, $this->email);
$this->login($this->user);
$this->redirect("dashboard/index");
}
示例4: executeSelectorNodeForm
public function executeSelectorNodeForm(sfWebRequest $request)
{
$versionId = $request->getParameter("ei_version_id") ? $request->getParameter("ei_version_id") : $this->ei_version_id;
/** @var EiVersion $version */
$version = Doctrine_Core::getTable("EiVersion")->find($versionId);
$tree = null;
$selected = null;
if ($request->getMethod() === "POST") {
$blockForeach = $request->getPostParameter("ei_block_foreach");
if ($blockForeach != null && isset($blockForeach["Iterator"]["ei_dataset_structure_id"])) {
$selected = $blockForeach["Iterator"]["ei_dataset_structure_id"];
}
} elseif (isset($this->block) && $this->block instanceof EiBlockForeach) {
$selected = $this->block->getIteratorMapping()->getEiDataSetStructureMapping()->getId();
}
if ($version != null && $version->getId() != "") {
/** @var EiDataSetStructureTable $tableStructure */
$tableStructure = Doctrine_Core::getTable("EiDataSetStructure");
// Réupération de la structure du scénario.
$structures = $tableStructure->getTreeArrayForITree($version->getEiScenarioId(), array(EiDataSetStructure::$TYPE_NODE));
// Création du TreeViewer.
$treeViewer = new TreeViewer("EiDataSetStructure");
$treeViewer->import($structures);
// TreeViewer pour le mapping.
$tree = new TreeView($treeViewer, new ModeSelectInHiddenInputTreeStrategy(), array("id" => "select_node_iterator_" . time(), "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "inputTarget" => "ei_block_foreach_Iterator_ei_dataset_structure_id", "selected" => $selected, "actions" => array()));
}
$this->tree = $tree;
}
示例5: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->form = new ContactForm();
$this->getUser()->setFlash('success', false);
$this->getUser()->setFlash('error', false);
if ($request->getMethod() == 'POST') {
$this->form->bind($request->getParameter('contact'));
if ($this->form->isValid()) {
$contact = $request->getParameter('contact');
//recupera o e-mail de contato
$profile = Doctrine_Core::getTable('Profile')->findOneBy('id', 1);
$message = $this->getMailer()->compose($contact['email'], array($profile->email), 'Contato Tiago Trespach', <<<EOF
Nome:{$contact['nome']}
E-mail:{$contact['email']}
Telefone:{$contact['telefone']}
Mensagem:{$contact['mensagem']}
EOF
);
$this->getMailer()->send($message);
$this->getUser()->setFlash('success', 'Mensagem enviada! Em breve responderei.');
$this->form = new ContactForm();
} else {
$this->getUser()->setFlash('error', 'Oooops, alguns campos não estão preenchidos.');
}
}
}
示例6: executeBrowse
public function executeBrowse(sfWebRequest $request)
{
$this->getResponse()->addJavascript('/sfWidgetCKEditorPlugin/js/cropper/cropper.min.js');
$this->getResponse()->addJavascript('/sfWidgetCKEditorPlugin/js/main.js');
$this->getResponse()->addStylesheet('/sfWidgetCKEditorPlugin/js/cropper/cropper.css');
// var_dump(sfConfig::get('sf_data_dir'));
$template = $this->getContext()->getConfiguration()->getTemplateDir('ckeditor', 'gallery.php');
$this->uploadForm = new GalleryImageForm();
if ($request->getMethod() == sfWebRequest::POST) {
$this->uploadForm->bind($request->getParameter('gallery_image'), $request->getFiles('gallery_image'));
if ($this->uploadForm->isValid()) {
$file = $this->uploadForm->getValue('orginal_location');
$name = sha1($file->getOriginalName() . time());
$size = $file->getSize();
$filename = 'uploaded_' . $name;
$extension = $file->getExtension($file->getOriginalExtension());
$file->save(sfConfig::get('sf_data_dir') . '/images/' . $filename . $extension);
$obj = $this->uploadForm->getObject();
$obj->setOrginalLocation($name);
$obj->setExtension($extension);
$obj->setFilesize($size);
$obj->setName($file->getOriginalName());
$obj->setGalleryFolderId($this->uploadForm->getValue('gallery_folder_id'));
$obj->setImageType($file->getType());
$obj->save();
}
}
$gallery = GalleryFolderQuery::create()->filterByPath('/')->findOne();
$this->setLayout($template . DIRECTORY_SEPARATOR . 'gallery');
}
示例7: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->getResponse()->setSlot('js_document_ready', $this->getPartial('deal/js_init_deal.js'));
$url = $request->getParameter("url", null);
// handle form submit
if ($request->getMethod() == "POST") {
$params = $request->getParameter('like');
$params['u_id'] = $this->getUser()->getUserId();
if ($url) {
$params['i_url'] = $url;
}
$activity = new Documents\YiidActivity();
$activity->fromArray($params);
// try to save activity
try {
$activity->save();
$this->redirect("@coupon?id=" . $activity->getId() . "&u_code=" . $activity->getCCode());
} catch (Exception $e) {
// send error on exception
$this->getLogger()->err($e->getMessage());
$this->redirect('@default_deal');
return sfView::SUCCESS;
}
}
$deal = DealTable::getInstance()->getNextFromPool($this->getUser()->getUser(), $url);
$this->deal = $deal;
if (!$deal) {
$this->hash = md5($this->getUser()->getId() . $url);
$this->setTemplate('default_deal');
}
}
示例8: executeControl
/**
* action Control
*
* @author Damian Suarez
*/
public function executeControl(sfWebRequest $request)
{
$this->revision = Doctrine::getTable('Revision')->find($request->getParameter('id'));
$this->rev_items = $this->revision->getRevisionItem();
if ($request->getMethod() == 'POST') {
$params = $request->getParameter('items');
if (!empty($params)) {
foreach ($params as $key => $value) {
$rev_item = RevisionItemTable::retrieveByRevisionAndItem($this->revision->get('id'), $key);
if ($value != $rev_item->getState()) {
$rev_item->setState($value);
$rev_item->save();
}
}
$this->revision->setBlock(false);
$this->revision->save();
}
}
$this->rev_itemsGroup = array();
foreach ($this->rev_items as $rev_item) {
if (!array_key_exists($rev_item->getItem()->getGroup()->getId(), $this->rev_itemsGroup)) {
$this->rev_itemsGroup[$rev_item->getItem()->getGroup()->getId()] = array();
}
array_push($this->rev_itemsGroup[$rev_item->getItem()->getGroup()->getId()], $rev_item);
}
}
示例9: executeOffres
public function executeOffres(sfWebRequest $request)
{
$this->filters = new InfoJobOffreFormFilter();
if ($request->getMethod() == sfRequest::POST) {
$this->filters->bind($request->getParameter($this->filters->getName()));
if ($this->filters->isValid()) {
$query = $this->filters->buildQuery($this->filters->getValues());
}
$query = InfoJobOffreTable::getInstance()->addStandardFilters($query)->orderBy('created_at DESC');
} else {
$query = InfoJobOffreTable::getInstance()->getLastOffreList();
}
$this->pager = new sfDoctrinePager('InfoJobOffre', sfConfig::get('app_portail_offres_par_page'));
$this->pager->setQuery($query);
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
$this->annonces = $this->pager->getResults();
$this->isGet = $request->getMethod() == sfRequest::GET;
}
示例10: execute
/**
* @param sfWebRequest $request
* @return application/json data
*/
public function execute($request)
{
if ($request->getMethod() == \sfWebRequest::GET) {
$datas = array('commit' => $request->getParameter('commit'), 'file_id' => $request->getParameter('fileId'), 'position' => $request->getParameter('position'), 'line' => $request->getParameter('line'), 'user_id' => $this->getUser()->getId());
} else {
if ($request->getMethod() == \sfWebRequest::POST) {
// get the propel connection
$con = Propel::getConnection();
$con->beginTransaction();
try {
// get the comment arguments parameter
$datas = $request->getParameter('comment');
$this->forward404Unless($datas, "Comment arguments not found");
$commit = $datas['commit'];
$this->forward404Unless($commit, 'Commit Hash Not Found');
$fileId = $datas['file_id'];
$this->forward404Unless($fileId, 'File Id Not Found');
$file = FileQuery::create()->filterById($fileId)->findOne();
$this->forward404Unless($file, 'File Not Found');
$position = $datas['position'];
$this->forward404Unless($position, 'Position Line Number Not Found');
$line = $datas['line'];
$this->forward404Unless($line, 'Line Number Not Found');
$value = $datas['value'];
$this->forward404Unless($value, 'Comment Value Not Found');
// new comment object
$lineComment = new Comment();
$lineComment->setUserId($this->getUser()->getId())->setCommit($commit)->setBranchId($file->getBranchId())->setFileId($fileId)->setPosition($position)->setLine($line)->setType(CommentPeer::TYPE_LINE)->setValue($value)->save($con);
$lineComment->getBranch()->setReviewRequest(false)->save();
$datas = array_merge($datas, array('form_visible' => false));
$con->commit();
$this->dispatcher->notify(new sfEvent($this, 'notification.comment', array('project-id' => $lineComment->getBranch()->getRepositoryId(), 'type' => 'line', 'object' => $lineComment)));
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
}
}
// returns a json object
$this->getResponse()->setContentType('application/json');
return $this->renderText(json_encode(array('html' => $this->getComponent('default', 'commentLine', $datas))));
}
示例11: executeQuickinput
public function executeQuickinput(sfWebRequest $request)
{
//this will only handle inputstring and parsing.
//All other functions will be delegated.
//---initialize vars-------------------------------------------------------------------------------
$this->linestrings = array();
$this->cellstrings = array();
$this->inputstring = "";
$this->errors = array();
$this->messages = array();
$this->pricelistdata = new PricelistDataGroup($this);
$this->producttypedata = new ProducttypeDataGroup($this);
$this->productdata = new ProductDataGroup($this);
$this->quotedata = new QuoteDataGroup($this);
$this->productsfromproducttypedata = new ProductsFromProducttypeDataGroup($this);
//---------case 1: if id given, method=get: load data object: [ok] ---------
//just display it
if ($request->getParameter("id") and $request->getMethod() == "GET") {
$this->pricelistdata->processById($request->getParameter("id"));
} else {
if ($request->getMethod() == "GET") {
$this->pricelistdata->processEmpty();
} else {
$this->inputstring = $request->getParameter("inputstring");
$this->parse();
$this->pricelistdata->process($this->cellstrings, $request);
$this->producttypedata->process($this->cellstrings);
$this->productdata->process($this->cellstrings, $this->producttypedata);
$this->quotedata->process($this->cellstrings, $request);
$this->productsfromproducttypedata->process($this->cellstrings, $this->producttypedata);
if ($request->getParameter("submit") == "Save" and count($this->errors) == 0) {
$this->pricelistdata->save();
$this->producttypedata->save();
$this->productdata->save();
$this->quotedata->save();
}
//---update input string-----------------------------------------------------------------------
$this->inputstring = $this->pricelistdata->getInputString() . $this->producttypedata->getInputString() . $this->productdata->getInputString();
}
}
}
示例12: executeIndex
public function executeIndex(sfWebRequest $request)
{
$this->fields = myParamsConfig::$fields;
$this->form = new myParamsForm();
if ($request->getMethod() === sfRequest::POST) {
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$this->form->save();
$this->getUser()->setFlash('notice', 'Your applications settings has been updated');
$this->redirect('myConfiguration/index');
}
}
}
示例13: executeIndex
public function executeIndex(sfWebRequest $request)
{
$this->filters = new AnnonceFormFilter();
if ($request->getMethod() == sfRequest::POST) {
$this->filters->bind($request->getParameter($this->filters->getName()));
if ($this->filters->isValid()) {
$query = $this->filters->buildQuery($this->filters->getValues());
}
} else {
$query = Doctrine_Core::getTable('Annonce')->createQuery('a')->orderBy('a.created_at DESC');
}
$this->annonces = $query->execute();
}
示例14: executeEdit
public function executeEdit(sfWebRequest $request)
{
$this->user = $this->getRoute()->getObject();
$this->form = new sfGuardUserAdminForm($this->user);
if ($request->getMethod() == sfWebRequest::POST) {
$this->form->bind($request->getPostParameter($this->form->getName()));
if ($this->form->isValid()) {
$this->form->save();
$this->getUser()->setFlash("notification_ok", $this->__("User edited successfully"));
$this->redirect("users/index");
}
}
}
示例15: executeDelete
public function executeDelete(sfWebRequest $request)
{
$this->form = new BudgetCategoryEditForm();
$getParameters = 'get' . ucfirst(strtolower($request->getMethod()));
$getParameters .= 'Parameters';
$this->form->bind($request->{$getParameters}());
$budgetCategory = $this->form->getObject();
if ($budgetCategory && $budgetCategory->delete()) {
return $this->renderJson(array('result' => array('text' => '')));
} else {
return $this->renderJson(array('error' => array('text' => 'Ошибка при удалении бюджета')));
}
}