@inheritdoc

Returns view as a data transfer object.

@throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
337972
public function getView(View $view)
    {
        if (($configHash = $this->matcherFactory->match($view)) === null) {
            return null;
        }

        // We can set the collection directly to the view, no need to go through DTO
        $view->addParameters([
            ContentView::QUERY_DEFINITION_COLLECTION_NAME => $this->getQueryDefinitionCollection($configHash, $view),
        ]);

        // Return DTO so that Configurator can set the data back to the $view
        return $this->getDTO($configHash);
    }
1282181
public function onAdd(ViewInterface $view)
    {
        if (!$view instanceof TwigView) {
            throw new \InvalidArgumentException("This plugin only works with a Twig view");
        }
        
        foreach ($this->extensions as $class) {
            if (class_exists($class)) {
                $view->getTwig()->addExtension(new $class());
            }
        }
    }
555098
public function setView($view)
    {
        $this->view = $view;

        $this->setDisplay(function ($model) {
            $this->data['model'] = $model;

            return view($this->getView(), $this->data);
        });

        return $this;
    }
154233
private function serialize($data, TypeMetadataInterface $type, ContextInterface $context)
    {
        $class = $type->getName();

        if (!$data instanceof $class) {
            throw new \InvalidArgumentException(sprintf(
                'Expected a "%s", got "%s".',
                $class,
                is_object($data) ? get_class($data) : gettype($data)
            ));
        }

        $result = $data->format($format = $type->getOption('format', $this->format));

        if ($result === false) {
            throw new \InvalidArgumentException(sprintf('The date format "%s" is not valid.', $format));
        }

        return $result;
    }
1053159
public function toHtml($data)
    {
        if (!is_object($data) && !is_array($data)) {
            throw new \InvalidArgumentException('The $data parameter takes only an object or an array.');
        }

        $data = (array) $data;
        $type = (string) $data['type'];

        switch ($type) {
            case 'photo':
                if (empty($data['width']) || empty($data['height'])) {
                    return false;
                }
                // no break

            case 'link':
                if (empty($data['url']) || !$this->isSafeUrl($data['url'])) {
                    return false;
                }
                break;

            case 'video':
            case 'rich':
                if (empty($data['html']) || !$this->isSafeHtml($data['html'])) {
                    return false;
                }
                break;

            default:
                return false;
        }

        return $this->render($type, $data);
    }
65196
public function find($view)
    {
        /** @var ViewFinderInterface $viewFinder */
        foreach ($this->viewFinders as $viewFinder) {
            try {
                return $viewFinder->find($view);
            } catch (\Exception $e) {
            }
        }

        throw new InvalidArgumentException("View [$view] not found in any registered viewfinder.");
    }
449638
public function first(array $views, $data = [], $mergeData = [])
    {
        $view = Arr::first($views, function ($view) {
            return $this->exists($view);
        });

        if (! $view) {
            throw new InvalidArgumentException('None of the views in the given array exist.');
        }

        return $this->make($view, $data, $mergeData);
    }
1298191
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value || '' === $value) {
            return $value;
        }

        if ( ! $value instanceof Email) {
            $type = is_object($value) ? get_class($value) : gettype($value);
            throw new \InvalidArgumentException(sprintf('You have to pass an object of kind \SerendipityHQ\Component\ValueObjects\Email\Email to use the Doctrine type EmailType. "%s" passed instead.', $type));
        }

        // Validate the $value as a valid email
        $validator = new EmailValidator();

        if ( ! $validator->isValid($value, new RFCValidation())) {
            throw new \InvalidArgumentException(sprintf('An email field accepts only valid email addresses. The value "%s" is not a valid email.', $value));
        }

        // The value is automatically transformed into a string thans to the __toString() method
        return $value;
    }
