Render a model.

@param ModelInterface       $model       The model to render.
@param EnvironmentInterface $environment Current environment.

@return void
2726
protected function renderModel(ModelInterface $model, EnvironmentInterface $environment)
    {
        $event = new FormatModelLabelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch(
            DcGeneralEvents::FORMAT_MODEL_LABEL,
            $event
        );

        $model->setMeta($model::LABEL_VALUE, $event->getLabel());
    }
1144510
protected function populatePanel(EnvironmentInterface $environment)
    {
        /** @var BackendViewInterface $view */
        $view = $environment->getView();

        // Already populated or not in Backend? Get out then.
        if (!(($view instanceof BaseView))) {
            return;
        }

        if (!$environment->getDataDefinition()->hasDefinition(Contao2BackendViewDefinitionInterface::NAME)) {
            return;
        }

        // Already populated.
        if ($view->getPanel()) {
            return;
        }

        $view->setPanel((new PanelBuilder($environment))->build());
    }
383128
public function populateController(EnvironmentInterface $environment)
    {
        // Already populated, get out then.
        if ($environment->getController()) {
            return;
        }
        // @codingStandardsIgnoreStart
        @\trigger_error('Fallback populator in use - implement a proper populator!', E_USER_DEPRECATED);
        // @codingStandardsIgnoreEnd

        $environment->setController((new DefaultController())->setEnvironment($environment));
    }
1148307
public function render(RenderInterface $render)
    {
        $this->render = $render;
        $this->render->setConfig($this->config);
        return $this->render->render();
    }
1236144
public function evaluate(EnvironmentInterface $env)
    {
        $qb = $env->queryBuilder;
        
        $paramValue = $env->newParamName();

        switch ($this->operator) {
            case 'equals':
                $qb->andWhere($this->attribute.' = :'.$paramValue);
                $qb->setParameter($paramValue, $this->getRight()->getValue());
                break;
            case 'notequals':
                $qb->andWhere($this->attribute.' <> :'.$paramValue);
                $qb->setParameter($paramValue, $this->getRight()->getValue());
                break;
            case 'contains':
                $qb->andWhere($this->attribute.' LIKE :'.$paramValue);
                $qb->setParameter($paramValue, '%'. $this->getRight()->getValue().'%');
                break;
        }
    }
166106
protected function process(Action $action, EnvironmentInterface $environment)
    {
        // Edit only mode, forward to edit action.
        if ($environment->getDataDefinition()->getBasicDefinition()->isEditOnlyMode()) {
            return $this->callAction($environment, 'edit', $action->getArguments());
        }

        $grouping = ViewHelpers::getGroupingMode($environment);

        Message::reset();

        // Process now.
        $collection = $this->loadCollection($environment);
        $this->handleEditAllButton($collection, $environment);
        $this->renderCollection($environment, $collection, $grouping);

        $template = $this->determineTemplate($grouping)
            ->set('collection', $collection)
            ->set('mode', ($grouping ? $grouping['mode'] : null))
            ->set('theme', Backend::getTheme());
        $this->renderTemplate($template, $environment);

        $clipboard = new ViewEvent($environment, $action, DcGeneralViews::CLIPBOARD, []);
        $environment->getEventDispatcher()->dispatch(DcGeneralEvents::VIEW, $clipboard);

        return \implode(
            "\n",
            [
                'language'  => $this->languageSwitcher($environment),
                'panel'     => $this->panel($environment),
                'buttons'   => $this->generateHeaderButtons($environment),
                'clipboard' => $clipboard->getResponse(),
                'body'      => $template->parse()
            ]
        );
    }
193311
public function evaluate(EnvironmentInterface $env)
    {
        $method = $this->operator;

        return $env->getOperator()->$method($env, $this);
    }
800352
public function populateController(EnvironmentInterface $environment)
    {
        $definition = $environment->getDataDefinition();

        if (!$definition->getBasicDefinition()->getParentDataProvider()) {
            return;
        }

        $parentDefinition = (new DcGeneralFactory())
            ->setEventDispatcher($environment->getEventDispatcher())
            ->setTranslator($environment->getTranslator())
            ->setContainerName($definition->getBasicDefinition()->getParentDataProvider())
            ->createDcGeneral()
            ->getEnvironment()
            ->getDataDefinition();

        $environment->setParentDataDefinition($parentDefinition);
    }
896246
protected function process(EnvironmentInterface $environment)
    {
        $dataProvider = $environment->getDataProvider();
        $properties   = $environment->getDataDefinition()->getPropertiesDefinition()->getProperties();
        $model        = $dataProvider->getEmptyModel();
        $clone        = $dataProvider->getEmptyModel();

        // If some of the fields have a default value, set it.
        foreach ($properties as $property) {
            $propName = $property->getName();

            if (null !== $property->getDefaultValue()) {
                $model->setProperty($propName, $property->getDefaultValue());
                $clone->setProperty($propName, $property->getDefaultValue());
            }
        }

        $view = $environment->getView();
        if (!$view instanceof BaseView) {
            return false;
        }

        return (new EditMask($view, $model, $clone, null, null, $view->breadcrumb()))->execute();
    }
