Generate a panel name if not given.

@param string        $value         Panel name.
@param DataContainer $dataContainer Data container driver.

@return string
969171
public function generatePanelName($value, $dataContainer): string
    {
        if (!$value) {
            $value = 'panel_' . $dataContainer->activeRecord->id;
        }

        return $value;
    }
122066
public function describeValue(Exporter $exporter, $value): string
    {
        return $this->predicate->describeValue($exporter, $value);
    }
690253
private function _searchParams($value, array $dataRecursive)
    {
        preg_match_all(
            '/
                \?
                (?P<name>\\w+)                  # name param
                \\s*\=\\s*
                (?P<value>\{{3}\\d+\}{3}\\s*)*  # value param
                [^\?\[\]]*                      # restriction: is not "?" and not "[" "]"
            /iux',
            $value,
            $matches
        );
        $i = 0;
        $result = [];
        if (!isset($matches['name'])) {
            return $result;
        }
        foreach ($matches['name'] as $nameParams) {
            if (!isset($matches['value'][$i]) || !isset($nameParams)) {
                continue;
            }
            $valueParams = mb_substr($dataRecursive[trim($matches['value'][$i])], 2, -2, 'UTF-8');
            // Search prefix
            $valueParams = $this->_searchPrefix($nameParams, $valueParams);
            // to type
            if (is_string($valueParams)) {
                $valueParams = $this->_prepareValueOfParam(str_replace('&#61;', '=', $valueParams));
                $valueParams = Helper::toType($valueParams);

            }
            // If multiple placeholders with the same name, then create to array
            if (isset($result[$nameParams])) {
                if (is_array($result[$nameParams])) {
                    $result[$nameParams][] = $valueParams;
                } else {
                    $result[$nameParams] = [$result[$nameParams], $valueParams];
                }
            } else {
                $result[$nameParams] = $valueParams;
            }
            ++$i;
        }

        return $result;
    }
886291
public function describeValue(Exporter $exporter, $value): string
    {
        if (! $value instanceof CatchedError) {
            return parent::describeValue($exporter, $value);
        }

        return 'error of level "' . $value->name()
        . '" with message "' . $value->errstr() . '" triggered in '
        . $value->file() . ' on line ' . $value->line();
    }
560432
public function generateLabel(array $row, $label, DataContainer $dc, array $args): array
    {
        $manager = $this->getManager($row['source']);

        if (null !== ($tag = $manager->find($row['id']))) {
            $args[2] = $manager->countSourceRecords($tag);
        }

        return $args;
    }
1299018
public function onLoadCallback(DataContainer $dc): void
    {
        if (!($dc instanceof Driver)) {
            return;
        }

        $ids = [];

        // Collect the top tags from all registries
        foreach ($this->registry->getAliases() as $alias) {
            $manager = $this->registry->get($alias);

            if ($manager instanceof DefaultManager) {
                foreach ($manager->getTopTagIds([], null, true) as $id => $count) {
                    $ids[$id] = $count;
                }
            }
        }

        // Append all other tags
        foreach ($this->db->executeQuery("SELECT id FROM {$dc->table}")->fetchAll(\PDO::FETCH_COLUMN, 0) as $id) {
            if (!\array_key_exists($id, $ids)) {
                $ids[$id] = 0;
            }
        }

        /** @var AttributeBagInterface $bag */
        $bag = $this->session->getBag('contao_backend');
        $session = $bag->all();

        // Handle the sorting selection
        switch ($session['sorting'][$dc->table]) {
            case 'total_asc':
                \asort($ids);
                break;
            case 'total_desc':
                \arsort($ids);
                break;
            default:
                $session['sorting'][$dc->table] = null;
                $bag->replace($session);

                return;
        }

        /** @var Database $db */
        $db = $this->framework->createInstance(Database::class);
        $dc->setOrderBy([$db->findInSet('id', \array_keys($ids))]);

        // Prevent adding an extra column to the listing
        $dc->setFirstOrderBy('name');
    }
