Pimcore\Model\Redirect::setTarget PHP Method

setTarget() public method

public setTarget ( string $target ) : void
$target string
return void
    public function setTarget($target)
    {
        $this->target = $target;
        return $this;
    }

Usage Example

Example #1
0
 /**
  *
  */
 protected function update()
 {
     $oldPath = $this->getDao()->getCurrentFullPath();
     parent::update();
     $config = \Pimcore\Config::getSystemConfig();
     if ($oldPath && $config->documents->createredirectwhenmoved && $oldPath != $this->getRealFullPath()) {
         // create redirect for old path
         $redirect = new Redirect();
         $redirect->setTarget($this->getId());
         $redirect->setSource("@" . $oldPath . "/?@");
         $redirect->setStatusCode(301);
         $redirect->setExpiry(time() + 86400 * 60);
         // this entry is removed automatically after 60 days
         $redirect->save();
     }
 }
All Usage Examples Of Pimcore\Model\Redirect::setTarget