@inheritdoc

@param XType $type
@param mixed $value
@param string $view (default:'default')

@return string|null
191374
public function value(XType $type, $value, $view = 'default')
    {
        $formatter = $this->getFormatter($type);
        return call_user_func($formatter, $type, $value, $view, $this->locale);
    }
1178702
public static function fixType($value, $type = \PDO::PARAM_STR)
    {
        if ($value === null) {
            return null;
        }

        switch ($type) {
            case \PDO::PARAM_NULL:
                return null;
            case \PDO::PARAM_INT:
                $float = floatval($value);
                $int = intval($float);
                if ($float && $int != $float) {
                    return $float;
                }

                return $int;
            case \PDO::PARAM_BOOL:
                return $value ? 1 : 0;
        }

        return $value;
    }
902634
public static function isType(BlockView $view, $type)
    {
        return isset($view->vars['block_prefixes'])
            && \is_array($view->vars['block_prefixes'])
            && \in_array($type, $view->vars['block_prefixes']);
    }
738122
private function createView($view, $viewFile, $type, $moduleDir)
    {
        $template = file_get_contents(
            __DIR__.DIRECTORY_SEPARATOR."templates".DIRECTORY_SEPARATOR."view_".$type.".tpl"
        );

        $template = str_replace('$VIEW', $view, $template);

        file_put_contents($viewFile, $template);
    }
408190
public function equals($type, $value = null)
    {
        return $this->is($type) && $value === $this->value;
    }
345274
protected function process($value, string $type)
    {
        if ($type === 'integer') {
            return (int) $value;
        }

        if ($type === 'float') {
            return (float) $value;
        }

        if ($type === 'boolean') {
            return (bool) $value;
        }

        return (string) $value;
    }
148842
public void registerView(final ServiceValidationViewTypes type, final Pair<View, View> view) {
        registerView(type.getType(), view);
    }
889207
public function fromPg($value, $type = null)
    {
        return $this->converter->fromPg(
            $value,
            $type === null ? $this->getClientIdentifier() : $type,
            $this->getSession()
        );
    }
160786
public function watch($view, $args = array(), $type = null)
    {
        try {
            return $this->scope($view, $args, $type);
        } catch (\InvalidArgumentException $e) {
            return $this->of($view, $args, $type);
        }
    }
107813
protected function handleTypeConversions($value, $typeOfField)
    {
        switch ($typeOfField) {
            case 'datetimetz':
            case 'datetime':
            case 'time':
            case 'date':
                if ('' === $value) {
                    return null;
                }

                if (is_int($value)) {
                    $dateTime = new DateTime();
                    $dateTime->setTimestamp($value);
                    $value = $dateTime;
                } elseif (is_string($value)) {
                    $value = new DateTime($value);
                }

                break;
            default:
        }

        return $value;
    }
580950
public static function castValueToDataType($value, $type)
    {
        switch ($type) {
            case Property::DATA_TYPE_FLOAT:
                return empty($value) ? null : (float) $value;
                break;

            case Property::DATA_TYPE_BOOLEAN:
                return empty($value) ? null : (bool) $value;
                break;

            case Property::DATA_TYPE_INTEGER:
                return empty($value) ? null : (int) $value;
                break;

            default:
                return $value;
                break;
        }
    }
1275515
public View viewByContentType(String contentType) {
        for (View view: views.values()) {
            if (view.getContentType().equals(contentType)) {
                return view;
            }
        }
        return null;
    }
1173812
protected function _getValueByType($value, $type)
	{
		if( !is_null($value) )
		{
			switch( $type )
			{
				case "id":
					if( array_contains( array('',null), $value, true ) )
					{
						$value = null;
					}
					else
					{
						$value = intval( $value );
					}
				break;
				case "bool":
				case "boolean":
					$value = (bool) $value;
				break;
				case "int":
					$value = (int) $value;
					break;
				case "float":
					$value = (float) $value;
				break;
				case "object":
				case "array":
					if(is_object($value) || !is_array($value))
					{
						$value = unserialize($value);
					}
				break;
				case "date":
					if($value == '0000-00-00' || $value == '')
					{
						$value = null;
					}
				break;
				case "time":
					if($value == '00:00:00' || $value == '')
					{
						$value = null;
					}
				break;
				case "datetime":
					if($value == '0000-00-00 00:00:00' || $value == '')
					{
						$value = null;
					}
				break;
				case "text":
				default:
					$value = (string) $value;
				break;
			}
		}

		return $value;
	}
