Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -0,0 +1,85 @@
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Component\Routing\Enhancer;
use Symfony\Component\HttpFoundation\Request;
/**
* This enhancer sets a field if not yet existing from the class of an object
* in another field.
*
* The comparison is done with instanceof to support proxy classes and such.
*
* Only works with RouteObjectInterface routes that can return a referenced
* content.
*
* @author David Buchmann
*/
class FieldByClassEnhancer implements RouteEnhancerInterface
{
/**
* @var string field for the source class
*/
protected $source;
/**
* @var string field to write hashmap lookup result into
*/
protected $target;
/**
* @var array containing the mapping between a class name and the target value
*/
protected $map;
/**
* @param string $source the field name of the class
* @param string $target the field name to set from the map
* @param array $map the map of class names to field values
*/
public function __construct($source, $target, $map)
{
$this->source = $source;
$this->target = $target;
$this->map = $map;
}
/**
* If the source field is instance of one of the entries in the map,
* target is set to the value of that map entry.
*
* {@inheritDoc}
*/
public function enhance(array $defaults, Request $request)
{
if (isset($defaults[$this->target])) {
// no need to do anything
return $defaults;
}
if (! isset($defaults[$this->source])) {
return $defaults;
}
// we need to loop over the array and do instanceof in case the content
// class extends the specified class
// i.e. phpcr-odm generates proxy class for the content.
foreach ($this->map as $class => $value) {
if ($defaults[$this->source] instanceof $class) {
// found a matching entry in the map
$defaults[$this->target] = $value;
return $defaults;
}
}
return $defaults;
}
}

View file

@ -0,0 +1,70 @@
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Component\Routing\Enhancer;
use Symfony\Component\HttpFoundation\Request;
/**
* This enhancer can fill one field with the result of a hashmap lookup of
* another field. If the target field is already set, it does nothing.
*
* @author David Buchmann
*/
class FieldMapEnhancer implements RouteEnhancerInterface
{
/**
* @var string field for key in hashmap lookup
*/
protected $source;
/**
* @var string field to write hashmap lookup result into
*/
protected $target;
/**
* @var array containing the mapping between the source field value and target field value
*/
protected $hashmap;
/**
* @param string $source the field to read
* @param string $target the field to write the result of the lookup into
* @param array $hashmap for looking up value from source and get value for target
*/
public function __construct($source, $target, array $hashmap)
{
$this->source = $source;
$this->target = $target;
$this->hashmap = $hashmap;
}
/**
* If the target field is not set but the source field is, map the field
*
* {@inheritDoc}
*/
public function enhance(array $defaults, Request $request)
{
if (isset($defaults[$this->target])) {
return $defaults;
}
if (! isset($defaults[$this->source])) {
return $defaults;
}
if (! isset($this->hashmap[$defaults[$this->source]])) {
return $defaults;
}
$defaults[$this->target] = $this->hashmap[$defaults[$this->source]];
return $defaults;
}
}

View file

@ -0,0 +1,76 @@
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Component\Routing\Enhancer;
use Symfony\Component\HttpFoundation\Request;
/**
* This enhancer sets a field to a fixed value. You can specify a source field
* name to only set the target field if the source is present.
*
* @author David Buchmann
*/
class FieldPresenceEnhancer implements RouteEnhancerInterface
{
/**
* Field name for the source field that must exist. If null, the target
* field is always set if not already present.
*
* @var string|null
*/
protected $source;
/**
* Field name to write the value into.
*
* @var string
*/
protected $target;
/**
* Value to set the target field to.
*
* @var string
*/
private $value;
/**
* @param null|string $source the field name of the class, null to disable the check
* @param string $target the field name to set from the map
* @param string $value value to set target field to if source field exists
*/
public function __construct($source, $target, $value)
{
$this->source = $source;
$this->target = $target;
$this->value = $value;
}
/**
* {@inheritDoc}
*/
public function enhance(array $defaults, Request $request)
{
if (isset($defaults[$this->target])) {
// no need to do anything
return $defaults;
}
if (null !== $this->source && !isset($defaults[$this->source])) {
return $defaults;
}
$defaults[$this->target] = $this->value;
return $defaults;
}
}

View file

@ -0,0 +1,79 @@
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Component\Routing\Enhancer;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
/**
* This enhancer sets the content to target field if the route provides content.
*
* Only works with RouteObjectInterface routes that can return a referenced
* content.
*
* @author David Buchmann
*/
class RouteContentEnhancer implements RouteEnhancerInterface
{
/**
* @var string field for the route class
*/
protected $routefield;
/**
* @var string field to write hashmap lookup result into
*/
protected $target;
/**
* @param string $routefield the field name of the route class
* @param string $target the field name to set from the map
* @param array $hashmap the map of class names to field values
*/
public function __construct($routefield, $target)
{
$this->routefield = $routefield;
$this->target = $target;
}
/**
* If the route has a non-null content and if that content class is in the
* injected map, returns that controller.
*
* {@inheritDoc}
*/
public function enhance(array $defaults, Request $request)
{
if (isset($defaults[$this->target])) {
// no need to do anything
return $defaults;
}
if (! isset($defaults[$this->routefield])
|| ! $defaults[$this->routefield] instanceof RouteObjectInterface
) {
// we can't determine the content
return $defaults;
}
/** @var $route RouteObjectInterface */
$route = $defaults[$this->routefield];
$content = $route->getContent();
if (! $content) {
// we have no content
return $defaults;
}
$defaults[$this->target] = $content;
return $defaults;
}
}

View file

@ -0,0 +1,37 @@
<?php
/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Cmf\Component\Routing\Enhancer;
use Symfony\Component\HttpFoundation\Request;
/**
* A route enhancer can change the values in the route data arrays
*
* This is useful to provide information to the rest of the routing system
* that can be inferred from other parameters rather than hardcode that
* information in every route.
*
* @author David Buchmann
*/
interface RouteEnhancerInterface
{
/**
* Update the defaults based on its own data and the request.
*
* @param array $defaults the getRouteDefaults array.
* @param Request $request the Request instance.
*
* @return array the modified defaults. Each enhancer MUST return the
* $defaults but may add or remove values.
*/
public function enhance(array $defaults, Request $request);
}