Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 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;
|
||||
}
|
||||
}
|
85
vendor/symfony-cmf/routing/Enhancer/FieldByClassEnhancer.php
vendored
Normal file
85
vendor/symfony-cmf/routing/Enhancer/FieldByClassEnhancer.php
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?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\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;
|
||||
}
|
||||
}
|
70
vendor/symfony-cmf/routing/Enhancer/FieldMapEnhancer.php
vendored
Normal file
70
vendor/symfony-cmf/routing/Enhancer/FieldMapEnhancer.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\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;
|
||||
}
|
||||
}
|
76
vendor/symfony-cmf/routing/Enhancer/FieldPresenceEnhancer.php
vendored
Normal file
76
vendor/symfony-cmf/routing/Enhancer/FieldPresenceEnhancer.php
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?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\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;
|
||||
}
|
||||
}
|
78
vendor/symfony-cmf/routing/Enhancer/RouteContentEnhancer.php
vendored
Normal file
78
vendor/symfony-cmf/routing/Enhancer/RouteContentEnhancer.php
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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\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;
|
||||
}
|
||||
}
|
37
vendor/symfony-cmf/routing/Enhancer/RouteEnhancerInterface.php
vendored
Normal file
37
vendor/symfony-cmf/routing/Enhancer/RouteEnhancerInterface.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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\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);
|
||||
}
|
Reference in a new issue