1140376
private function renderHeaderFields($parentModel, EnvironmentInterface $environment)
    {
        $definition = $environment->getDataDefinition();
        $parentName = $definition->getBasicDefinition()->getParentDataProvider();
        $add        = [];
        $properties = $environment->getParentDataDefinition()->getPropertiesDefinition();
        foreach ($this->getViewSection($definition)->getListingConfig()->getHeaderPropertyNames() as $field) {
            $value = StringUtil::deserialize($parentModel->getProperty($field));

            if ('tstamp' === $field) {
                $value = date(Config::get('datimFormat'), $value);
            } else {
                $value = $this->renderParentProperty($environment, $properties->getProperty($field), $value);
            }

            // Add the field.
            if ('' !== $value) {
                $add[$this->translateHeaderColumnName($field, $parentName)] = $value;
            }
        }

        $event = new GetParentHeaderEvent($environment, $parentModel);
        $event->setAdditional($add);

        $environment->getEventDispatcher()->dispatch(GetParentHeaderEvent::NAME, $event);

        if (null !== !$event->getAdditional()) {
            $add = $event->getAdditional();
        }

        return \array_map(
            function ($value) {
                if (\is_array($value)) {
                    return $value[0];
                }
                return $value;
            },
            $add
        );
    }
812658
public function output(
        FieldDescriptionInterface $fieldDescription,
        Template $template,
        array $parameters,
        Environment $environment
    ) {
        return $this->render(
            $fieldDescription,
            new TemplateWrapper($environment, $template),
            $parameters,
            $environment
        );
    }
937471
public function renderStripeScripts(Twig_Environment $environment)
    {
        $environment->display($this->scriptsTemplate, [
            'public_key' => $this->publicKey,
            'currency' => $this->paymentBridgeInterface->getCurrency(),
        ]);
    }
870722
private function renderCollection(EnvironmentInterface $environment, CollectionInterface $collection, $grouping)
    {
        $listing    = $this->getViewSection($environment->getDataDefinition())->getListingConfig();
        $remoteCur  = null;
        $groupClass = 'tl_folder_tlist';
        $eoCount    = -1;

        // Generate buttons - only if not in select mode!
        if ('select' !== $environment->getInputProvider()->getParameter('act')) {
            $buttonRenderer = new ButtonRenderer($environment);
            $buttonRenderer->renderButtonsForCollection($collection);
        }

        // Run each model.
        foreach ($collection as $model) {
            /** @var ModelInterface $model */
            $this->addGroupHeader($environment, (array) $grouping, $model, $groupClass, $eoCount, $remoteCur);

            if ($listing->getItemCssClass()) {
                $model->setMeta($model::CSS_CLASS, $listing->getItemCssClass());
            }
            $cssClasses = [(0 === (++$eoCount) % 2) ? 'even' : 'odd'];

            (null !== $model->getMeta($model::CSS_ROW_CLASS)) ?
                $cssClasses[] = $model->getMeta($model::CSS_ROW_CLASS) : null;

            $modelId = ModelId::fromModel($model);
            if ($environment->getClipboard()->hasId($modelId)) {
                $cssClasses[] = 'tl_folder_clipped';
            }

            $model->setMeta($model::CSS_ROW_CLASS, \implode(' ', $cssClasses));

            $this->renderModel($model, $environment);
        }
    }
1177371
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->requireConfig();

        $output->writeln('Starting <fg=blue>Magallanes</>');
        $output->writeln('');

        $table = new Table($output);
        $table->setHeaders(['Environment', 'User', 'Branch', 'Hosts']);

        $configuration = $this->runtime->getConfigOption('environments');
        foreach ($configuration as $environment => $config) {
            $row = [$environment];

            $row[] = (isset($config['user']) ? $config['user'] : '-');
            $row[] = (isset($config['branch']) ? $config['branch'] : '-');
            $row[] = (isset($config['hosts']) ? implode(PHP_EOL, $config['hosts']) : '-');

            $table->addRow($row);
        }

        $table->render();

        $output->writeln('');
        $output->writeln('Finished <fg=blue>Magallanes</>');

        return 0;
    }
978409
private function determineAction(EnvironmentInterface $environment)
    {
        foreach (['delete', 'cut', 'copy', 'override', 'edit'] as $action) {
            if ($environment->getInputProvider()->hasValue($action)
                || $environment->getInputProvider()->hasValue($action . '_save')
                || $environment->getInputProvider()->hasValue($action . '_saveNback')
            ) {
                $environment->getInputProvider()->setParameter('mode', $action);

                return $action;
            }
        }

        return null;
    }
861019
public function evaluate(EnvironmentInterface $env)
    {
        $qb = $env->queryBuilder;

        $paramTemplate = $env->newParamName();
        $paramValue = $env->newParamName();
        $paramVs = $env->newParamName();

        $rootAliases = $qb->getRootAliases();
        
        $qb->innerJoin($rootAliases[0] . '.valueSet', $paramVs)
            ->innerJoin($paramVs . '.template', $paramTemplate);

        switch ($this->operator) {
            case 'in':
                $qb->andWhere($paramTemplate . '.id IN (:' . $paramValue . ')');
                break;
            case 'notin':
                $qb->andWhere($paramTemplate . '.id NOT IN (:' . $paramValue . ')');
                break;
        }

        $qb->setParameter($paramValue, $this->getRight()->getValue());
    }
828092
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->addOption('--environment', '-e', InputArgument::OPTIONAL);
        $input->setOption('environment', getenv('RAD_ENVIRONMENT'));
        parent::execute($input, $output);
    }