Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -203,7 +203,7 @@ class DateTimePlus {
|
|||
$datetimeplus = new static('', $timezone, $settings);
|
||||
|
||||
$date = \DateTime::createFromFormat($format, $time, $datetimeplus->getTimezone());
|
||||
if (!$date instanceOf \DateTime) {
|
||||
if (!$date instanceof \DateTime) {
|
||||
throw new \Exception('The date cannot be created from a format.');
|
||||
}
|
||||
else {
|
||||
|
@ -212,10 +212,10 @@ class DateTimePlus {
|
|||
// re-creating the date/time formatted string and comparing it to the input. For
|
||||
// instance, an input value of '11' using a format of Y (4 digits) gets
|
||||
// created as '0011' instead of '2011'.
|
||||
if ($date instanceOf DateTimePlus) {
|
||||
if ($date instanceof DateTimePlus) {
|
||||
$test_time = $date->format($format, $settings);
|
||||
}
|
||||
elseif ($date instanceOf \DateTime) {
|
||||
elseif ($date instanceof \DateTime) {
|
||||
$test_time = $date->format($format);
|
||||
}
|
||||
$datetimeplus->setTimestamp($date->getTimestamp());
|
||||
|
@ -345,7 +345,7 @@ class DateTimePlus {
|
|||
*/
|
||||
protected function prepareTimezone($timezone) {
|
||||
// If the input timezone is a valid timezone object, use it.
|
||||
if ($timezone instanceOf \DateTimezone) {
|
||||
if ($timezone instanceof \DateTimezone) {
|
||||
$timezone_adjusted = $timezone;
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ class DateTimePlus {
|
|||
|
||||
// Default to the system timezone when not explicitly provided.
|
||||
// If the system timezone is missing, use 'UTC'.
|
||||
if (empty($timezone_adjusted) || !$timezone_adjusted instanceOf \DateTimezone) {
|
||||
if (empty($timezone_adjusted) || !$timezone_adjusted instanceof \DateTimezone) {
|
||||
$system_timezone = date_default_timezone_get();
|
||||
$timezone_name = !empty($system_timezone) ? $system_timezone : 'UTC';
|
||||
$timezone_adjusted = new \DateTimeZone($timezone_name);
|
||||
|
|
|
@ -19,7 +19,7 @@ use Drupal\Component\Utility\Unicode;
|
|||
* More ideas are taken from:
|
||||
* http://www.ics.uci.edu/~eppstein/161/960229.html
|
||||
*
|
||||
* Some ideas are (and a bit of code) are from from analyze.c, from GNU
|
||||
* Some ideas (and a bit of code) are from analyze.c, from GNU
|
||||
* diffutils-2.7, which can be found at:
|
||||
* ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz
|
||||
*
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Gettext\PoWriterInterface;
|
||||
use Drupal\Component\Gettext\PoHeader;
|
||||
use Drupal\Component\Gettext\PoItem;
|
||||
|
||||
/**
|
||||
* Defines a Gettext PO memory writer, to be used by the installer.
|
||||
*/
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Gettext\PoHeader;
|
||||
|
||||
/**
|
||||
* Methods required for both reader and writer implementations.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Gettext\PoMetadataInterface;
|
||||
|
||||
/**
|
||||
* Shared interface definition for all Gettext PO Readers.
|
||||
*/
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Gettext\PoReaderInterface;
|
||||
use Drupal\Component\Gettext\PoStreamInterface;
|
||||
use Drupal\Component\Gettext\PoHeader;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,12 +7,6 @@
|
|||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Gettext\PoHeader;
|
||||
use Drupal\Component\Gettext\PoItem;
|
||||
use Drupal\Component\Gettext\PoReaderInterface;
|
||||
use Drupal\Component\Gettext\PoWriterInterface;
|
||||
use Drupal\Component\Gettext\PoStreamInterface;
|
||||
|
||||
/**
|
||||
* Defines a Gettext PO stream writer.
|
||||
*/
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Gettext\PoMetadataInterface;
|
||||
use Drupal\Component\Gettext\PoItem;
|
||||
|
||||
/**
|
||||
* Shared interface definition for all Gettext PO Writers.
|
||||
*/
|
||||
|
|
|
@ -33,11 +33,21 @@ abstract class SecuredRedirectResponse extends RedirectResponse {
|
|||
*/
|
||||
public static function createFromRedirectResponse(RedirectResponse $response) {
|
||||
$safe_response = new static($response->getTargetUrl(), $response->getStatusCode(), $response->headers->allPreserveCase());
|
||||
$safe_response->setProtocolVersion($response->getProtocolVersion());
|
||||
$safe_response->setCharset($response->getCharset());
|
||||
$safe_response->fromResponse($response);
|
||||
return $safe_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies over the values from the given response.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\RedirectResponse $response
|
||||
* The redirect reponse object.
|
||||
*/
|
||||
protected function fromResponse(RedirectResponse $response) {
|
||||
$this->setProtocolVersion($response->getProtocolVersion());
|
||||
$this->setCharset($response->getCharset());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
namespace Drupal\Component\Plugin\Exception;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\ExceptionInterface;
|
||||
use \BadMethodCallException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,7 @@ class SafeMarkup {
|
|||
* \Drupal\Component\Render\MarkupInterface.
|
||||
*/
|
||||
public static function isSafe($string, $strategy = 'html') {
|
||||
return $string instanceOf MarkupInterface;
|
||||
return $string instanceof MarkupInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Core\Action;
|
||||
|
||||
use Drupal\Component\Plugin\ConfigurablePluginInterface;
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\PluginFormInterface;
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* An AJAX command for adding css to the page via ajax.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
|
||||
/**
|
||||
* An AJAX command for calling the jQuery after() method.
|
||||
*
|
||||
|
|
|
@ -7,15 +7,10 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Asset\AttachedAssets;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\Render\Renderer;
|
||||
use Drupal\Core\Render\AttachmentsInterface;
|
||||
use Drupal\Core\Render\AttachmentsTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* JSON response object for AJAX requests.
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* AJAX command for a javascript alert box.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
|
||||
/**
|
||||
* An AJAX command for calling the jQuery append() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
|
||||
/**
|
||||
* An AJAX command for calling the jQuery before() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* An AJAX command for marking HTML elements as changed.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CloseDialogCommand;
|
||||
|
||||
/**
|
||||
* Defines an AJAX command that closes the currently visible modal dialog.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* An AJAX command for calling the jQuery css() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* An AJAX command for implementing jQuery's data() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
|
||||
/**
|
||||
* AJAX command for calling the jQuery html() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* Generic AJAX command for inserting content.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* AJAX command for invoking an arbitrary jQuery method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* Defines an AJAX command to open certain content in a dialog.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\OpenDialogCommand;
|
||||
|
||||
/**
|
||||
* Defines an AJAX command to open certain content in a dialog in a modal dialog.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
|
||||
/**
|
||||
* AJAX command for calling the jQuery insert() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* Defines an AJAX command to set the window.location, loading that URL.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* AJAX command for calling the jQuery remove() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
|
||||
/**
|
||||
* AJAX command for calling the jQuery replace() method.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* AJAX command for resetting the striping on a table.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\SetDialogOptionCommand;
|
||||
|
||||
/**
|
||||
* Defines an AJAX command that sets jQuery UI dialog properties.
|
||||
*
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* AJAX command for adjusting Drupal's JavaScript settings.
|
||||
*
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
use Drupal\Core\Asset\AssetDumperInterface;
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
use Drupal\Core\Asset\AssetCollectionGrouperInterface;
|
||||
|
||||
/**
|
||||
* Groups CSS assets.
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
use Drupal\Core\Asset\AssetOptimizerInterface;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
use Drupal\Core\Asset\AssetCollectionGrouperInterface;
|
||||
|
||||
/**
|
||||
* Groups JavaScript assets.
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Asset;
|
||||
|
||||
use Drupal\Core\Asset\AssetOptimizerInterface;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,6 @@ use Drupal\Core\Asset\Exception\IncompleteLibraryDefinitionException;
|
|||
use Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException;
|
||||
use Drupal\Core\Asset\Exception\InvalidLibraryFileException;
|
||||
use Drupal\Core\Asset\Exception\LibraryDefinitionMissingLicenseException;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Theme\ThemeManagerInterface;
|
||||
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
|
||||
|
|
|
@ -68,7 +68,7 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
* @return string
|
||||
* The APCu key for the cache item ID.
|
||||
*/
|
||||
protected function getApcuKey($cid) {
|
||||
public function getApcuKey($cid) {
|
||||
return $this->binPrefix . $cid;
|
||||
}
|
||||
|
||||
|
@ -178,14 +178,8 @@ class ApcuBackend implements CacheBackendInterface {
|
|||
$cache->serialized = 0;
|
||||
$cache->data = $data;
|
||||
|
||||
// apc_store()'s $ttl argument can be omitted but also set to 0 (zero),
|
||||
// in which case the value will persist until it's removed from the cache or
|
||||
// until the next cache clear, restart, etc. This is what we want to do
|
||||
// when $expire equals CacheBackendInterface::CACHE_PERMANENT.
|
||||
if ($expire === CacheBackendInterface::CACHE_PERMANENT) {
|
||||
$expire = 0;
|
||||
}
|
||||
apc_store($this->getApcuKey($cid), $cache, $expire);
|
||||
// Expiration is handled by our own prepareItem(), not APCu.
|
||||
apc_store($this->getApcuKey($cid), $cache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace Drupal\Core\Cache;
|
|||
use Drupal\Core\Site\Settings;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
|
||||
|
||||
|
|
26
core/lib/Drupal/Core/Cache/CacheableRedirectResponse.php
Normal file
26
core/lib/Drupal/Core/Cache/CacheableRedirectResponse.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Cache\CacheableRedirectResponse.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Cache;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
* A RedirectResponse that contains and can expose cacheability metadata.
|
||||
*
|
||||
* Supports Drupal's caching concepts: cache tags for invalidation and cache
|
||||
* contexts for variations.
|
||||
*
|
||||
* @see \Drupal\Core\Cache\Cache
|
||||
* @see \Drupal\Core\Cache\CacheableMetadata
|
||||
* @see \Drupal\Core\Cache\CacheableResponseTrait
|
||||
*/
|
||||
class CacheableRedirectResponse extends RedirectResponse implements CacheableResponseInterface {
|
||||
|
||||
use CacheableResponseTrait;
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ namespace Drupal\Core\Composer;
|
|||
|
||||
use Drupal\Component\PhpStorage\FileStorage;
|
||||
use Composer\Script\Event;
|
||||
use Composer\Installer\PackageEvent;
|
||||
|
||||
/**
|
||||
* Provides static functions for composer script events.
|
||||
|
@ -17,6 +18,56 @@ use Composer\Script\Event;
|
|||
*/
|
||||
class Composer {
|
||||
|
||||
protected static $packageToCleanup = [
|
||||
'behat/mink' => ['tests', 'driver-testsuite'],
|
||||
'behat/mink-browserkit-driver' => ['tests'],
|
||||
'behat/mink-goutte-driver' => ['tests'],
|
||||
'doctrine/cache' => ['tests'],
|
||||
'doctrine/collections' => ['tests'],
|
||||
'doctrine/common' => ['tests'],
|
||||
'doctrine/inflector' => ['tests'],
|
||||
'doctrine/instantiator' => ['tests'],
|
||||
'egulias/email-validator' => ['documentation', 'tests'],
|
||||
'fabpot/goutte' => ['Goutte/Tests'],
|
||||
'guzzlehttp/promises' => ['tests'],
|
||||
'guzzlehttp/psr7' => ['tests'],
|
||||
'masterminds/html5' => ['test'],
|
||||
'mikey179/vfsStream' => ['src/test'],
|
||||
'phpdocumentor/reflection-docblock' => ['tests'],
|
||||
'phpunit/php-code-coverage' => ['tests'],
|
||||
'phpunit/php-timer' => ['tests'],
|
||||
'phpunit/php-token-stream' => ['tests'],
|
||||
'phpunit/phpunit' => ['tests'],
|
||||
'phpunit/php-mock-objects' => ['tests'],
|
||||
'sebastian/comparator' => ['tests'],
|
||||
'sebastian/diff' => ['tests'],
|
||||
'sebastian/environment' => ['tests'],
|
||||
'sebastian/exporter' => ['tests'],
|
||||
'sebastian/global-state' => ['tests'],
|
||||
'sebastian/recursion-context' => ['tests'],
|
||||
'stack/builder' => ['tests'],
|
||||
'symfony/browser-kit' => ['Tests'],
|
||||
'symfony/class-loader' => ['Tests'],
|
||||
'symfony/console' => ['Tests'],
|
||||
'symfony/css-selector' => ['Tests'],
|
||||
'symfony/debug' => ['Tests'],
|
||||
'symfony/dependency-injection' => ['Tests'],
|
||||
'symfony/dom-crawler' => ['Tests'],
|
||||
// @see \Drupal\Tests\Component\EventDispatcher\ContainerAwareEventDispatcherTest
|
||||
// 'symfony/event-dispatcher' => ['Tests'],
|
||||
'symfony/http-foundation' => ['Tests'],
|
||||
'symfony/http-kernel' => ['Tests'],
|
||||
'symfony/process' => ['Tests'],
|
||||
'symfony/psr-http-message-bridge' => ['Tests'],
|
||||
'symfony/routing' => ['Tests'],
|
||||
'symfony/serializer' => ['Tests'],
|
||||
'symfony/translation' => ['Tests'],
|
||||
'symfony/validator' => ['Tests'],
|
||||
'symfony/yaml' => ['Tests'],
|
||||
'symfony-cmf/routing' => ['Test', 'Tests'],
|
||||
'twig/twig' => ['doc', 'ext', 'test'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Add vendor classes to composers static classmap.
|
||||
*/
|
||||
|
@ -70,4 +121,90 @@ EOT;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove possibly problematic test files from vendored projects.
|
||||
*
|
||||
* @param \Composer\Script\Event $event
|
||||
*/
|
||||
public static function vendorTestCodeCleanup(PackageEvent $event) {
|
||||
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
|
||||
$op = $event->getOperation();
|
||||
if ($op->getJobType() == 'update') {
|
||||
$package = $op->getTargetPackage();
|
||||
}
|
||||
else {
|
||||
$package = $op->getPackage();
|
||||
}
|
||||
$package_key = static::findPackageKey($package->getName());
|
||||
if ($package_key) {
|
||||
foreach (static::$packageToCleanup[$package_key] as $path) {
|
||||
$dir_to_remove = $vendor_dir . '/' . $package_key . '/' . $path;
|
||||
if (is_dir($dir_to_remove)) {
|
||||
if (!static::deleteRecursive($dir_to_remove)) {
|
||||
throw new \RuntimeException(sprintf("Failure removing directory '%s' in package '%s'.", $path, $package->getPrettyName()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new \RuntimeException(sprintf("The directory '%s' in package '%s' does not exist.", $path, $package->getPrettyName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the array key for a given package name with a case-insensitive search.
|
||||
*
|
||||
* @param string $package_name
|
||||
* The package name from composer. This is always already lower case.
|
||||
*
|
||||
* @return NULL|string
|
||||
* The string key, or NULL if none was found.
|
||||
*/
|
||||
protected static function findPackageKey($package_name) {
|
||||
$package_key = NULL;
|
||||
// In most cases the package name is already used as the array key.
|
||||
if (isset(static::$packageToCleanup[$package_name])) {
|
||||
$package_key = $package_name;
|
||||
}
|
||||
else {
|
||||
// Handle any mismatch in case between the package name and array key.
|
||||
// For example, the array key 'mikey179/vfsStream' needs to be found
|
||||
// when composer returns a package name of 'mikey179/vfsstream'.
|
||||
foreach (static::$packageToCleanup as $key => $dirs) {
|
||||
if (strtolower($key) === $package_name) {
|
||||
$package_key = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $package_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to remove directories and the files they contain.
|
||||
*
|
||||
* @param string $path
|
||||
* The directory or file to remove. It must exist.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE on success or FALSE on failure.
|
||||
*/
|
||||
protected static function deleteRecursive($path) {
|
||||
if (is_file($path) || is_link($path)) {
|
||||
return unlink($path);
|
||||
}
|
||||
$success = TRUE;
|
||||
$dir = dir($path);
|
||||
while (($entry = $dir->read()) !== FALSE) {
|
||||
if ($entry == '.' || $entry == '..') {
|
||||
continue;
|
||||
}
|
||||
$entry_path = $path . '/' . $entry;
|
||||
$success = static::deleteRecursive($entry_path) && $success;
|
||||
}
|
||||
$dir->close();
|
||||
|
||||
return rmdir($path) && $success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Condition;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\Executable\ExecutableManagerInterface;
|
||||
use Drupal\Core\Executable\ExecutablePluginBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Config;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Config;
|
|||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Config\Entity\ConfigDependencyManager;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityDependency;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
|
|
|
@ -9,14 +9,12 @@ namespace Drupal\Core\Config\Entity;
|
|||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Config\ConfigException;
|
||||
use Drupal\Core\Config\Schema\SchemaIncompleteException;
|
||||
use Drupal\Core\Entity\Entity;
|
||||
use Drupal\Core\Config\ConfigDuplicateUUIDException;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Plugin\PluginDependencyTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Config\Entity;
|
||||
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ class Condition extends ConditionBase {
|
|||
$single_conditions = array();
|
||||
$condition_groups = array();
|
||||
foreach ($this->conditions as $condition) {
|
||||
if ($condition['field'] instanceOf ConditionInterface) {
|
||||
if ($condition['field'] instanceof ConditionInterface) {
|
||||
$condition_groups[] = $condition;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -109,7 +109,7 @@ interface StorageComparerInterface {
|
|||
*
|
||||
* @return array
|
||||
* An associative array of configuration names. The array keys are
|
||||
* 'old_name' and and 'new_name' representing the old and name configuration
|
||||
* 'old_name' and 'new_name' representing the old and new configuration
|
||||
* object names during a rename operation.
|
||||
*
|
||||
* @see \Drupal\Core\Config\StorageComparer::createRenameNames()
|
||||
|
|
|
@ -43,14 +43,24 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
|
|||
*/
|
||||
protected $checked = array();
|
||||
|
||||
/**
|
||||
* An array of config object names that are excluded from schema checking.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
/**
|
||||
* Constructs the ConfigSchemaChecker object.
|
||||
*
|
||||
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_manager
|
||||
* The typed config manager.
|
||||
* @param string[] $exclude
|
||||
* An array of config object names that are excluded from schema checking.
|
||||
*/
|
||||
public function __construct(TypedConfigManagerInterface $typed_manager) {
|
||||
public function __construct(TypedConfigManagerInterface $typed_manager, array $exclude = array()) {
|
||||
$this->typedManager = $typed_manager;
|
||||
$this->exclude = $exclude;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,17 +84,7 @@ class ConfigSchemaChecker implements EventSubscriberInterface {
|
|||
$name = $saved_config->getName();
|
||||
$data = $saved_config->get();
|
||||
$checksum = hash('crc32b', serialize($data));
|
||||
$exceptions = array(
|
||||
// Following are used to test lack of or partial schema. Where partial
|
||||
// schema is provided, that is explicitly tested in specific tests.
|
||||
'config_schema_test.noschema',
|
||||
'config_schema_test.someschema',
|
||||
'config_schema_test.schema_data_types',
|
||||
'config_schema_test.no_schema_data_types',
|
||||
// Used to test application of schema to filtering of configuration.
|
||||
'config_test.dynamic.system',
|
||||
);
|
||||
if (!in_array($name, $exceptions) && !isset($this->checked[$name . ':' . $checksum])) {
|
||||
if (!in_array($name, $this->exclude) && !isset($this->checked[$name . ':' . $checksum])) {
|
||||
$this->checked[$name . ':' . $checksum] = TRUE;
|
||||
$errors = $this->checkConfigSchema($this->typedManager, $name, $data);
|
||||
if ($errors === FALSE) {
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\Core\Config;
|
|||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Config\Schema\ArrayElement;
|
||||
use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
|
||||
use Drupal\Core\Config\Schema\ConfigSchemaDiscovery;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Database\Driver\mysql;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
use Drupal\Core\Database\SchemaException;
|
||||
use Drupal\Core\Database\SchemaObjectExistsException;
|
||||
|
|
|
@ -10,9 +10,6 @@ namespace Drupal\Core\Database\Driver\pgsql;
|
|||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\Connection as DatabaseConnection;
|
||||
use Drupal\Core\Database\DatabaseNotFoundException;
|
||||
use Drupal\Core\Database\StatementInterface;
|
||||
use Drupal\Core\Database\IntegrityConstraintViolationException;
|
||||
use Drupal\Core\Database\DatabaseExceptionWrapper;
|
||||
|
||||
/**
|
||||
* @addtogroup database
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
namespace Drupal\Core\Database\Driver\pgsql;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
use Drupal\Core\Database\SchemaObjectExistsException;
|
||||
use Drupal\Core\Database\SchemaObjectDoesNotExistException;
|
||||
use Drupal\Core\Database\Schema as DatabaseSchema;
|
||||
|
|
|
@ -277,10 +277,10 @@ class Condition implements ConditionInterface, \Countable {
|
|||
$this->changed = TRUE;
|
||||
foreach ($this->conditions as $key => $condition) {
|
||||
if ($key !== '#conjunction') {
|
||||
if ($condition['field'] instanceOf ConditionInterface) {
|
||||
if ($condition['field'] instanceof ConditionInterface) {
|
||||
$this->conditions[$key]['field'] = clone($condition['field']);
|
||||
}
|
||||
if ($condition['value'] instanceOf SelectInterface) {
|
||||
if ($condition['value'] instanceof SelectInterface) {
|
||||
$this->conditions[$key]['value'] = clone($condition['value']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
namespace Drupal\Core\Database\Query;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Database\Query\SelectExtender;
|
||||
use Drupal\Core\Database\Query\SelectInterface;
|
||||
|
||||
/**
|
||||
* Query extender for pager queries.
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Database;
|
||||
|
||||
use Drupal\Core\Database\SchemaObjectExistsException;
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
use Drupal\Core\Database\Query\PlaceholderInterface;
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Core\Datetime;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
|
||||
/**
|
||||
* Provides an interface defining a date format.
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Core\Datetime;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
namespace Drupal\Core\Datetime;
|
||||
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
|
||||
/**
|
||||
* Defines Gregorian Calendar date values.
|
||||
*/
|
||||
|
@ -449,7 +447,7 @@ class DateHelper {
|
|||
* The number of days in the month.
|
||||
*/
|
||||
public static function daysInMonth($date = NULL) {
|
||||
if (!$date instanceOf DrupalDateTime) {
|
||||
if (!$date instanceof DrupalDateTime) {
|
||||
$date = new DrupalDateTime($date);
|
||||
}
|
||||
if (!$date->hasErrors()) {
|
||||
|
@ -469,7 +467,7 @@ class DateHelper {
|
|||
* The number of days in the year.
|
||||
*/
|
||||
public static function daysInYear($date = NULL) {
|
||||
if (!$date instanceOf DrupalDateTime) {
|
||||
if (!$date instanceof DrupalDateTime) {
|
||||
$date = new DrupalDateTime($date);
|
||||
}
|
||||
if (!$date->hasErrors()) {
|
||||
|
@ -494,7 +492,7 @@ class DateHelper {
|
|||
* The number of the day in the week.
|
||||
*/
|
||||
public static function dayOfWeek($date = NULL) {
|
||||
if (!$date instanceOf DrupalDateTime) {
|
||||
if (!$date instanceof DrupalDateTime) {
|
||||
$date = new DrupalDateTime($date);
|
||||
}
|
||||
if (!$date->hasErrors()) {
|
||||
|
@ -517,7 +515,7 @@ class DateHelper {
|
|||
* The name of the day in the week for that date.
|
||||
*/
|
||||
public static function dayOfWeekName($date = NULL, $abbr = TRUE) {
|
||||
if (!$date instanceOf DrupalDateTime) {
|
||||
if (!$date instanceof DrupalDateTime) {
|
||||
$date = new DrupalDateTime($date);
|
||||
}
|
||||
$dow = self::dayOfWeek($date);
|
||||
|
|
|
@ -66,7 +66,7 @@ abstract class DateElementBase extends FormElement {
|
|||
$min_year = $temp;
|
||||
}
|
||||
// If there is a current value, stretch the range to include it.
|
||||
$value_year = $date instanceOf DrupalDateTime ? $date->format('Y') : '';
|
||||
$value_year = $date instanceof DrupalDateTime ? $date->format('Y') : '';
|
||||
if (!empty($value_year)) {
|
||||
$min_year = min($value_year, $min_year);
|
||||
$max_year = max($value_year, $max_year);
|
||||
|
|
|
@ -67,7 +67,7 @@ class Datelist extends DateElementBase {
|
|||
}
|
||||
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL;
|
||||
$date = DrupalDateTime::createFromArray($input, $timezone);
|
||||
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
|
||||
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
|
||||
static::incrementRound($date, $increment);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class Datelist extends DateElementBase {
|
|||
$return = array_fill_keys($parts, '');
|
||||
if (!empty($element['#default_value'])) {
|
||||
$date = $element['#default_value'];
|
||||
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
|
||||
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
|
||||
static::incrementRound($date, $increment);
|
||||
foreach ($parts as $part) {
|
||||
switch ($part) {
|
||||
|
@ -184,7 +184,7 @@ class Datelist extends DateElementBase {
|
|||
$date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL;
|
||||
|
||||
// Set a fallback timezone.
|
||||
if ($date instanceOf DrupalDateTime) {
|
||||
if ($date instanceof DrupalDateTime) {
|
||||
$element['#date_timezone'] = $date->getTimezone()->getName();
|
||||
}
|
||||
elseif (!empty($element['#timezone'])) {
|
||||
|
@ -253,7 +253,7 @@ class Datelist extends DateElementBase {
|
|||
}
|
||||
|
||||
$default = isset($element['#value'][$part]) && trim($element['#value'][$part]) != '' ? $element['#value'][$part] : '';
|
||||
$value = $date instanceOf DrupalDateTime && !$date->hasErrors() ? $date->format($format) : $default;
|
||||
$value = $date instanceof DrupalDateTime && !$date->hasErrors() ? $date->format($format) : $default;
|
||||
if (!empty($value) && $part != 'ampm') {
|
||||
$value = intval($value);
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ class Datelist extends DateElementBase {
|
|||
else {
|
||||
// If the input is valid, set it.
|
||||
$date = $input['object'];
|
||||
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
|
||||
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
|
||||
$form_state->setValueForElement($element, $date);
|
||||
}
|
||||
// If the input is invalid, set an error.
|
||||
|
@ -364,7 +364,7 @@ class Datelist extends DateElementBase {
|
|||
*/
|
||||
protected static function incrementRound(&$date, $increment) {
|
||||
// Round minutes and seconds, if necessary.
|
||||
if ($date instanceOf DrupalDateTime && $increment > 1) {
|
||||
if ($date instanceof DrupalDateTime && $increment > 1) {
|
||||
$day = intval($date->format('j'));
|
||||
$hour = intval($date->format('H'));
|
||||
$second = intval(round(intval($date->format('s')) / $increment) * $increment);
|
||||
|
|
|
@ -101,7 +101,7 @@ class Datetime extends DateElementBase {
|
|||
}
|
||||
else {
|
||||
$date = $element['#default_value'];
|
||||
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
|
||||
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
|
||||
$input = array(
|
||||
'date' => $date->format($element['#date_date_format']),
|
||||
'time' => $date->format($element['#date_time_format']),
|
||||
|
@ -223,7 +223,7 @@ class Datetime extends DateElementBase {
|
|||
$date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL;
|
||||
|
||||
// Set a fallback timezone.
|
||||
if ($date instanceOf DrupalDateTime) {
|
||||
if ($date instanceof DrupalDateTime) {
|
||||
$element['#date_timezone'] = $date->getTimezone()->getName();
|
||||
}
|
||||
elseif (empty($element['#timezone'])) {
|
||||
|
@ -246,7 +246,7 @@ class Datetime extends DateElementBase {
|
|||
);
|
||||
|
||||
// Adds the HTML5 date attributes.
|
||||
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) {
|
||||
if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
|
||||
$html5_min = clone($date);
|
||||
$range = static::datetimeRangeYears($element['#date_year_range'], $date);
|
||||
$html5_min->setDate($range[0], 1, 1)->setTime(0, 0, 0);
|
||||
|
|
|
@ -10,8 +10,6 @@ namespace Drupal\Core\DependencyInjection\Compiler;
|
|||
use Drupal\Component\ProxyBuilder\ProxyBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
|
||||
namespace Drupal\Core\DependencyInjection\Compiler;
|
||||
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Adds services tagged 'stream_wrapper' to the stream_wrapper_manager service.
|
||||
|
|
|
@ -22,14 +22,12 @@ use Drupal\Core\Extension\ExtensionDiscovery;
|
|||
use Drupal\Core\File\MimeType\MimeTypeGuesser;
|
||||
use Drupal\Core\Http\TrustedHostsRequestFactory;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\PageCache\RequestPolicyInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
|
143
core/lib/Drupal/Core/Entity/Controller/EntityController.php
Normal file
143
core/lib/Drupal/Core/Entity/Controller/EntityController.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Entity\Controller\EntityController.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Entity\Controller;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides generic entity title callbacks for use in routing.
|
||||
*
|
||||
* It provides:
|
||||
* - A view title callback.
|
||||
* - An edit title callback.
|
||||
* - A delete title callback.
|
||||
*/
|
||||
class EntityController implements ContainerInjectionInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* Constructs a new EntityController.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
|
||||
* The string translation.
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation) {
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->stringTranslation = $string_translation;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager'),
|
||||
$container->get('string_translation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a generic title callback for a single entity.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $_entity
|
||||
* (optional) An entity, passed in directly from the request attributes.
|
||||
*
|
||||
* @return string
|
||||
* The title for the entity view page.
|
||||
*/
|
||||
public function title(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
|
||||
if ($entity = $this->doGetEntity($route_match, $_entity)) {
|
||||
return $entity->label();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a generic edit title callback.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $_entity
|
||||
* (optional) An entity, passed in directly from the request attributes.
|
||||
*
|
||||
* @return string
|
||||
* The title for the entity edit page.
|
||||
*/
|
||||
public function editTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
|
||||
if ($entity = $this->doGetEntity($route_match, $_entity)) {
|
||||
return $this->t('Edit %label', ['%label' => $entity->label()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a generic delete title callback.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $_entity
|
||||
* (optional) An entity, passed in directly from the request attributes, and
|
||||
* set in \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer.
|
||||
*
|
||||
* @return string
|
||||
* The title for the delete entity page.
|
||||
*/
|
||||
public function deleteTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
|
||||
if ($entity = $this->doGetEntity($route_match, $_entity)) {
|
||||
return $this->t('Delete %label', ['%label' => $entity->label()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the entity.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $_entity
|
||||
* (optional) The entity, set in
|
||||
* \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer.
|
||||
*
|
||||
* @return \Drupal\Core\Entity\EntityInterface|NULL
|
||||
* The entity, if it is passed in directly or if the first parameter of the
|
||||
* active route is an entity; otherwise, NULL.
|
||||
*/
|
||||
protected function doGetEntity(RouteMatchInterface $route_match, EntityInterface $_entity = NULL) {
|
||||
if ($_entity) {
|
||||
$entity = $_entity;
|
||||
}
|
||||
else {
|
||||
// Let's look up in the route object for the name of upcasted values.
|
||||
foreach ($route_match->getParameters() as $parameter) {
|
||||
if ($parameter instanceof EntityInterface) {
|
||||
$entity = $parameter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($entity) {
|
||||
return $this->entityManager->getTranslationFromContext($entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Core\Entity\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Defines a generic controller to list entities.
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Entity;
|
|||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
|
||||
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
|
||||
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Entity;
|
|||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Entity;
|
|||
use Drupal\Core\Form\ConfirmFormHelper;
|
||||
use Drupal\Core\Form\ConfirmFormInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Provides a generic base class for an entity-based confirmation form.
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Entity;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,6 @@ use Drupal\Core\Field\FieldStorageDefinitionEvents;
|
|||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionListenerInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
|
||||
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||
|
@ -1133,7 +1132,7 @@ class EntityManager extends DefaultPluginManager implements EntityManagerInterfa
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array of display mode options by bundle.
|
||||
* Returns an array of enabled display mode options by bundle.
|
||||
*
|
||||
* @param $display_type
|
||||
* The display type to be retrieved. It can be "view_mode" or "form_mode".
|
||||
|
|
|
@ -450,7 +450,7 @@ interface EntityManagerInterface extends PluginManagerInterface, EntityTypeListe
|
|||
public function getFormModeOptions($entity_type_id);
|
||||
|
||||
/**
|
||||
* Returns an array of view mode options by bundle.
|
||||
* Returns an array of enabled view mode options by bundle.
|
||||
*
|
||||
* @param string $entity_type_id
|
||||
* The entity type whose view mode options should be returned.
|
||||
|
@ -463,7 +463,7 @@ interface EntityManagerInterface extends PluginManagerInterface, EntityTypeListe
|
|||
public function getViewModeOptionsByBundle($entity_type_id, $bundle);
|
||||
|
||||
/**
|
||||
* Returns an array of form mode options by bundle.
|
||||
* Returns an array of enabled form mode options by bundle.
|
||||
*
|
||||
* @param string $entity_type_id
|
||||
* The entity type whose form mode options should be returned.
|
||||
|
|
|
@ -87,7 +87,7 @@ abstract class ConditionFundamentals {
|
|||
*/
|
||||
public function __clone() {
|
||||
foreach ($this->conditions as $key => $condition) {
|
||||
if ($condition['field'] instanceOf ConditionInterface) {
|
||||
if ($condition['field'] instanceof ConditionInterface) {
|
||||
$this->conditions[$key]['field'] = clone($condition['field']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class Condition extends ConditionBase {
|
|||
$sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery;
|
||||
$tables = $this->query->getTables($sql_query);
|
||||
foreach ($this->conditions as $condition) {
|
||||
if ($condition['field'] instanceOf ConditionInterface) {
|
||||
if ($condition['field'] instanceof ConditionInterface) {
|
||||
$sql_condition = new SqlCondition($condition['field']->getConjunction());
|
||||
// Add the SQL query to the object before calling this method again.
|
||||
$sql_condition->sqlQuery = $sql_query;
|
||||
|
|
|
@ -30,7 +30,7 @@ class ConditionAggregate extends ConditionAggregateBase {
|
|||
$sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $conditionContainer->sqlQuery;
|
||||
$tables = new Tables($sql_query);
|
||||
foreach ($this->conditions as $condition) {
|
||||
if ($condition['field'] instanceOf ConditionAggregateInterface) {
|
||||
if ($condition['field'] instanceof ConditionAggregateInterface) {
|
||||
$sql_condition = new SqlCondition($condition['field']->getConjunction());
|
||||
// Add the SQL query to the object before calling this method again.
|
||||
$sql_condition->sqlQuery = $sql_query;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Core\Entity\Query\Sql;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Entity\Query\QueryBase;
|
||||
use Drupal\Core\Entity\Query\QueryFactoryInterface;
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Entity\Routing;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
|
||||
/**
|
||||
* Provides HTML routes for entities with administrative edit/delete pages.
|
||||
*
|
||||
* Use this class if the edit and delete form routes should use the
|
||||
* administrative theme.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AdminHtmlRouteProvider extends DefaultHtmlRouteProvider {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEditFormRoute(EntityTypeInterface $entity_type) {
|
||||
if ($route = parent::getEditFormRoute($entity_type)) {
|
||||
$route->setOption('_admin_route', TRUE);
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDeleteFormRoute(EntityTypeInterface $entity_type) {
|
||||
if ($route = parent::getDeleteFormRoute($entity_type)) {
|
||||
$route->setOption('_admin_route', TRUE);
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
135
core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Normal file
135
core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Entity\Routing;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* Provides HTML routes for entities.
|
||||
*
|
||||
* This class provides the following routes for entities, with title and access
|
||||
* callbacks:
|
||||
* - canonical
|
||||
* - edit-form
|
||||
* - delete-form
|
||||
*
|
||||
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DefaultHtmlRouteProvider implements EntityRouteProviderInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutes(EntityTypeInterface $entity_type) {
|
||||
$collection = new RouteCollection();
|
||||
|
||||
$entity_type_id = $entity_type->id();
|
||||
|
||||
if ($edit_route = $this->getEditFormRoute($entity_type)) {
|
||||
$collection->add("entity.{$entity_type_id}.edit_form", $edit_route);
|
||||
}
|
||||
|
||||
if ($canonical_route = $this->getCanonicalRoute($entity_type)) {
|
||||
$collection->add("entity.{$entity_type_id}.canonical", $canonical_route);
|
||||
}
|
||||
|
||||
if ($delete_route = $this->getDeleteFormRoute($entity_type)) {
|
||||
$collection->add("entity.{$entity_type_id}.delete_form", $delete_route);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the canonical route.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\Route|null
|
||||
* The generated route, if available.
|
||||
*/
|
||||
protected function getCanonicalRoute(EntityTypeInterface $entity_type) {
|
||||
if ($entity_type->hasLinkTemplate('canonical') && $entity_type->hasViewBuilderClass()) {
|
||||
$entity_type_id = $entity_type->id();
|
||||
$route = new Route($entity_type->getLinkTemplate('canonical'));
|
||||
$route
|
||||
->addDefaults([
|
||||
'_entity_view' => "{$entity_type_id}.full",
|
||||
'_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::title',
|
||||
])
|
||||
->setRequirement('_entity_access', "{$entity_type_id}.view")
|
||||
->setOption('parameters', [
|
||||
$entity_type_id => ['type' => 'entity:' . $entity_type_id],
|
||||
]);
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the edit-form route.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\Route|null
|
||||
* The generated route, if available.
|
||||
*/
|
||||
protected function getEditFormRoute(EntityTypeInterface $entity_type) {
|
||||
if ($entity_type->hasLinkTemplate('edit-form')) {
|
||||
$entity_type_id = $entity_type->id();
|
||||
$route = new Route($entity_type->getLinkTemplate('edit-form'));
|
||||
// Use the edit form handler, if available, otherwise default.
|
||||
$operation = 'default';
|
||||
if ($entity_type->getFormClass('edit')) {
|
||||
$operation = 'edit';
|
||||
}
|
||||
$route
|
||||
->setDefaults([
|
||||
'_entity_form' => "{$entity_type_id}.{$operation}",
|
||||
'_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::editTitle'
|
||||
])
|
||||
->setRequirement('_entity_access', "{$entity_type_id}.update")
|
||||
->setOption('parameters', [
|
||||
$entity_type_id => ['type' => 'entity:' . $entity_type_id],
|
||||
]);
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the delete-form route.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\Route|null
|
||||
* The generated route, if available.
|
||||
*/
|
||||
protected function getDeleteFormRoute(EntityTypeInterface $entity_type) {
|
||||
if ($entity_type->hasLinkTemplate('delete-form')) {
|
||||
$entity_type_id = $entity_type->id();
|
||||
$route = new Route($entity_type->getLinkTemplate('delete-form'));
|
||||
$route
|
||||
->addDefaults([
|
||||
'_entity_form' => "{$entity_type_id}.delete",
|
||||
'_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::deleteTitle',
|
||||
])
|
||||
->setRequirement('_entity_access', "{$entity_type_id}.delete")
|
||||
->setOption('parameters', [
|
||||
$entity_type_id => ['type' => 'entity:' . $entity_type_id],
|
||||
]);
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -324,7 +324,9 @@ use Drupal\node\Entity\NodeType;
|
|||
* also need to add a corresponding route to your module's routing.yml file;
|
||||
* see the entity.node.canonical route in node.routing.yml for an example, and see
|
||||
* @ref sec_routes below for some notes.
|
||||
* - Define routes and links for the various URLs associated with the entity.
|
||||
* - Optionally, instead of defining routes, routes can be auto generated by
|
||||
* providing a route handler. See @ref sec_routes. Otherwise, define routes
|
||||
* and links for the various URLs associated with the entity.
|
||||
* These go into the 'links' annotation, with the link type as the key, and
|
||||
* the path of this link template as the value. The corresponding route
|
||||
* requires the following route name:
|
||||
|
@ -358,8 +360,10 @@ use Drupal\node\Entity\NodeType;
|
|||
*
|
||||
* @section sec_routes Entity routes
|
||||
* Entity routes, like other routes, are defined in *.routing.yml files; see
|
||||
* the @link menu Menu and routing @endlink topic for more information. Here
|
||||
* is a typical entry, for the block configure form:
|
||||
* the @link routing Routing API @endlink topic for more information. Entities
|
||||
* may alternatively use an auto route provider class; there is an example of
|
||||
* this at the end of this section. If providing routes directly, here is a
|
||||
* typical entry, for the block configure form:
|
||||
* @code
|
||||
* entity.block.edit_form:
|
||||
* path: '/admin/structure/block/manage/{block}'
|
||||
|
@ -386,6 +390,19 @@ use Drupal\node\Entity\NodeType;
|
|||
* "form" = {
|
||||
* "default" = "Drupal\block\BlockForm",
|
||||
* @endcode
|
||||
* - Instead of putting the routes for your entity in a *.routing.yml file, you
|
||||
* can instead use a route provider class.
|
||||
* \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider provides canonical,
|
||||
* edit-form, and delete-form routes;
|
||||
* \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider provides the same
|
||||
* routes, set up to use the administrative theme for edit and delete pages.
|
||||
* You can also create your own class. To use a route provider class, add
|
||||
* lines like the following to your entity annotation:
|
||||
* @code
|
||||
* handlers = {
|
||||
* "route_provider" = {
|
||||
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
|
||||
* @endcode
|
||||
*
|
||||
* @section bundle Defining a content entity bundle
|
||||
* For entity types that use bundles, such as Node (bundles are content types)
|
||||
|
|
|
@ -12,9 +12,7 @@ use Drupal\Core\Language\LanguageInterface;
|
|||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Path\CurrentPathStack;
|
||||
use Drupal\Core\Path\PathMatcherInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
|
|
@ -11,7 +11,6 @@ use Drupal\Core\Cache\CacheableMetadata;
|
|||
use Drupal\Core\Cache\CacheableResponseInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ use Drupal\Core\Render\AttachmentsInterface;
|
|||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
|
|
@ -48,12 +48,14 @@ class EntityRouteProviderSubscriber implements EventSubscriberInterface {
|
|||
foreach ($this->entityManager->getRouteProviders($entity_type->id()) as $route_provider) {
|
||||
// Allow to both return an array of routes or a route collection,
|
||||
// like route_callbacks in the routing.yml file.
|
||||
|
||||
$routes = $route_provider->getRoutes($entity_type);
|
||||
if ($routes instanceof RouteCollection) {
|
||||
$route_collection->addCollection($routes);
|
||||
$routes = $routes->all();
|
||||
}
|
||||
elseif (is_array($routes)) {
|
||||
foreach ($routes as $route_name => $route) {
|
||||
foreach ($routes as $route_name => $route) {
|
||||
// Don't override existing routes.
|
||||
if (!$route_collection->get($route_name)) {
|
||||
$route_collection->add($route_name, $route);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,15 @@ namespace Drupal\Core\EventSubscriber;
|
|||
use Drupal\Component\Datetime\DateTimePlus;
|
||||
use Drupal\Core\Cache\CacheableResponseInterface;
|
||||
use Drupal\Core\Cache\Context\CacheContextsManager;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\PageCache\RequestPolicyInterface;
|
||||
use Drupal\Core\PageCache\ResponsePolicyInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
|
@ -65,6 +61,13 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
protected $cacheContexts;
|
||||
|
||||
/**
|
||||
* Whether to send cacheability headers for debugging purposes.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $debugCacheabilityHeaders = FALSE;
|
||||
|
||||
/**
|
||||
* Constructs a FinishResponseSubscriber object.
|
||||
*
|
||||
|
@ -78,13 +81,16 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
|
|||
* A policy rule determining the cacheability of a response.
|
||||
* @param \Drupal\Core\Cache\Context\CacheContextsManager $cache_contexts_manager
|
||||
* The cache contexts manager service.
|
||||
* @param bool $http_response_debug_cacheability_headers
|
||||
* (optional) Whether to send cacheability headers for debugging purposes.
|
||||
*/
|
||||
public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, CacheContextsManager $cache_contexts_manager) {
|
||||
public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, CacheContextsManager $cache_contexts_manager, $http_response_debug_cacheability_headers = FALSE) {
|
||||
$this->languageManager = $language_manager;
|
||||
$this->config = $config_factory->get('system.performance');
|
||||
$this->requestPolicy = $request_policy;
|
||||
$this->responsePolicy = $response_policy;
|
||||
$this->cacheContextsManager = $cache_contexts_manager;
|
||||
$this->debugCacheabilityHeaders = $http_response_debug_cacheability_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,11 +140,13 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
// Expose the cache contexts and cache tags associated with this page in a
|
||||
// X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header respectively.
|
||||
$response_cacheability = $response->getCacheableMetadata();
|
||||
$response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags()));
|
||||
$response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($response_cacheability->getCacheContexts())));
|
||||
if ($this->debugCacheabilityHeaders) {
|
||||
// Expose the cache contexts and cache tags associated with this page in a
|
||||
// X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header respectively.
|
||||
$response_cacheability = $response->getCacheableMetadata();
|
||||
$response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags()));
|
||||
$response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($response_cacheability->getCacheContexts())));
|
||||
}
|
||||
|
||||
$is_cacheable = ($this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) && ($this->responsePolicy->check($response, $request) !== ResponsePolicyInterface::DENY);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ abstract class HttpExceptionSubscriberBase implements EventSubscriberInterface {
|
|||
*
|
||||
* @return array
|
||||
* An indexed array of the format machine names that this subscriber will
|
||||
* attempt ot process,such as "html" or "json". Returning an empty array
|
||||
* attempt to process, such as "html" or "json". Returning an empty array
|
||||
* will apply to all formats.
|
||||
*
|
||||
* @see \Symfony\Component\HttpFoundation\Request
|
||||
|
|
|
@ -11,7 +11,6 @@ use Drupal\Core\State\StateInterface;
|
|||
use Drupal\Core\Routing\RouteBuildEvent;
|
||||
use Drupal\Core\Routing\RoutingEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* Provides all available first bits of all route paths.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Drupal\Core\Cache\CacheableRedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
@ -39,7 +39,7 @@ class RedirectLeadingSlashesSubscriber implements EventSubscriberInterface {
|
|||
if ($qs) {
|
||||
$qs = '?' . $qs;
|
||||
}
|
||||
$event->setResponse(new RedirectResponse($request->getUriForPath($path) . $qs));
|
||||
$event->setResponse(new CacheableRedirectResponse($request->getUriForPath($path) . $qs));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class RedirectResponseSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
public function checkRedirectUrl(FilterResponseEvent $event) {
|
||||
$response = $event->getResponse();
|
||||
if ($response instanceOf RedirectResponse) {
|
||||
if ($response instanceof RedirectResponse) {
|
||||
$request = $event->getRequest();
|
||||
|
||||
// Let the 'destination' query parameter override the redirect target.
|
||||
|
@ -71,7 +71,7 @@ class RedirectResponseSubscriber implements EventSubscriberInterface {
|
|||
|
||||
// Regardless of whether the target is the original one or the overridden
|
||||
// destination, ensure that all redirects are safe.
|
||||
if (!($response instanceOf SecuredRedirectResponse)) {
|
||||
if (!($response instanceof SecuredRedirectResponse)) {
|
||||
try {
|
||||
// SecuredRedirectResponse is an abstract class that requires a
|
||||
// concrete implementation. Default to LocalRedirectResponse, which
|
||||
|
|
|
@ -7,11 +7,7 @@
|
|||
|
||||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Lock\LockBackendInterface;
|
||||
use Drupal\Core\Routing\RouteBuilderInterface;
|
||||
use Drupal\Core\Routing\RoutingEvents;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Core\Executable;
|
||||
|
||||
use Drupal\Core\Plugin\ContextAwarePluginBase;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
use Drupal\Component\Plugin\Exception\PluginException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\Core\Extension;
|
|||
|
||||
use Drupal\Component\Graph\Graph;
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Utility\UpdateException;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Core\Field;
|
||||
|
||||
use Drupal\Component\Plugin\DependentPluginInterface;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
|
@ -252,9 +251,12 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function onDependencyRemoval(array $dependencies) {
|
||||
$changed = parent::onDependencyRemoval($dependencies);
|
||||
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
|
||||
$definition = $field_type_manager->getDefinition($this->getType());
|
||||
$changed = $definition['class']::onDependencyRemoval($this, $dependencies);
|
||||
if ($definition['class']::onDependencyRemoval($this, $dependencies)) {
|
||||
$changed = TRUE;
|
||||
}
|
||||
return $changed;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Field;
|
|||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Component\Render\MarkupTrait;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,7 @@ interface FormatterInterface extends PluginSettingsInterface {
|
|||
* If an empty result is returned, a UI can still be provided to display
|
||||
* a settings form in case the formatter has configurable settings.
|
||||
*
|
||||
* @return array()
|
||||
* @return string[]
|
||||
* A short summary of the formatter settings.
|
||||
*/
|
||||
public function settingsSummary();
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
|
|||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue