Prepare the tree selector.

@param PickerInterface $picker The picker.

@return TreePicker

@throws \InvalidArgumentException If invalid characters in the data provider name or property name.

@SuppressWarnings(PHPMD.Superglobals)
498115
private function prepareTreeSelector(PickerInterface $picker)
    {
        $modelId = ModelId::fromSerialized($picker->getConfig()->getExtra('modelId'));

        if (Validator::isInsecurePath($table = $modelId->getDataProviderName())) {
            throw new \InvalidArgumentException('The table name contains invalid characters');
        }

        if (Validator::isInsecurePath($field = $picker->getConfig()->getExtra('propertyName'))) {
            throw new \InvalidArgumentException('The field name contains invalid characters');
        }

        $sessionBag = $this->container->get('session')->getBag('contao_backend');
        // Define the current ID.
        \define('CURRENT_ID', ($table ? $sessionBag->get('CURRENT_ID') : $modelId->getId()));

        $this->itemContainer = (new DcGeneralFactory())
            ->setContainerName($modelId->getDataProviderName())
            ->setTranslator($this->container->get('cca.translator.contao_translator'))
            ->setEventDispatcher($this->container->get('event_dispatcher'))
            ->createDcGeneral();

        // Merge with the information from the data container.
        $property = $this
            ->itemContainer
            ->getEnvironment()
            ->getDataDefinition()
            ->getPropertiesDefinition()
            ->getProperty($picker->getConfig()->getExtra('propertyName'));

        $information = (array) $GLOBALS['TL_DCA'][$table]['fields'][$field];
        if (!isset($information['eval'])) {
            $information['eval'] = array();
        }
        $information['eval'] = array_merge($property->getExtra(), $information['eval']);

        $treeSelector = new $GLOBALS['BE_FFL']['DcGeneralTreePicker'](
            Widget::getAttributesFromDca(
                $information,
                $field,
                \array_filter(\explode(',', $picker->getConfig()->getValue())),
                $field,
                $table,
                new DcCompat($this->itemContainer->getEnvironment())
            ),
            new DcCompat($this->itemContainer->getEnvironment())
        );

        $treeSelector->id = 'tl_listing';

        return $treeSelector;
    }
103842
public function set(CheckerInterface $checker): self
    {
        $this->checkers[$checker->getId()] = $checker;

        return $this;
    }
1306371
public function load(InputInterface $input): ConfigInterface
    {
        $configFile = $input->getOption('config');
        if (!$configFile || !$this->filesystem->fileExists($configFile)) {
            throw InvalidArgumentException::invalidConfigFile();
        }
        $config = include $configFile;
        if (!$config instanceof ConfigInterface) {
            throw InvalidArgumentException::invalidConfigFile();
        }

        return $config;
    }
991093
public function setDivider($divider)
    {
        if (!is_string($divider) && !is_null($divider)) {
            throw new \InvalidArgumentException(
                'Breadcrumbs::setDivider() only accepts strings or NULL, but '
                . (is_object($divider) ? get_class($divider) : gettype($divider))
                . ' given: ' . print_r($divider, true)
            );
        }

        $this->divider = $divider;

        return $this;
    }
448419
public function setParent($parent)
    {
        if (null === $parent) {
            $this->parent = null;

            return $this;
        }

        if (is_string($parent)) {
            $this->parent = new Role($parent);

            return $this;
        }

        if ($parent instanceof RoleInterface) {
            $this->parent = $parent;

            return $this;
        }

        throw Exception\InvalidRoleException::invalidRoleInstance($parent);
    }
869871
protected function loadConfiguration(InputInterface $input, $rootDir)
    {
        $coverallsYmlPath = $input->getOption('config');

        $ymlPath = $this->rootDir . DIRECTORY_SEPARATOR . $coverallsYmlPath;
        $configurator = new Configurator();

        return $configurator
            ->load($ymlPath, $rootDir, $input)
            ->setDryRun($input->getOption('dry-run'))
            ->setExcludeNoStatementsUnlessFalse($input->getOption('exclude-no-stmt'))
            ->setVerbose($input->getOption('verbose'))
            ->setEnv($input->getOption('env'));
    }
131166
protected function getTwig(\Twig_LoaderInterface $loader)
    {
        $twig = new \Twig_Environment($loader);
        $twig->setCache(false);

        return $twig;
    }
