/** * Expands wildcards in schema update types, e.g. field.* or *.change * * @param array $schemaUpdateTypes List of schema update types * @return SchemaUpdateType[] * @throws \UnexpectedValueException If an invalid schema update type was passed */ protected function expandSchemaUpdateTypes(array $schemaUpdateTypes) { $expandedSchemaUpdateTypes = array(); $schemaUpdateTypeConstants = array_values(SchemaUpdateType::getConstants()); // Collect total list of types by expanding wildcards foreach ($schemaUpdateTypes as $schemaUpdateType) { if (strpos($schemaUpdateType, '*') !== FALSE) { $matchPattern = '/' . str_replace('\\*', '.+', preg_quote($schemaUpdateType, '/')) . '/'; $matchingSchemaUpdateTypes = preg_grep($matchPattern, $schemaUpdateTypeConstants); $expandedSchemaUpdateTypes = array_merge($expandedSchemaUpdateTypes, $matchingSchemaUpdateTypes); } else { $expandedSchemaUpdateTypes[] = $schemaUpdateType; } } // Cast to enumeration objects to ensure valid values foreach ($expandedSchemaUpdateTypes as &$schemaUpdateType) { try { $schemaUpdateType = SchemaUpdateType::cast($schemaUpdateType); } catch (InvalidEnumerationValueException $e) { throw new \UnexpectedValueException(sprintf('Invalid schema update type "%s", must be one of: "%s"', $schemaUpdateType, implode('", "', $schemaUpdateTypeConstants)), 1439460396); } } return $expandedSchemaUpdateTypes; }