297873
public static function view($type, $view)
    {
        if ($view !== null && View::exists($view) === false) {
            throw new Exception($view . ' view is not found', 2);
        }

        $callRender = array( '\\' . get_called_class(), 'render' . ucfirst($type) );

        switch ($type) {
            case 'error':
                self::$views[$type] = $view;
                App::on('error', $callRender);

                if (empty(self::$displayErrors)) {
                    self::$displayErrors = ini_get('display_errors');

                    function_exists('ini_set') && ini_set('display_errors', '0');
                }
                break;

            case 'classes':
            case 'performance':
                self::$views[$type] = $view;
                App::on('terminate', $callRender);
                break;

            case 'before':
                self::$views[$type] = $view;
                break;

            default:
                throw new Exception($type . ' is not valid event', 2);
        }
    }
80769
protected function prepareFluidView(): ViewInterface
    {
        $fluidView = new StandaloneView();
        $fluidView->setControllerContext($this->runtime->getControllerContext());
        $fluidView->setFormat('html');
        $fluidView->setTemplatePathAndFilename('resource://Neos.Neos.Ui/Private/Templates/Error/ErrorMessage.html');

        return $fluidView;
    }
1213189
public static function get($type)
    {
        if (!isset(static::$_modelFactories['Table'])) {
            static::$_modelFactories['Table'] = [TableRegistry::getTableLocator(), 'get'];
        }

        if (!isset(static::$_modelFactories[$type])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown repository type "%s". Make sure you register a type before trying to use it.',
                $type
            ));
        }

        return static::$_modelFactories[$type];
    }
880081
protected function determineViewType()
    {
        $filename = Core::i()->request_uri;
        $extension = HTTPUtilities::getFileExtension($filename);
        if (PHP_SAPI === 'cli' || PHP_SAPI === 'cli-server') {
            // Extension is irrelevant, use the cli renderer
            $this->setViewType('c l i');
            $url_array[] = $filename;
        } elseif (!is_null($extension)) {
            $this->setViewType($extension);
        }
        Core::i()->log->debug('View Type: ' . $this->view_type);
    }
509428
private function getValue($data, $view)
    {
        if (is_scalar($view)) {
            return false;
        }

        if (is_array($view) || $view instanceof ArrayAccess) {
            if (! isset($view[$data])) {
                return false;
            }

            return $view[$data];
        }

        if (is_object($view)) {
            if (! isset($view->{$data})) {
                return false;
            }

            return $view->{$data};
        }

        return false;
    }
1096944
function onMvcErrorInjectViewModel($e)
    {
        $result = $e->getResult();
        if (!$result instanceof ModelInterface)
            return;

        $model = $e->getViewModel();

        if ($result->terminate()) {
            $e->setViewModel($result);
            return;
        }

        if ($e->getError() && $model instanceof ClearableModelInterface) {
            $model->clearChildren();
        }

        $model->addChild($result);
    }
1233882
protected function getExtension(IView $view) : string
    {
        // Find a registered extension that the view's path ends with
        foreach (array_keys($this->compilers) as $extension) {
            $lengthDifference = strlen($view->getPath()) - strlen($extension);

            if ($lengthDifference >= 0 && strpos($view->getPath(), $extension, $lengthDifference) !== false) {
                return $extension;
            }
        }

        throw new InvalidArgumentException("No extension registered for path \"{$view->getPath()}\"");
    }
1012068
public function getView()
    {
        if(!$this->_view instanceof ViewInterface)
        {
            //Make sure we have a view identifier
            if(!($this->_view instanceof ObjectIdentifier)) {
                $this->setView($this->_view);
            }

            //Create the view
            $config = array(
                'url'        => clone $this->getObject('request')->getUrl(),
                'layout'     => $this->getRequest()->getQuery()->get('layout', 'identifier'),
            );

            $this->_view = $this->getObject($this->_view, $config);

            //Make sure the view implements ViewInterface
            if(!$this->_view instanceof ViewInterface)
            {
                throw new \UnexpectedValueException(
                    'View: '.get_class($this->_view).' does not implement ViewInterface'
                );
            }
        }

        return $this->_view;
    }
1306346
public function resolveDataValue($data)
    {
        if ($data instanceof Data) {

            return $this->setData($data);

        } elseif (is_array($data)) {

            return $this->setData(new Data($data));
        }

        throw new \InvalidArgumentException(
            "Data must be View\Data or array value"
        );
    }