1161792
public function onPanelCallback(DataContainer $dc): string
    {
        /** @var AttributeBagInterface $bag */
        $bag = $this->session->getBag('contao_backend');
        $session = $bag->all();

        $sorting = ['_default', 'total_asc', 'total_desc'];
        $request = $this->requestStack->getCurrentRequest();

        // Store the sorting in the session
        if ('tl_filters' === $request->request->get('FORM_SUBMIT')) {
            $sort = $request->request->get('tl_sort');

            if ('_default' !== $sort && \in_array($sort, $sorting, true)) {
                $session['sorting'][$dc->table] = $sort;
            } else {
                $session['sorting'][$dc->table] = null;
            }

            $bag->replace($session);
        }

        $options = [];

        // Generate the markup options
        foreach ($sorting as $option) {
            $options[] = \sprintf(
                '<option value="%s"%s>%s</option>',
                StringUtil::specialchars($option),
                ($session['sorting'][$dc->table] === $option) ? ' selected="selected"' : '',
                ('_default' === $option) ? $GLOBALS['TL_DCA'][$dc->table]['fields'][$GLOBALS['TL_DCA'][$dc->table]['list']['sorting']['fields'][0]]['label'][0] : $GLOBALS['TL_LANG'][$dc->table]['sortRef'][$option]
            );
        }

        return '

<div class="tl_sorting tl_subpanel">
<strong>'.$GLOBALS['TL_LANG']['MSC']['sortBy'].':</strong>
<select name="tl_sort" id="tl_sort" class="tl_select">
'.\implode("\n", $options).'
</select>
</div>';
    }
1190090
public function describeValue(Exporter $exporter, $value): string
    {
        return (null !== $this->violatingKey ? 'key ' . $this->violatingKey . ' ' : '')
         . 'in ' . $exporter->export($value);
    }
1097467
public function getTypeForValue($value) : string
    {
        foreach ($this->handlers as $type => $handler) {
            if ($handler->canHandleValue($value)) {
                return $type;
            }
        }

        throw DataTypeException::handlerNotFoundForValue($value);
    }
1238720
public function describeValue(Exporter $exporter, $value): string
    {
        if (! $value instanceof \Throwable) {
            return parent::describeValue($exporter, $value);
        }

        return 'exception of type "' . get_class($value)
        . '" with message "' . $value->getMessage() . '" thrown in '
        . $value->getFile() . ' on line ' . $value->getLine();
    }
222788
public function describeValue(Exporter $exporter, $value): string
    {
        if ($this->isCountable($value)) {
            if (is_string($value)) {
                $type = 'string';
            } elseif (is_array($value)) {
                $type = 'array';
            } else {
                $type = 'instance of type ' . get_class($value);
            }

            return $type . ' with actual size ' . $this->sizeOf($value);
        }

        return parent::describeValue($exporter, $value);
    }
35373
public function itemValuetoStringRepresentation($value)
    {
        if (is_bool($value))
        {
            $castedValue = (true === $value) ? 'true' : 'false';
        }
        elseif (is_null($value))
        {
            $castedValue = 'null';
        }
        elseif (is_array($value))
        {
            $castedValue = [];
            foreach ($value as $k => $v)
            {
                $castedValue[$k] = $this->itemValuetoStringRepresentation($v);
            }
        }
        elseif (is_numeric($value))
        {
            $castedValue = (string)$value;
        }
        elseif (is_string($value))
        {
            $castedValue = $value;
        }
        else
        {
            throw new InvalidDataException('Invalid item value type!');
        }

        return $castedValue;
    }
1338860
public function setValue($value, $data = null)
    {
        $value = $this->preventHtmlParserError($value);
        return parent::setValue($value, $data);
    }
387649
private function generateFormElements($value)
    {
        $form = $label = '';
        $label = Inflector::underscoreToSpace($value['COLUMN_NAME']);
        $form .= "\t\t".'->addElement("label", "'.$label.'", ["class" => "col-sm-2 control-label","style" => "width:100%;"])'.PHP_EOL;

        $form .= "\t\t".'->addElement("text", "'.$value['COLUMN_NAME'].'", ["value" => (isset($this->model->'.$value['COLUMN_NAME'].')) ? $this->model->'.$value['COLUMN_NAME'].' : "", "class" => "form-control"])'.PHP_EOL;

        return $form;
    }
903465
public function resourceName($value = null)
    {
        if ($value === null) {
            return $this->_action()->resourceName();
        }

        return $this->_action()->resourceName($value);
    }
977742
public function getConfigurationParameterName($value = null)
    {
        $output = '';

        if (!empty($this->_parent) && $this->_parent instanceof Parameter) {
            $output .= $this->_parent->getConfigurationParameterName();
        }

        if (!empty($this->_name)) {
            if (!empty($output)) $output .= '->';

            $output .= $this->_name;
        } else {
            if (!empty($output)) $output .= '->';

            $output .= '{unspecified}';
        }

        if (!empty($value)) {
            if (!empty($output)) $output .= '->';

            $output .= $value;
        }

        return $output;
    }
1207843
public function onFieldSave(string $value, DataContainer $dc): string
    {
        $manager = $this->getManagerFromDca($dc);

        if ($manager instanceof DcaAwareInterface) {
            $value = $manager->saveDcaField($value, $dc);
        }

        return $value;
    }