getValue() 공개 메소드

public getValue ( )
예제 #1
0
 /**
  * It should throw an exception if the property is required but the value is null.
  *
  * @expectedException Sulu\Component\Content\Exception\MandatoryPropertyException
  */
 public function testThrowExceptionPropertyRequired()
 {
     $document = new TestContentDocument($this->structure->reveal());
     $document->setStructureType('foobar');
     $this->persistEvent->getDocument()->willReturn($document);
     // map the structure type
     $this->persistEvent->getLocale()->willReturn('fr');
     // map the content
     $this->inspector->getStructureMetadata($document)->willReturn($this->structureMetadata->reveal());
     $this->inspector->getWebspace($document)->willReturn('webspace');
     $this->structureMetadata->getProperties()->willReturn(['prop1' => $this->structureProperty->reveal()]);
     $this->structureProperty->isRequired()->willReturn(true);
     $this->structure->getProperty('prop1')->willReturn($this->propertyValue->reveal());
     $this->propertyValue->getValue()->willReturn(null);
     $this->structureMetadata->getName()->willReturn('test');
     $this->structureMetadata->getResource()->willReturn('/path/to/resource.xml');
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }
예제 #2
0
 /**
  * gets the value from property.
  *
  * @return mixed
  */
 public function getValue()
 {
     if ($this->propertyValue) {
         return $this->propertyValue->getValue();
     }
     return $this->value;
 }
예제 #3
0
 /**
  * Upgrades the given property to the new URL representation.
  *
  * @param PropertyValue $property The current property value, which will be updated
  * @param bool $addScheme Adds the scheme to URLs if true, removes the scheme otherwise
  */
 private function upgradeProperty(PropertyValue $property, $addScheme)
 {
     $value = $property->getValue();
     if ($addScheme) {
         $this->upgradeUrl($value);
     } else {
         $this->downgradeUrl($value);
     }
     $property->setValue($value);
 }
예제 #4
0
 /**
  * Upgrades the given property to the new URL representation.
  *
  * @param PropertyValue $property The current property value, which will be updated
  * @param bool $addScheme Adds the scheme to URLs if true, removes the scheme otherwise
  */
 private function upgradeProperty(PropertyValue $property, $addScheme)
 {
     $value = $property->getValue();
     if (is_array($value)) {
         foreach ($value as $key => $entry) {
             if ($entry['type'] !== 'url') {
                 continue;
             }
             if ($addScheme) {
                 $this->upgradeUrl($entry['url']);
             } else {
                 $this->downgradeUrl($entry['url']);
             }
             $value[$key] = $entry;
         }
     } elseif ($addScheme) {
         $this->upgradeUrl($value);
     } else {
         $this->downgradeUrl($value);
     }
     $property->setValue($value);
 }