Check permission for create a model.

@param EnvironmentInterface $environment The environment.

@return string|bool
428003
private function checkPermission(EnvironmentInterface $environment)
    {
        $dataDefinition = $environment->getDataDefinition();

        if (true === $dataDefinition->getBasicDefinition()->isCreatable()) {
            return true;
        }

        return \sprintf(
            '<div style="text-align:center; font-weight:bold; padding:40px;">
                You have no permission for create model in %s.
            </div>',
            $dataDefinition->getName()
        );
    }
163727
private function getSubmitAction(EnvironmentInterface $environment, $regardSelectMode = false)
    {
        if (!$regardSelectMode
            && $environment->getInputProvider()->hasParameter('select')
            && !$environment->getInputProvider()->hasValue('properties')
        ) {
            return 'select' . \ucfirst($environment->getInputProvider()->getParameter('select'));
        }

        if (null !== ($action = $this->determineAction($environment))) {
            return $action;
        }

        if ($regardSelectMode) {
            return $environment->getInputProvider()->getParameter('mode') ?: null;
        }

        return $environment->getInputProvider()->getParameter('select') ?
            'select' . \ucfirst($environment->getInputProvider()->getParameter('select')) : null;
    }
1356724
private function getSelectContainer(EnvironmentInterface $environment)
    {
        $inputProvider  = $environment->getInputProvider();
        $sessionStorage = $environment->getSessionStorage();

        $sessionName = $environment->getDataDefinition()->getName() . '.' . $inputProvider->getParameter('mode');
        if (!$sessionStorage->has($sessionName)) {
            return [];
        }

        $selectAction = $inputProvider->getParameter('select');
        if (!$selectAction) {
            return [];
        }

        $session = $sessionStorage->get($sessionName);
        if (!\array_key_exists($selectAction, $session)) {
            return [];
        }

        return $session[$selectAction];
    }
1122557
public static function factory(?Enviroment $environment = null): Parser
    {
        $environment = $environment ?? Enviroment::getFromSapi(PHP_SAPI);

        return self::evaluate($environment)->isInstanceOf(Parser::class)->getValue();
    }
983531
public function parseHeaders(EnvironmentInterface $environment)
    {
        foreach ($environment as $key => $value) {
            $key = strtoupper($key);

            if (strpos($key, 'HTTP_') === 0 || in_array($key, $this->special)) {
                if ($key === 'HTTP_CONTENT_TYPE' || $key === 'HTTP_CONTENT_LENGTH') {
                    continue;
                }

                parent::set($this->normalizeKey($key), array($value));
            }
        }
    }
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;
        }
    }
744697
public static function is($environment = null)
    {
        $current = Configure::read('Environment.name');

        if (! $environment) {
            return $current;
        }

        return $current === $environment;
    }
962786
protected function detectConsoleEnvironment($environments, array $args)
    {
        // First we will check if an environment argument was passed via console arguments
        // and if it was that automatically overrides as the environment. Otherwise, we
        // will check the environment as a "web" request like a typical HTTP request.
        if (!is_null($value = $this->getEnvironmentArgument($args))) {
            return head(array_slice(explode('=', $value), 1));
        }
    }
632842
private function setProjectProfiles(EnvironmentInterface $environment)
    {
        $projectFs = $environment->getProjectFilesystem();
        if (!$projectFs->has(self::PROJECT_PHPCS)) {
            return;
        }

        $ideConfigFs = $environment->getIdeConfigFilesystem();

        $xml = simplexml_load_string(
            $ideConfigFs->read(self::INSPECTION_PROFILE)
        );

        $this->setProjectPhpCsProfile($xml);
        $ideConfigFs->put(self::INSPECTION_PROFILE, $xml->asXML());
    }
1094054
private function getSelectCollection(EnvironmentInterface $environment)
    {
        $sessionStorage = $environment->getSessionStorage();
        $dataDefinition = $environment->getDataDefinition();
        $dataProvider   = $environment->getDataProvider();
        $session        =
            $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true));

        $modelIds = [];
        foreach ($session['models'] as $modelId) {
            $modelIds[] = ModelId::fromSerialized($modelId)->getId();
        }

        $idProperty = \method_exists($dataProvider, 'getIdProperty') ? $dataProvider->getIdProperty() : 'id';
        return $dataProvider->fetchAll(
            $dataProvider->getEmptyConfig()->setFilter(
                [
                    [
                        'operation' => 'IN',
                        'property'  => $idProperty,
                        'values'    => $modelIds
                    ]
                ]
            )
        );
    }
110899
public static function validateEnvironment(string $environment)
    {
        if (!in_array($environment, self::$validEnvironments, true)) {
            $environmentsText = '"' . implode('", ', self::$validEnvironments) . '"';
            throw new \UnexpectedValueException(
                '$environment must be one of ' . $environmentsText . ', but actually was: "' . $environment . '"',
                1499112172
            );
        }
    }
739925
protected function detectWebEnvironment($environments)
	{
		$default = ClientManager::client('site', true);

		foreach ($environments as $environment => $url)
		{
			if ($client = ClientManager::client($environment, true))
			{
				$const = 'JPATH_' . strtoupper($environment);

				// To determine the current environment, we'll simply iterate through the possible
				// environments and look for the host that matches the host for this request we
				// are currently processing here, then return back these environment's names.
				if ((defined($const) && JPATH_BASE == constant($const)) || $this->request->segment(1) == $url)
				{
					return $client;
				}
			}
		}

		return $default;
	}
1296119
private function extractParameters(SystemEnvironmentInterface $environment)
    {
        $server = $this->environment->getRequestHelper()->getServerParams();
        $params = array();
        parse_str(isset($server['QUERY_STRING']) ? $server['QUERY_STRING'] : '', $params);
        $body = $this->environment->getStdInput();
        $content_type = isset($server['CONTENT_TYPE']) ? $server['CONTENT_TYPE'] : '';
        if (strchr($content_type, ';') !== false) {
            list($content_type) = preg_split('/;/', $content_type, 2);
        }
        switch ($content_type) {
            case "application/json":
                $params = array_merge($params, $this->parseApplicationJson($body));
                break;

            case "application/x-www-form-urlencoded":
                $params = array_merge($params, $this->parseApplicationFormUrlEncoded($body));
                break;

            case "multipart/form-data":
                $params = array_merge($params, $this->parseMultipartFormdata($body));
                break;
        }
        $environment->getRequestHelper()->fillWithData($params);
    }
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();
    }
315845
public function patch(
        EnvironmentInterface $environment
    ) {
        $this->copyDirectory(
            $environment->getDefaultsFilesystem(),
            $environment->getIdeConfigFilesystem(),
            'inspectionProfiles'
        );

        $this->setProjectProfiles($environment);
    }
892103
protected function getCollection(EnvironmentInterface $environment)
    {
        $dataDefinition = $environment->getDataDefinition();
        $relationShip   = $dataDefinition->getModelRelationshipDefinition();

        if (!$relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName())) {
            return $this->getFlatCollection($environment);
        }

        return $this->getHierarchyCollection($this->getClipboardItems($environment), $environment);
    }
638419
private function getReferrerUrl(EnvironmentInterface $environment)
    {
        $parent = $environment->getParentDataDefinition();
        $event  = new GetReferrerEvent(
            true,
            (null !== $parent)
                ? $parent->getName()
                : $environment->getDataDefinition()->getName()
        );

        $environment->getEventDispatcher()->dispatch(ContaoEvents::SYSTEM_GET_REFERRER, $event);

        return $event->getReferrerUrl();
    }