Datatypes\TinyUrl\Editor::save PHP Method

save() public method

Save upload editor
public save ( ) : void
return void
    public function save()
    {
        $url = $this->getRequest()->getPost()->get($this->getName());
        $value = array();
        if (!empty($url)) {
            $validator = new Uri(array('allowRelative' => false));
            if ($validator->isValid($url)) {
                $tinyUrl = file_get_contents('http://tinyurl.com/api-create.php?url=' . rawurlencode($url));
                $value = array($url, $tinyUrl);
            }
        }
        $this->setValue(serialize($value));
    }

Usage Example

Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testSave()
 {
     $this->object->getRequest()->getPost()->set($this->object->getName(), 'http://got-cms.com');
     $this->object->save();
     $this->assertEquals($this->serializedString, $this->object->getValue());
 }