当前位置: 首页>>代码示例>>PHP>>正文


PHP Redirect::setStatusCode方法代码示例

本文整理汇总了PHP中Redirect::setStatusCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Redirect::setStatusCode方法的具体用法?PHP Redirect::setStatusCode怎么用?PHP Redirect::setStatusCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redirect的用法示例。


在下文中一共展示了Redirect::setStatusCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  *
  */
 public function update()
 {
     parent::update();
     $config = Pimcore_Config::getSystemConfig();
     if ($this->_oldPath && $config->documents->createredirectwhenmoved) {
         // create redirect for old path
         $redirect = new Redirect();
         $redirect->setTarget($this->getId());
         $redirect->setSource("@" . $this->_oldPath . "/?@");
         $redirect->setStatusCode(301);
         $redirect->setExpiry(time() + 86400 * 60);
         // this entry is removed automatically after 60 days
         $redirect->save();
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:18,代码来源:Page.php

示例2: saveAction

 public function saveAction()
 {
     if ($this->_getParam("id")) {
         $page = Document_Page::getById($this->_getParam("id"));
         $page = $this->getLatestVersion($page);
         $page->setUserModification($this->getUser()->getId());
         // save to session
         $key = "document_" . $this->_getParam("id");
         $session = new Zend_Session_Namespace("pimcore_documents");
         $session->{$key} = $page;
         if ($this->_getParam("task") == "unpublish") {
             $page->setPublished(false);
         }
         if ($this->_getParam("task") == "publish") {
             $page->setPublished(true);
         }
         // check for redirects
         if ($this->getUser()->isAllowed("redirects") && $this->_getParam("settings")) {
             $settings = Zend_Json::decode($this->_getParam("settings"));
             if (is_array($settings)) {
                 $redirectList = new Redirect_List();
                 $redirectList->setCondition("target = ?", $page->getId());
                 $existingRedirects = $redirectList->load();
                 $existingRedirectIds = array();
                 foreach ($existingRedirects as $existingRedirect) {
                     $existingRedirectIds[$existingRedirect->getId()] = $existingRedirect->getId();
                 }
                 for ($i = 1; $i < 100; $i++) {
                     if (array_key_exists("redirect_url_" . $i, $settings)) {
                         // check for existing
                         if ($settings["redirect_id_" . $i]) {
                             $redirect = Redirect::getById($settings["redirect_id_" . $i]);
                             unset($existingRedirectIds[$redirect->getId()]);
                         } else {
                             // create new one
                             $redirect = new Redirect();
                         }
                         $redirect->setSource($settings["redirect_url_" . $i]);
                         $redirect->setTarget($page->getId());
                         $redirect->setStatusCode(301);
                         $redirect->save();
                     }
                 }
                 // remove existing redirects which were delete
                 foreach ($existingRedirectIds as $existingRedirectId) {
                     $redirect = Redirect::getById($existingRedirectId);
                     $redirect->delete();
                 }
             }
         }
         // only save when publish or unpublish
         if ($this->_getParam("task") == "publish" && $page->isAllowed("publish") or $this->_getParam("task") == "unpublish" && $page->isAllowed("unpublish")) {
             $this->setValuesToDocument($page);
             try {
                 $page->save();
                 $this->_helper->json(array("success" => true));
             } catch (Exception $e) {
                 Logger::err($e);
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         } else {
             if ($page->isAllowed("save")) {
                 $this->setValuesToDocument($page);
                 try {
                     $page->saveVersion();
                     $this->_helper->json(array("success" => true));
                 } catch (Exception $e) {
                     Logger::err($e);
                     $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
                 }
             }
         }
     }
     $this->_helper->json(false);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:75,代码来源:PageController.php


注:本文中的Redirect::setStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。