9 use Symfony\Component\Console\Input\InputArgument;
10 use Symfony\Component\Console\Input\InputInterface;
29 self::INPUT_KEY_TYPES,
30 InputArgument::IS_ARRAY,
31 'Space-separated list of cache types or omit to apply to all cache types.' 45 if ($input->getArgument(self::INPUT_KEY_TYPES)) {
46 $requestedTypes = $input->getArgument(self::INPUT_KEY_TYPES);
47 $requestedTypes = array_filter(array_map(
'trim', $requestedTypes),
'strlen');
49 if (empty($requestedTypes)) {
50 return $this->cacheManager->getAvailableTypes();
52 $availableTypes = $this->cacheManager->getAvailableTypes();
53 $unsupportedTypes = array_diff($requestedTypes, $availableTypes);
54 if ($unsupportedTypes) {
55 throw new \InvalidArgumentException(
56 "The following requested cache types are not supported: '" . join(
"', '", $unsupportedTypes)
57 .
"'." . PHP_EOL .
'Supported types: ' . join(
", ", $availableTypes)
60 return array_values(array_intersect($availableTypes, $requestedTypes));
getRequestedTypes(InputInterface $input)