eZ\Publish\Core\FieldType\Page\HashConverter::convertFromValue PHP Method

convertFromValue() public method

Converts the given $value into a plain hash format.
public convertFromValue ( Value $value ) : array
$value Value
return array
    public function convertFromValue(Value $value)
    {
        $hash = array();
        foreach ($value->page->getState() as $propName => $propValue) {
            switch ($propName) {
                case 'layout':
                    if ($propValue !== null) {
                        $hash['layout'] = $propValue;
                    }
                    break;
                case 'attributes':
                    if ($propValue !== null && $propValue !== array()) {
                        $hash['attributes'] = $propValue;
                    }
                    break;
                case 'zones':
                    foreach ($propValue as $zone) {
                        $hash['zones'][] = $this->convertZoneToHash($zone);
                    }
                    break;
            }
        }
        return $hash;
    }

Usage Example

Beispiel #1
0
 /**
  * Converts a Value to a hash.
  *
  * @param \eZ\Publish\Core\FieldType\Page\Value $value
  *
  * @return mixed
  */
 public function toHash(SPIValue $value)
 {
     if ($this->isEmptyValue($value)) {
         return null;
     }
     return $this->hashConverter->convertFromValue($value);
 }