Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
70
vendor/symfony-cmf/routing/Enhancer/ContentRepositoryEnhancer.php
vendored
Normal file
70
vendor/symfony-cmf/routing/Enhancer/ContentRepositoryEnhancer.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2015 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\Cmf\Component\Routing\ContentRepositoryInterface;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* This enhancer uses a ContentRepositoryInterface to load a content if $target
|
||||
* is empty.
|
||||
*
|
||||
* $source specifies the field that contains the ID to load, $target specifies
|
||||
* the field where to put the content returned by the repository.
|
||||
*
|
||||
* @author Samusev Andrey
|
||||
*/
|
||||
class ContentRepositoryEnhancer implements RouteEnhancerInterface
|
||||
{
|
||||
/**
|
||||
* @var ContentRepositoryInterface
|
||||
*/
|
||||
private $contentRepository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $target;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @param ContentRepositoryInterface $contentRepository repository to search for the content
|
||||
* @param string $target the field name to set content
|
||||
* @param string $source the field name of the request parameter that contains the id
|
||||
*/
|
||||
public function __construct(
|
||||
ContentRepositoryInterface $contentRepository,
|
||||
$target = RouteObjectInterface::CONTENT_OBJECT,
|
||||
$source = RouteObjectInterface::CONTENT_ID
|
||||
) {
|
||||
$this->contentRepository = $contentRepository;
|
||||
$this->target = $target;
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
if (!isset($defaults[$this->target]) && isset($defaults[$this->source])) {
|
||||
$defaults[$this->target] = $this->contentRepository->findById($defaults[$this->source]);
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -55,7 +55,7 @@ class FieldByClassEnhancer implements RouteEnhancerInterface
|
|||
* 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}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ class FieldByClassEnhancer implements RouteEnhancerInterface
|
|||
return $defaults;
|
||||
}
|
||||
|
||||
if (! isset($defaults[$this->source])) {
|
||||
if (!isset($defaults[$this->source])) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -47,19 +47,19 @@ class FieldMapEnhancer implements RouteEnhancerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* If the target field is not set but the source field is, map the field
|
||||
* If the target field is not set but the source field is, map the field.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
if (isset($defaults[$this->target])) {
|
||||
return $defaults;
|
||||
}
|
||||
if (! isset($defaults[$this->source])) {
|
||||
if (!isset($defaults[$this->source])) {
|
||||
return $defaults;
|
||||
}
|
||||
if (! isset($this->hashmap[$defaults[$this->source]])) {
|
||||
if (!isset($this->hashmap[$defaults[$this->source]])) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -56,7 +56,7 @@ class FieldPresenceEnhancer implements RouteEnhancerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -12,7 +12,6 @@
|
|||
namespace Symfony\Cmf\Component\Routing\Enhancer;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +48,7 @@ class RouteContentEnhancer implements RouteEnhancerInterface
|
|||
* If the route has a non-null content and if that content class is in the
|
||||
* injected map, returns that controller.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
|
@ -58,8 +57,8 @@ class RouteContentEnhancer implements RouteEnhancerInterface
|
|||
return $defaults;
|
||||
}
|
||||
|
||||
if (! isset($defaults[$this->routefield])
|
||||
|| ! $defaults[$this->routefield] instanceof RouteObjectInterface
|
||||
if (!isset($defaults[$this->routefield])
|
||||
|| !$defaults[$this->routefield] instanceof RouteObjectInterface
|
||||
) {
|
||||
// we can't determine the content
|
||||
return $defaults;
|
||||
|
@ -68,7 +67,7 @@ class RouteContentEnhancer implements RouteEnhancerInterface
|
|||
$route = $defaults[$this->routefield];
|
||||
|
||||
$content = $route->getContent();
|
||||
if (! $content) {
|
||||
if (!$content) {
|
||||
// we have no content
|
||||
return $defaults;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -14,7 +14,7 @@ namespace Symfony\Cmf\Component\Routing\Enhancer;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* A route enhancer can change the values in the route data arrays
|
||||
* 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
|
||||
|
|
Reference in a new issue