Pimcore\Console\Command\CacheWarmingCommand::getArrayOption PHP Method

getArrayOption() protected method

Get one of types, document, asset or object types, handle "all" value and list input validation.
protected getArrayOption ( $option, $property, $singular, boolean $fallback = false ) : mixed
$option
$property
$singular
$fallback boolean
return mixed
    protected function getArrayOption($option, $property, $singular, $fallback = false)
    {
        $input = $this->input->getOption($option);
        // fall back to whole list if fallback is set
        if (!$input || count($input) === 0) {
            if ($fallback) {
                $input = $this->{$property};
            } else {
                $input = null;
            }
        }
        if (null !== $input) {
            foreach ($input as $value) {
                if (!in_array($value, $this->{$property})) {
                    $message = sprintf('Invalid %s: %s', $singular, $value);
                    throw new \InvalidArgumentException($message);
                }
            }
        }
        return $input;
    }