src/Contao/View/Contao2BackendView/ContaoWidgetManager.php
public function getWidget($property, PropertyValueBag $inputValues = null)
    {
        $environment         = $this->getEnvironment();
        $propertyDefinitions = $environment->getDataDefinition()->getPropertiesDefinition();

        if (!$propertyDefinitions->hasProperty($property)) {
            throw new DcGeneralInvalidArgumentException(
                'Property ' . $property . ' is not defined in propertyDefinitions.'
            );
        }

        $model = clone $this->model;
        $model->setId($this->model->getId());

        if ($inputValues) {
            $values = new PropertyValueBag($inputValues->getArrayCopy());
            $this->environment->getController()->updateModelFromPropertyBag($model, $values);
        }

        $event = new BuildWidgetEvent($environment, $model, $propertyDefinitions->getProperty($property));

        $environment->getEventDispatcher()->dispatch($event::NAME, $event);
        if (!$event->getWidget()) {
            throw new DcGeneralRuntimeException(
                \sprintf('Widget was not build for property %s::%s.', $this->model->getProviderName(), $property)
            );
        }

        return $event->getWidget();
    }
public function getWidget($property, PropertyValueBag $inputValues = null)
    {
        $environment         = $this->getEnvironment();
        $propertyDefinitions = $environment->getDataDefinition()->getPropertiesDefinition();

        if (!$propertyDefinitions->hasProperty($property)) {
            throw new DcGeneralInvalidArgumentException(
                'Property ' . $property . ' is not defined in propertyDefinitions.'
            );
        }

        $model = clone $this->model;
        $model->setId($this->model->getId());

        if ($inputValues) {
            $values = new PropertyValueBag($inputValues->getArrayCopy());
            $this->environment->getController()->updateModelFromPropertyBag($model, $values);
        }

        $event = new BuildWidgetEvent($environment, $model, $propertyDefinitions->getProperty($property));

        $environment->getEventDispatcher()->dispatch($event::NAME, $event);
        if (!$event->getWidget()) {
            throw new DcGeneralRuntimeException(
                \sprintf('Widget was not build for property %s::%s.', $this->model->getProviderName(), $property)
            );
        }

        return $event->getWidget();
    }
public function getWidget ( $ property , PropertyValueBag $ inputValues = null ) { $ environment = $ this -> getEnvironment ( ) ; $ propertyDefinitions = $ environment -> getDataDefinition ( ) -> getPropertiesDefinition ( ) ; if ( ! $ propertyDefinitions -> hasProperty ( $ property ) ) { throw new DcGeneralInvalidArgumentException ( 'Property ' . $ property . ' is not defined in propertyDefinitions.' ) ; } $ model = clone $ this -> model ; $ model -> setId ( $ this -> model -> getId ( ) ) ; if ( $ inputValues ) { $ values = new PropertyValueBag ( $ inputValues -> getArrayCopy ( ) ) ; $ this -> environment -> getController ( ) -> updateModelFromPropertyBag ( $ model , $ values ) ; } $ event = new BuildWidgetEvent ( $ environment , $ model , $ propertyDefinitions -> getProperty ( $ property ) ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( $ event :: NAME , $ event ) ; if ( ! $ event -> getWidget ( ) ) { throw new DcGeneralRuntimeException ( \ sprintf ( 'Widget was not build for property %s::%s.' , $ this -> model -> getProviderName ( ) , $ property ) ) ; } return $ event -> getWidget ( ) ; }
Retrieve the instance of a widget for the given property.

@param string           $property    Name of the property for which the widget shall be retrieved.
@param PropertyValueBag $inputValues The input values to use (optional).

@return Widget

@throws DcGeneralRuntimeException         When No widget could be build.
@throws DcGeneralInvalidArgumentException When property is not defined in the property definitions.

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
Retrieve the instance of a widget for the given property .