113487
public static function getParent(BlockView $view, $type)
    {
        $parent = null;

        if (null !== $view->parent) {
            if (static::isType($view->parent, $type)) {
                $parent = $view->parent;
            } else {
                $parent = static::getParent($view->parent, $type);
            }
        }

        return $parent;
    }
1150364
public function view($view = null, $layout = null)
    {
        if (! is_null($layout)) {
            $this->layoutOptions = [
                'default' => $layout,
                'ajax'    => $layout,
            ];
        }

        // Set up the default view resolution
        viewBuilder()->setUp($this->layoutOptions, $view);
        $this->setupLayout();
    }
126555
public function getView(View $view)
    {
        if (!$view instanceof ContentValueView) {
            return null;
        }

        $viewType = $view->getViewType();
        $contentInfo = $view->getContent()->contentInfo;

        $legacyKernel = $this->getLegacyKernel();
        $legacyContentClosure = function (array $params) use ($contentInfo, $viewType, $legacyKernel) {
            return $legacyKernel->runCallback(
                function () use ($contentInfo, $viewType, $params) {
                    $tpl = eZTemplate::factory();
                    /**
                     * @var \eZObjectForwarder
                     */
                    $funcObject = $tpl->fetchFunctionObject('content_view_gui');
                    if (!$funcObject) {
                        return '';
                    }

                    // Used by XmlText field type
                    if (isset($params['objectParameters'])) {
                        if (isset($params['linkParameters']) && $params['linkParameters'] !== null) {
                            $linkParameters = $params['linkParameters'];
                        }
                        $tpl->setVariable('object_parameters', $params['objectParameters'], 'ContentView');
                    }
                    // Used by RichText field type
                    elseif (isset($params['embedParams'])) {
                        if (isset($params['embedParams']['link'])) {
                            $linkParameters = $params['embedParams']['link'];
                        }

                        if (isset($params['embedParams']['config'])) {
                            $tpl->setVariable('object_parameters', $params['embedParams']['config'], 'ContentView');
                        }
                    }

                    // Convert link parameters to Legacy Stack format
                    if (isset($linkParameters)) {
                        $tpl->setVariable(
                            'link_parameters',
                            $this->legalizeLinkParameters($linkParameters),
                            'ContentView'
                        );
                    }

                    $children = [];
                    $funcObject->process(
                        $tpl, $children, 'content_view_gui', false,
                        [
                            'content_object' => [
                                [
                                    eZTemplate::TYPE_ARRAY,
                                    // eZTemplate::TYPE_OBJECT does not exist because
                                    // it's not possible to create "inline" objects in
                                    // legacy template engine (ie objects are always
                                    // stored in a tpl variable).
                                    // TYPE_ARRAY is used here to allow to directly
                                    // retrieve the object without creating a variable.
                                    // (TYPE_STRING, TYPE_BOOLEAN, ... have the same
                                    // behaviour, see eZTemplate::elementValue())
                                    eZContentObject::fetch($contentInfo->id),
                                ],
                            ],
                            'view' => [
                                [
                                    eZTemplate::TYPE_STRING,
                                    $viewType,
                                ],
                            ],
                        ],
                        [], '', ''
                    );
                    if (\is_array($children) && isset($children[0])) {
                        return ezpEvent::getInstance()->filter('response/output', $children[0]);
                    }

                    return '';
                },
                false
            );
        };

        $this->decorator->setContentView(
            new ContentView($legacyContentClosure)
        );

        return $this->decorator;
    }
1045912
protected function _initValue($value = null, $type = self::T_TEXT)
    {
        switch ($type) {
            case self::T_TEXT:
                $this->rawValue = $value;
                break;
            case self::T_RAW:
                $this->value = $value;
                break;
        }
    }