1149658
public function picker($query, $maxResults = null, $showAvatar = null, $exclude = null)
    {
        $parameters = array(
            'query' => $query,
            'maxResults' => $maxResults,
            'showAvatar' => $showAvatar,
            'exclude' => $exclude
        );
        return $this->apiClient->callEndpoint(sprintf('%s/picker', self::ENDPOINT), $parameters);
    }
640232
public function setAdapter(AdapterInterface $adapter)
    {
        $adapter->setClient($this);

        $this->adapter = $adapter;

        return $this;
    }
725759
public static function setDumper($dumper)
    {
        if (!$dumper instanceof interfaces\Dumper && !is_callable($dumper)) {
            throw new \InvalidArgumentException('Expected an instance of ['.interfaces\Dumper::class.'] or a callable, got ['.static::getTypeName($dumper).'] instead.');
        }

        static::$dumper = $dumper;
    }
16231
public function addDispatcher($name, DispatcherInterface $dispatcher)
    {
        $name = strtolower($name);

        $dispatcher->name = $name;

        $this->dispatchers[$name] = $dispatcher;

        return $this;
    }
1059224
public function getLoader(): LoaderInterface
    {
        if (!isset($this->i__loader)) {
            $this->i__loader = new DelegateLoader();
        }

        return $this->i__loader;
    }
1150184
public function setLoaders(array $loaders)
    {
        $this->loaders = array();
        foreach ($loaders as $type=>$loader) {
            if (!$loader instanceof ResourceLoaderInterface) {
                throw new \InvalidArgumentException("Not a valid resource loader.");
            }
            $this->loaders[$type] = $loader;
        }
    }
942763
public function makeValidator($validator = null)
    {
        $validator = !is_null($validator) ? $validator : $this->validator();

        if (!is_null($validator)) {
            $this->validator = is_string($validator) ? $this->app->make($validator) : $validator;

            if (!$this->validator instanceof ValidatorInterface) {
                throw new RepositoryException("Class {$validator} must be an instance of Prettus\\Validator\\Contracts\\ValidatorInterface");
            }

            return $this->validator;
        }

        return null;
    }
1434
public function dispatch($dispatcher = null, $path = null, $method = null)
    {
        if (!$dispatcher) {
            $dispatcher = new Dispatcher;
        } elseif (\is_array($dispatcher)) {
            $dispatcher = new Dispatcher($dispatcher);
        }

        if (!$dispatcher instanceof DispatcherInterface) {
            throw new \InvalidArgumentException(
                'The first argument is must an array OR an object instanceof the DispatcherInterface'
            );
        }

        if (!$dispatcher->hasRouter()) {
            $dispatcher->setRouter($this);
        }

        return $dispatcher->dispatchUri($path, $method);
    }
853957
public function setFormatter(Formatter $formatter)
    {
        $this->formatter = $formatter;
        $format = $this;

        return $this
            ->setOptionsRecursive($formatter->getOptions())
            ->registerHelper(
                'dependencies_storage',
                $formatter->getOption('dependencies_storage')
            )->registerHelper(
                'helper_prefix',
                static::class.'::'
            )->provideHelper(
                'get_helper',
                [
                    'dependencies_storage',
                    'helper_prefix',
                    function ($dependenciesStorage, $prefix) use ($format) {
                        return function ($name) use ($dependenciesStorage, $prefix, $format) {
                            if (!isset($$dependenciesStorage)) {
                                return $format->getHelper($name);
                            }

                            $storage = $$dependenciesStorage;

                            if (!array_key_exists($prefix.$name, $storage) &&
                                !isset($storage[$prefix.$name])
                            ) {
                                throw new \Exception(
                                    var_export($name, true).
                                    ' dependency not found in the namespace: '.
                                    var_export($prefix, true)
                                );
                            }

                            return $storage[$prefix.$name];
                        };
                    },
                ]
            );
    }
1022968
public function setGetter($getter)
    {
        if (!is_bool($getter)) {
            throw new \InvalidArgumentException('The attribute getter on the class Attribute has to be boolean (' . gettype($getter) . ('object' === gettype($getter) ? ' ' . get_class($getter) : '') . ' given).');
        }

        $this->getter = $getter;

        return $this;
    }