src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php
public function buildWidget(
        PropertyInterface $property,
        ModelInterface $model
    ) {
        if (static::$scopeDeterminator->currentScopeIsUnknown()
            || !static::$scopeDeterminator->currentScopeIsBackend()
        ) {
            throw new DcGeneralRuntimeException(
                \sprintf(
                    'WidgetBuilder only supports the backend mode. Running in mode "%s".',
                    static::$scopeDeterminator->currentScopeIsUnknown() ? 'unknown' : 'frontend'
                )
            );
        }

        $environment = $this->getEnvironment();
        $class       = $this->getWidgetClass($property);

        $prepareAttributes = $this->prepareWidgetAttributes($model, $property);
        $widget            = new $class($prepareAttributes, new DcCompat($environment, $model, $property->getName()));

        // OH: what is this? source: DataContainer 232.
        $widget->currentRecord = $model->getId();

        $widget->xlabel .= $this->getXLabel($property);

        $event = new ManipulateWidgetEvent($environment, $model, $property, $widget);
        $environment->getEventDispatcher()->dispatch(ManipulateWidgetEvent::NAME, $event);

        return $widget;
    }
public function buildWidget(
        PropertyInterface $property,
        ModelInterface $model
    ) {
        if (static::$scopeDeterminator->currentScopeIsUnknown()
            || !static::$scopeDeterminator->currentScopeIsBackend()
        ) {
            throw new DcGeneralRuntimeException(
                \sprintf(
                    'WidgetBuilder only supports the backend mode. Running in mode "%s".',
                    static::$scopeDeterminator->currentScopeIsUnknown() ? 'unknown' : 'frontend'
                )
            );
        }

        $environment = $this->getEnvironment();
        $class       = $this->getWidgetClass($property);

        $prepareAttributes = $this->prepareWidgetAttributes($model, $property);
        $widget            = new $class($prepareAttributes, new DcCompat($environment, $model, $property->getName()));

        // OH: what is this? source: DataContainer 232.
        $widget->currentRecord = $model->getId();

        $widget->xlabel .= $this->getXLabel($property);

        $event = new ManipulateWidgetEvent($environment, $model, $property, $widget);
        $environment->getEventDispatcher()->dispatch(ManipulateWidgetEvent::NAME, $event);

        return $widget;
    }
public function buildWidget ( PropertyInterface $ property , ModelInterface $ model ) { if ( static :: $ scopeDeterminator -> currentScopeIsUnknown ( ) || ! static :: $ scopeDeterminator -> currentScopeIsBackend ( ) ) { throw new DcGeneralRuntimeException ( \ sprintf ( 'WidgetBuilder only supports the backend mode. Running in mode "%s".' , static :: $ scopeDeterminator -> currentScopeIsUnknown ( ) ? 'unknown' : 'frontend' ) ) ; } $ environment = $ this -> getEnvironment ( ) ; $ class = $ this -> getWidgetClass ( $ property ) ; $ prepareAttributes = $ this -> prepareWidgetAttributes ( $ model , $ property ) ; $ widget = new $ class ( $ prepareAttributes , new DcCompat ( $ environment , $ model , $ property -> getName ( ) ) ) ; // OH: what is this? source: DataContainer 232. $ widget -> currentRecord = $ model -> getId ( ) ; $ widget -> xlabel .= $ this -> getXLabel ( $ property ) ; $ event = new ManipulateWidgetEvent ( $ environment , $ model , $ property , $ widget ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( ManipulateWidgetEvent :: NAME , $ event ) ; return $ widget ; }
Build a widget for a given property.

@param PropertyInterface $property The property.
@param ModelInterface    $model    The current model.

@return Widget

@throws DcGeneralRuntimeException When not running in TL_MODE BE.

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)
Build a widget for a given property .