Commit 73b5652a authored by alexpott's avatar alexpott
Browse files

Issue #2470693 by dawehner, Berdir, jibran, hussainweb, pwolanin, znerol: Upgrade to Symfony 2.7.0

parent 7786d91c
......@@ -6,18 +6,19 @@
"require": {
"php": ">=5.4.5",
"sdboyer/gliph": "0.1.*",
"symfony/class-loader": "2.6.*",
"symfony/console": "2.6.*",
"symfony/css-selector": "2.6.*",
"symfony/dependency-injection": "2.6.*",
"symfony/event-dispatcher": "2.6.*",
"symfony/http-foundation": "2.6.*",
"symfony/http-kernel": "2.6.*",
"symfony/routing": "2.6.*",
"symfony/serializer": "2.6.*",
"symfony/validator": "2.6.*@dev",
"symfony/process": "2.6.*",
"symfony/yaml": "2.6.*",
"symfony/class-loader": "2.7.*",
"symfony/console": "2.7.*",
"symfony/css-selector": "2.7.*",
"symfony/dependency-injection": "2.7.*",
"symfony/event-dispatcher": "2.7.*",
"symfony/http-foundation": "2.7.*",
"symfony/http-kernel": "2.7.*",
"symfony/routing": "2.7.*",
"symfony/serializer": "2.7.*",
"symfony/translation": "2.7.*",
"symfony/validator": "2.7.*",
"symfony/process": "2.7.*",
"symfony/yaml": "2.7.*",
"twig/twig": "1.18.*",
"doctrine/common": "~2.4.2",
"doctrine/annotations": "1.2.*",
......@@ -34,6 +35,8 @@
"fabpot/goutte": "^2.0.3",
"masterminds/html5": "~2.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Drupal\\Core\\": "lib/Drupal/Core",
......
This diff is collapsed.
......@@ -144,57 +144,49 @@ services:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin, default_backend: cache.backend.chainedfast }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [bootstrap]
cache.config:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin, default_backend: cache.backend.chainedfast }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [config]
cache.default:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [default]
cache.entity:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [entity]
cache.menu:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [menu]
cache.render:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [render]
cache.data:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [data]
cache.discovery:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin, default_backend: cache.backend.chainedfast }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [discovery]
cache_router_rebuild_subscriber:
class: Drupal\Core\EventSubscriber\CacheRouterRebuildSubscriber
......@@ -253,13 +245,11 @@ services:
- { name: backend_overridable }
config.storage.file:
class: Drupal\Core\Config\FileStorage
factory_class: Drupal\Core\Config\FileStorageFactory
factory_method: getActive
factory: Drupal\Core\Config\FileStorageFactory::getActive
public: false
config.storage.staging:
class: Drupal\Core\Config\FileStorage
factory_class: Drupal\Core\Config\FileStorageFactory
factory_method: getStaging
factory: Drupal\Core\Config\FileStorageFactory::getStaging
config.storage.snapshot:
class: Drupal\Core\Config\DatabaseStorage
arguments: ['@database', config_snapshot]
......@@ -285,8 +275,7 @@ services:
arguments: ['@config.factory']
database:
class: Drupal\Core\Database\Connection
factory_class: Drupal\Core\Database\Database
factory_method: getConnection
factory: Drupal\Core\Database\Database::getConnection
arguments: [default]
file_system:
class: Drupal\Core\File\FileSystem
......@@ -324,8 +313,7 @@ services:
logger.channel_base:
abstract: true
class: Drupal\Core\Logger\LoggerChannel
factory_method: get
factory_service: logger.factory
factory: logger.factory:get
logger.channel.default:
parent: logger.channel_base
arguments: ['system']
......@@ -340,8 +328,7 @@ services:
arguments: ['cron']
logger.channel.file:
class: Drupal\Core\Logger\LoggerChannel
factory_method: get
factory_service: logger.factory
factory: logger.factory:get
arguments: ['file']
logger.channel.form:
parent: logger.channel_base
......@@ -358,8 +345,7 @@ services:
settings:
class: Drupal\Core\Site\Settings
factory_class: Drupal\Core\Site\Settings
factory_method: getInstance
factory: Drupal\Core\Site\Settings::getInstance
state:
class: Drupal\Core\State\State
arguments: ['@keyvalue']
......@@ -546,8 +532,7 @@ services:
arguments: ['@service_container']
app.root:
class: SplString
factory_service: 'app.root.factory'
factory_method: 'get'
factory: app.root.factory:get
tags:
- { name: parameter_service }
app.root.factory:
......@@ -617,8 +602,7 @@ services:
- { name: service_collector, tag: string_translator, call: addTranslator }
database.replica:
class: Drupal\Core\Database\Connection
factory_class: Drupal\Core\Database\Database
factory_method: getConnection
factory: Drupal\Core\Database\Database::getConnection
arguments: [replica]
typed_data_manager:
class: Drupal\Core\TypedData\TypedDataManager
......
......@@ -24,14 +24,14 @@ public static function preAutoloadDump(Event $event) {
$package = $composer->getPackage();
$autoload = $package->getAutoload();
$autoload['classmap'] = array_merge($autoload['classmap'], array(
'vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php',
'vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php',
'vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php',
'vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php',
'vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php',
'vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php',
'vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php',
'vendor/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php'
'vendor/symfony/http-foundation/Request.php',
'vendor/symfony/http-foundation/ParameterBag.php',
'vendor/symfony/http-foundation/FileBag.php',
'vendor/symfony/http-foundation/ServerBag.php',
'vendor/symfony/http-foundation/HeaderBag.php',
'vendor/symfony/http-kernel/HttpKernel.php',
'vendor/symfony/http-kernel/HttpKernelInterface.php',
'vendor/symfony/http-kernel/TerminableInterface.php',
));
$package->setAutoload($autoload);
}
......
......@@ -43,10 +43,6 @@ public function __construct(ParameterBagInterface $parameterBag = NULL) {
public function set($id, $service, $scope = self::SCOPE_CONTAINER) {
SymfonyContainer::set($id, $service, $scope);
if ($this->hasDefinition($id) && ($definition = $this->getDefinition($id)) && $definition->isSynchronized()) {
$this->synchronize($id);
}
// Ensure that the _serviceId property is set on synthetic services as well.
if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) {
$this->services[$id]->_serviceId = $id;
......
......@@ -83,6 +83,10 @@ public function load($file)
// parameters
if (isset($content['parameters'])) {
if (!is_array($content['parameters'])) {
throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $file));
}
foreach ($content['parameters'] as $key => $value) {
$this->container->setParameter($key, $this->resolveServices($value));
}
......@@ -108,6 +112,10 @@ private function parseDefinitions($content, $file)
return;
}
if (!is_array($content['services'])) {
throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file));
}
foreach ($content['services'] as $id => $service) {
$this->parseDefinition($id, $service, $file);
}
......@@ -128,8 +136,14 @@ private function parseDefinition($id, $service, $file)
$this->container->setAlias($id, substr($service, 1));
return;
} elseif (isset($service['alias'])) {
$public = !array_key_exists('public', $service) || (Boolean) $service['public'];
}
if (!is_array($service)) {
throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but %s found for service "%s" in %s. Check your YAML syntax.', gettype($service), $id, $file));
}
if (isset($service['alias'])) {
$public = !array_key_exists('public', $service) || (bool) $service['public'];
$this->container->setAlias($id, new Alias($service['alias'], $public));
return;
......@@ -154,7 +168,7 @@ private function parseDefinition($id, $service, $file)
}
if (isset($service['synchronized'])) {
$definition->setSynchronized($service['synchronized']);
$definition->setSynchronized($service['synchronized'], 'request' !== $id);
}
if (isset($service['lazy'])) {
......@@ -169,6 +183,19 @@ private function parseDefinition($id, $service, $file)
$definition->setAbstract($service['abstract']);
}
if (isset($service['factory'])) {
if (is_string($service['factory'])) {
if (strpos($service['factory'], ':') !== false && strpos($service['factory'], '::') === false) {
$parts = explode(':', $service['factory']);
$definition->setFactory(array($this->resolveServices('@'.$parts[0]), $parts[1]));
} else {
$definition->setFactory($service['factory']);
}
} else {
$definition->setFactory(array($this->resolveServices($service['factory'][0]), $service['factory'][1]));
}
}
if (isset($service['factory_class'])) {
$definition->setFactoryClass($service['factory_class']);
}
......@@ -202,18 +229,33 @@ private function parseDefinition($id, $service, $file)
}
if (isset($service['calls'])) {
if (!is_array($service['calls'])) {
throw new InvalidArgumentException(sprintf('Parameter "calls" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
}
foreach ($service['calls'] as $call) {
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
$definition->addMethodCall($call[0], $args);
if (isset($call['method'])) {
$method = $call['method'];
$args = isset($call['arguments']) ? $this->resolveServices($call['arguments']) : array();
} else {
$method = $call[0];
$args = isset($call[1]) ? $this->resolveServices($call[1]) : array();
}
$definition->addMethodCall($method, $args);
}
}
if (isset($service['tags'])) {
if (!is_array($service['tags'])) {
throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s.', $id, $file));
throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
}
foreach ($service['tags'] as $tag) {
if (!is_array($tag)) {
throw new InvalidArgumentException(sprintf('A "tags" entry must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
}
if (!isset($tag['name'])) {
throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file));
}
......@@ -223,7 +265,7 @@ private function parseDefinition($id, $service, $file)
foreach ($tag as $attribute => $value) {
if (!is_scalar($value) && null !== $value) {
throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s.', $id, $name, $attribute, $file));
throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s. Check your YAML syntax.', $id, $name, $attribute, $file));
}
}
......@@ -231,6 +273,11 @@ private function parseDefinition($id, $service, $file)
}
}
if (isset($service['decorates'])) {
$renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null;
$definition->setDecoratedService($service['decorates'], $renameId);
}
$this->container->setDefinition($id, $definition);
}
......@@ -240,6 +287,8 @@ private function parseDefinition($id, $service, $file)
* @param string $file
*
* @return array The file content
*
* @throws InvalidArgumentException when the given file is not a local file or when it does not exist
*/
protected function loadFile($file)
{
......@@ -271,7 +320,7 @@ private function validate($content, $file)
}
if (!is_array($content)) {
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid: it is not an array.', $file));
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file));
}
if ($invalid_keys = array_diff_key($content, array('parameters' => 1, 'services' => 1))) {
......@@ -284,9 +333,9 @@ private function validate($content, $file)
/**
* Resolves services.
*
* @param string $value
* @param string|array $value
*
* @return Reference
* @return array|string|Reference
*/
private function resolveServices($value)
{
......
......@@ -39,8 +39,16 @@ public function __construct(RouteMatchInterface $route_match) {
public function processOutbound($route_name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) {
if ($route_name === '<current>') {
if ($current_route = $this->routeMatch->getRouteObject()) {
$requirements = $current_route->getRequirements();
// Setting _method and _schema is deprecated since 2.7. Using
// setMethods() and setSchemes() are now the recommended ways.
unset($requirements['_method']);
unset($requirements['_schema']);
$route->setRequirements($requirements);
$route->setPath($current_route->getPath());
$route->setRequirements($current_route->getRequirements());
$route->setSchemes($current_route->getSchemes());
$route->setMethods($current_route->getMethods());
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
......
......@@ -168,9 +168,13 @@ public function rebuild() {
'defaults' => array(),
'requirements' => array(),
'options' => array(),
'host' => NULL,
'schemes' => array(),
'methods' => array(),
'condition' => '',
);
$route = new Route($route_info['path'], $route_info['defaults'], $route_info['requirements'], $route_info['options']);
$route = new Route($route_info['path'], $route_info['defaults'], $route_info['requirements'], $route_info['options'], $route_info['host'], $route_info['schemes'], $route_info['methods'], $route_info['condition']);
$collection->add($name, $route);
}
}
......
......@@ -345,8 +345,8 @@ public function generateFromRoute($name, $parameters = array(), $options = array
else {
$scheme = $this->context->getScheme();
}
$scheme_req = $route->getRequirement('_scheme');
if (isset($scheme_req) && ($req = strtolower($scheme_req)) && $scheme !== $req) {
$scheme_req = $route->getSchemes();
if ($scheme_req && ($req = $scheme_req[0]) && $scheme !== $req) {
$scheme = $req;
}
$port = '';
......
......@@ -2,12 +2,12 @@
/**
* @file
* Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\NullConstraint.
* Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraint.
*/
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraints\Null;
use Symfony\Component\Validator\Constraints\IsNull;
/**
* Null constraint.
......@@ -20,4 +20,4 @@
* type = false
* )
*/
class NullConstraint extends Null { }
class IsNullConstraint extends IsNull { }
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\NullConstraintValidator.
* Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator.
*/
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
......@@ -11,14 +11,14 @@
use Drupal\Core\TypedData\ListInterface;
use Drupal\Core\TypedData\Validation\TypedDataAwareValidatorTrait;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\NullValidator;
use Symfony\Component\Validator\Constraints\IsNullValidator;
/**
* Null constraint validator.
*
* Overrides the symfony validator to handle empty Typed Data structures.
*/
class NullConstraintValidator extends NullValidator {
class IsNullConstraintValidator extends IsNullValidator {
use TypedDataAwareValidatorTrait;
......
......@@ -37,11 +37,13 @@ public function __construct(StateInterface $state) {
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The configuration event.
* @param string $name
* The event name.
*/
public function configEventRecorder(ConfigCrudEvent $event) {
public function configEventRecorder(ConfigCrudEvent $event, $name) {
$config = $event->getConfig();
$this->state->set('config_events_test.event', array(
'event_name' => $event->getName(),
'event_name' => $name,
'current_config_data' => $config->get(),
'original_config_data' => $config->getOriginal(),
'raw_config_data' => $config->getRawData()
......
......@@ -9,6 +9,5 @@ services:
arguments: ['@plugin.manager.mail', '@language_manager', '@logger.channel.contact', '@string_translation', '@entity.manager']
logger.channel.contact:
class: Drupal\Core\Logger\LoggerChannel
factory_method: get
factory_service: logger.factory
factory: logger.factory:get
arguments: ['contact']
......@@ -351,7 +351,7 @@ public function massageFormValues(array $values, array $form, FormStateInterface
public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($violations as $offset => $violation) {
$parameters = $violation->getMessageParameters();
$parameters = $violation->getParameters();
if (isset($parameters['@uri'])) {
$parameters['@uri'] = static::getUriAsDisplayableString($parameters['@uri']);
$violations->set($offset, new ConstraintViolation(
......@@ -361,7 +361,7 @@ public function flagErrors(FieldItemListInterface $items, ConstraintViolationLis
$violation->getRoot(),
$violation->getPropertyPath(),
$violation->getInvalidValue(),
$violation->getMessagePluralization(),
$violation->getPlural(),
$violation->getCode()
));
}
......
......@@ -3,8 +3,7 @@ services:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [migrate]
plugin.manager.migrate.source:
class: Drupal\migrate\Plugin\MigratePluginManager
......
......@@ -6,8 +6,7 @@ services:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory_method: get
factory_service: cache_factory
factory: cache_factory:get
arguments: [rest]
access_check.rest.csrf:
class: Drupal\rest\Access\CSRFAccessCheck
......
......@@ -111,7 +111,7 @@ public function routes() {
switch ($method) {
case 'POST':
$route->setPattern($create_path);
$route->setPath($create_path);
// Restrict the incoming HTTP Content-type header to the known
// serialization formats.
$route->addRequirements(array('_content_type_format' => implode('|', $this->serializerFormats)));
......@@ -203,10 +203,14 @@ protected function getBaseRoute($canonical_path, $method) {
// Pass the resource plugin ID along as default property.
'_plugin' => $this->pluginId,
), array(
// The HTTP method is a requirement for this route.
'_method' => $method,
'_permission' => "restful $lower_method $this->pluginId",
));
),
array(),
'',
array(),
// The HTTP method is a requirement for this route.
array($method)
);
return $route;
}
......
......@@ -263,7 +263,7 @@ public function collectRoutes(RouteCollection $collection) {
if ($route = $collection->get("view.$view_id.$display_id")) {
$style_plugin = $this->getPlugin('style');
// REST exports should only respond to get methods.
$requirements = array('_method' => 'GET');
$route->setMethods(['GET']);
// Format as a string using pipes as a delimiter.
$requirements['_format'] = implode('|', $style_plugin->getFormats());
......
......@@ -74,9 +74,10 @@ protected function alterRoutes(RouteCollection $collection) {
$plugin = $this->manager->getInstance(array('id' => $id));
foreach ($plugin->routes() as $name => $route) {
$method = $route->getRequirement('_method');
// @todo: Are multiple methods possible here?
$methods = $route->getMethods();
// Only expose routes where the method is enabled in the configuration.
if ($method && isset($enabled_methods[$method])) {
if ($methods && ($method = $methods[0]) && $method && isset($enabled_methods[$method])) {
$route->setRequirement('_access_rest_csrf', 'TRUE');
// Check that authentication providers are defined.
......
......@@ -708,7 +708,8 @@ protected function setUp() {
if ($this->strictConfigSchema) {
// Add a listener to validate configuration schema on save.
$yaml = new \Symfony\Component\Yaml\Yaml();
$services = $yaml->parse($directory . '/services.yml');
$content = file_get_contents($directory . '/services.yml');
$services = $yaml->parse($content);
$services['services']['simpletest.config_schema_checker'] = [
'class' => 'Drupal\Core\Config\Testing\ConfigSchemaChecker',
'arguments' => ['@config.typed'],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment