Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes

This commit is contained in:
Pantheon Automation 2016-01-06 16:31:26 -08:00 committed by Greg Anderson
parent 1a0e9d9fac
commit a6b049dd05
538 changed files with 5247 additions and 1594 deletions

View file

@ -16,21 +16,21 @@ class ApcuFileCacheBackend implements FileCacheBackendInterface {
* {@inheritdoc}
*/
public function fetch(array $cids) {
return apc_fetch($cids);
return apcu_fetch($cids);
}
/**
* {@inheritdoc}
*/
public function store($cid, $data) {
apc_store($cid, $data);
apcu_store($cid, $data);
}
/**
* {@inheritdoc}
*/
public function delete($cid) {
apc_delete($cid);
apcu_delete($cid);
}
}

View file

@ -471,10 +471,10 @@ class PoHeader {
*
* @param array $element_stack
* Array of plural formula values and operators create by parseArithmetic().
* @param integer $n
* @param int $n
* The @count number for which we are determining the right plural position.
*
* @return integer
* @return int
* Number of the plural string to be used for the given plural value.
*
* @see parseArithmetic()

View file

@ -21,11 +21,11 @@ class Number {
*
* This is based on the number/range verification methods of webkit.
*
* @param numeric $value
* @param float $value
* The value that needs to be checked.
* @param numeric $step
* @param float $step
* The step scale factor. Must be positive.
* @param numeric $offset
* @param float $offset
* (optional) An offset, to which the difference must be a multiple of the
* given step.
*

View file

@ -30,16 +30,6 @@ class OpCodeCache {
if (function_exists('opcache_invalidate')) {
opcache_invalidate($pathname, TRUE);
}
// If apcu extension is enabled in PHP 5.5 or greater it emulates apc.
// This is to provide an easy upgrade path if you are using apc's user
// caching however the emulation does not extend to opcode caching.
// Therefore we need to check if the function exists as well.
if (extension_loaded('apc') && function_exists('apc_delete_file')) {
// apc_delete_file() throws a PHP warning in case the specified file was
// not compiled yet.
// @see http://php.net/manual/en/function.apc-delete-file.php
@apc_delete_file($pathname);
}
}
}

View file

@ -36,10 +36,11 @@ class UrlHelper {
* http_build_query() directly.
*
* @param array $query
* The query parameter array to be processed,
* e.g. \Drupal::request()->query->all().
* The query parameter array to be processed; for instance,
* \Drupal::request()->query->all().
* @param string $parent
* Internal use only. Used to build the $query array key for nested items.
* (optional) Internal use only. Used to build the $query array key for
* nested items. Defaults to an empty string.
*
* @return string
* A rawurlencoded string which can be used as or appended to the URL query
@ -168,8 +169,8 @@ class UrlHelper {
}
// Internal URLs.
else {
// parse_url() does not support relative URLs, so make it absolute. E.g. the
// relative URL "foo/bar:1" isn't properly parsed.
// parse_url() does not support relative URLs, so make it absolute. For
// instance, the relative URL "foo/bar:1" isn't properly parsed.
$parts = parse_url('http://example.com/' . $url);
// Strip the leading slash that was just added.
$options['path'] = substr($parts['path'], 1);
@ -200,10 +201,11 @@ class UrlHelper {
}
/**
* Determines whether a path is external to Drupal (e.g. http://example.com).
* Determines whether a path is external to Drupal.
*
* If a path cannot be assessed by Drupal's menu handler, then we must
* treat it as potentially insecure.
* An example of an external path is http://example.com. If a path cannot be
* assessed by Drupal's menu handler, then we must treat it as potentially
* insecure.
*
* @param string $path
* The internal path or external URL being linked to, such as "node/34" or
@ -296,7 +298,7 @@ class UrlHelper {
}
/**
* Strips dangerous protocols (e.g. 'javascript:') from a URI.
* Strips dangerous protocols (for example, 'javascript:') from a URI.
*
* This function must be called for all URIs within user-entered input prior
* to being output to an HTML attribute value. It is often called as part of
@ -316,8 +318,8 @@ class UrlHelper {
* for well-formed URLs will be invoked, which strips most substrings that
* precede a ":". The result can be used in URL attributes such as "href"
* or "src" (only after calling Html::escape() separately), but this may not
* produce valid HTML (e.g., malformed URLs within "href" attributes fail
* HTML validation). This can be avoided by using
* produce valid HTML (for example, malformed URLs within "href" attributes
* fail HTML validation). This can be avoided by using
* Url::fromUri($possibly_not_a_url)->toString(), which either throws an
* exception or returns a well-formed URL.
*

View file

@ -55,6 +55,8 @@ class CustomAccessCheck implements RoutingAccessInterface {
/**
* Checks access for the account and route using the custom access checker.
*
* @param \Symfony\Component\Routing\Route $route
* The route.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match object to be checked.
* @param \Drupal\Core\Session\AccountInterface $account

View file

@ -10,18 +10,21 @@ namespace Drupal\Core\Annotation;
use Drupal\Component\Annotation\Plugin;
/**
* Declare queue workers that need to be run periodically.
* Declare a worker class for processing a queue item.
*
* While there can be only one hook_cron() process running at the same time,
* there can be any number of processes defined here running. Because of
* this, long running tasks are much better suited for this API. Items queued
* in hook_cron() might be processed in the same cron run if there are not many
* items in the queue, otherwise it might take several requests, which can be
* run in parallel.
* Worker plugins are used by some queues for processing the individual items
* in the queue. In that case, the ID of the worker plugin needs to match the
* machine name of a queue, so that you can retrieve the queue back end by
* calling \Drupal\Core\Queue\QueueFactory::get($plugin_id).
*
* You can create queues, add items to them, claim them, etc. without using a
* QueueWorker plugin if you want, however, you need to take care of processing
* the items in the queue in that case. See \Drupal\Core\Cron for an example.
* \Drupal\Core\Cron::processQueues() processes queues that use workers; they
* can also be processed outside of the cron process.
*
* Some queues do not use worker plugins: you can create queues, add items to
* them, claim them, etc. without using a QueueWorker plugin. However, you will
* need to take care of processing the items in the queue in that case. You can
* look at \Drupal\Core\Cron::processQueues() for an example of how to process
* a queue that uses workers, and adapt it to your queue.
*
* Plugin Namespace: Plugin\QueueWorker
*

View file

@ -51,14 +51,14 @@ class LibraryDiscoveryCollector extends CacheCollector {
/**
* Constructs a CacheCollector object.
*
* @param string $cid
* The cid for the array being cached.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The cache backend.
* @param \Drupal\Core\Lock\LockBackendInterface $lock
* The lock backend.
* @param \Drupal\Core\Asset\LibraryDiscoveryParser $discovery_parser
* The library discovery parser.
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
* The theme manager.
*/
public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, LibraryDiscoveryParser $discovery_parser, ThemeManagerInterface $theme_manager) {
$this->themeManager = $theme_manager;

View file

@ -50,6 +50,8 @@ class LibraryDiscoveryParser {
* The app root.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
* The theme manager.
*/
public function __construct($root, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) {
$this->root = $root;

View file

@ -13,8 +13,9 @@ use Symfony\Component\HttpFoundation\Request;
* Restrict authentication methods to a subset of the site.
*
* Some authentication methods should not be available throughout a whole site.
* E.g., there are good reasons to restrict insecure methods like HTTP basic
* auth or an URL token authentication method to API-only routes.
* For instance, there are good reasons to restrict insecure methods like HTTP
* basic authentication or an URL token authentication method to API-only
* routes.
*/
interface AuthenticationProviderFilterInterface {

View file

@ -0,0 +1,26 @@
<?php
/**
* @file
* Contains \Drupal\Core\Cache\Apcu4Backend.
*/
namespace Drupal\Core\Cache;
/**
* Stores cache items in the Alternative PHP Cache User Cache (APCu).
*
* This class is used with APCu versions >= 4.0.0 and < 5.0.0.
*/
class Apcu4Backend extends ApcuBackend {
/**
* {@inheritdoc}
*
* @return \APCIterator
*/
protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE) {
return new \APCIterator('user', $search, $format, $chunk_size, $list);
}
}

View file

@ -60,7 +60,7 @@ class ApcuBackend implements CacheBackendInterface {
}
/**
* Prepends the APC user variable prefix for this bin to a cache item ID.
* Prepends the APCu user variable prefix for this bin to a cache item ID.
*
* @param string $cid
* The cache item ID to prefix.
@ -76,7 +76,7 @@ class ApcuBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function get($cid, $allow_invalid = FALSE) {
$cache = apc_fetch($this->getApcuKey($cid));
$cache = apcu_fetch($this->getApcuKey($cid));
return $this->prepareItem($cache, $allow_invalid);
}
@ -90,7 +90,7 @@ class ApcuBackend implements CacheBackendInterface {
$map[$this->getApcuKey($cid)] = $cid;
}
$result = apc_fetch(array_keys($map));
$result = apcu_fetch(array_keys($map));
$cache = array();
if ($result) {
foreach ($result as $key => $item) {
@ -112,18 +112,18 @@ class ApcuBackend implements CacheBackendInterface {
* APCu is a memory cache, shared across all server processes. To prevent
* cache item clashes with other applications/installations, every cache item
* is prefixed with a unique string for this site. Therefore, functions like
* apc_clear_cache() cannot be used, and instead, a list of all cache items
* apcu_clear_cache() cannot be used, and instead, a list of all cache items
* belonging to this application need to be retrieved through this method
* instead.
*
* @param string $prefix
* (optional) A cache ID prefix to limit the result to.
*
* @return \APCIterator
* An APCIterator containing matched items.
* @return \APCUIterator
* An APCUIterator containing matched items.
*/
protected function getAll($prefix = '') {
return new \APCIterator('user', '/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
return $this->getIterator('/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
}
/**
@ -174,12 +174,12 @@ class ApcuBackend implements CacheBackendInterface {
$cache->expire = $expire;
$cache->tags = implode(' ', $tags);
$cache->checksum = $this->checksumProvider->getCurrentChecksum($tags);
// APC serializes/unserializes any structure itself.
// APCu serializes/unserializes any structure itself.
$cache->serialized = 0;
$cache->data = $data;
// Expiration is handled by our own prepareItem(), not APCu.
apc_store($this->getApcuKey($cid), $cache);
apcu_store($this->getApcuKey($cid), $cache);
}
/**
@ -195,35 +195,35 @@ class ApcuBackend implements CacheBackendInterface {
* {@inheritdoc}
*/
public function delete($cid) {
apc_delete($this->getApcuKey($cid));
apcu_delete($this->getApcuKey($cid));
}
/**
* {@inheritdoc}
*/
public function deleteMultiple(array $cids) {
apc_delete(array_map(array($this, 'getApcuKey'), $cids));
apcu_delete(array_map(array($this, 'getApcuKey'), $cids));
}
/**
* {@inheritdoc}
*/
public function deleteAll() {
apc_delete(new \APCIterator('user', '/^' . preg_quote($this->binPrefix, '/') . '/'));
apcu_delete($this->getIterator('/^' . preg_quote($this->binPrefix, '/') . '/'));
}
/**
* {@inheritdoc}
*/
public function garbageCollection() {
// APC performs garbage collection automatically.
// APCu performs garbage collection automatically.
}
/**
* {@inheritdoc}
*/
public function removeBin() {
apc_delete(new \APCIterator('user', '/^' . preg_quote($this->binPrefix, '/') . '/'));
apcu_delete($this->getIterator('/^' . preg_quote($this->binPrefix, '/') . '/'));
}
/**
@ -252,4 +252,25 @@ class ApcuBackend implements CacheBackendInterface {
}
}
/**
* Instantiates and returns the APCUIterator class.
*
* @param mixed $search
* A PCRE regular expression that matches against APC key names, either as a
* string for a single regular expression, or as an array of regular
* expressions. Or, optionally pass in NULL to skip the search.
* @param int $format
* The desired format, as configured with one or more of the APC_ITER_*
* constants.
* @param int $chunk_size
* The chunk size. Must be a value greater than 0. The default value is 100.
* @param int $list
* The type to list. Either pass in APC_LIST_ACTIVE or APC_LIST_DELETED.
*
* @return \APCUIterator
*/
protected function getIterator($search = NULL, $format = APC_ITER_ALL, $chunk_size = 100, $list = APC_LIST_ACTIVE) {
return new \APCUIterator($search, $format, $chunk_size, $list);
}
}

View file

@ -25,6 +25,13 @@ class ApcuBackendFactory implements CacheFactoryInterface {
*/
protected $checksumProvider;
/**
* The APCU backend class to use.
*
* @var string
*/
protected $backendClass;
/**
* Constructs an ApcuBackendFactory object.
*
@ -38,6 +45,12 @@ class ApcuBackendFactory implements CacheFactoryInterface {
public function __construct($root, $site_path, CacheTagsChecksumInterface $checksum_provider) {
$this->sitePrefix = Settings::getApcuPrefix('apcu_backend', $root, $site_path);
$this->checksumProvider = $checksum_provider;
if (version_compare(phpversion('apcu'), '5.0.0', '>=')) {
$this->backendClass = 'Drupal\Core\Cache\ApcuBackend';
}
else {
$this->backendClass = 'Drupal\Core\Cache\Apcu4Backend';
}
}
/**
@ -50,7 +63,7 @@ class ApcuBackendFactory implements CacheFactoryInterface {
* The cache backend object for the specified cache bin.
*/
public function get($bin) {
return new ApcuBackend($bin, $this->sitePrefix, $this->checksumProvider);
return new $this->backendClass($bin, $this->sitePrefix, $this->checksumProvider);
}
}

View file

@ -14,7 +14,7 @@ use Drupal\Core\Site\Settings;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface {
use ContainerAwareTrait;

View file

@ -17,9 +17,9 @@ interface CacheableResponseInterface {
/**
* Adds a dependency on an object: merges its cacheability metadata.
*
* E.g. when a response depends on some configuration, an entity, or an access
* result, we must make sure their cacheability metadata is present on the
* response. This method makes doing that simple.
* For instance, when a response depends on some configuration, an entity, or
* an access result, we must make sure their cacheability metadata is present
* on the response. This method makes doing that simple.
*
* @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
* The dependency. If the object implements CacheableDependencyInterface,

View file

@ -53,7 +53,7 @@ class ChainedFastBackendFactory implements CacheFactoryInterface {
}
// Default the fast backend to APCu if it's available.
if (!isset($fast_service_name) && function_exists('apc_fetch')) {
if (!isset($fast_service_name) && function_exists('apcu_fetch')) {
$fast_service_name = 'cache.backend.apcu';
}

View file

@ -92,9 +92,10 @@ class CacheContextsManager {
*
* A cache context token is either:
* - a cache context ID (if the service ID is 'cache_context.foo', then 'foo'
* is a cache context ID), e.g. 'foo'
* - a calculated cache context ID, followed by a double colon, followed by
* the parameter for the calculated cache context, e.g. 'bar:some_parameter'
* is a cache context ID); for example, 'foo'.
* - a calculated cache context ID, followed by a colon, followed by
* the parameter for the calculated cache context; for example,
* 'bar:some_parameter'.
*
* @param string[] $context_tokens
* An array of cache context tokens.
@ -142,11 +143,12 @@ class CacheContextsManager {
* If a cache context is being optimized away, it is able to set cacheable
* metadata for itself which will be bubbled up.
*
* E.g. when caching per user ('user'), also caching per role ('user.roles')
* is meaningless because "per role" is implied by "per user".
* For example, when caching per user ('user'), also caching per role
* ('user.roles') is meaningless because "per role" is implied by "per user".
*
* Examples remember that the period indicates hierarchy and the colon can
* be used to get a specific value of a calculated cache context:
* In the following examples, remember that the period indicates hierarchy and
* the colon can be used to get a specific value of a calculated cache
* context:
* - ['a', 'a.b'] -> ['a']
* - ['a', 'a.b.c'] -> ['a']
* - ['a.b', 'a.b.c'] -> ['a.b']

View file

@ -49,7 +49,7 @@ class ConditionManager extends DefaultPluginManager implements ExecutableManager
}
/**
* Override of Drupal\Component\Plugin\PluginManagerBase::createInstance().
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
$plugin = $this->getFactory()->createInstance($plugin_id, $configuration);

View file

@ -7,6 +7,7 @@
namespace Drupal\Core\Config;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Config\Entity\ConfigEntityDependency;
@ -279,6 +280,12 @@ class ConfigInstaller implements ConfigInstallerInterface {
}
if ($config_to_create[$name] !== FALSE) {
$new_config->setData($config_to_create[$name]);
// Add a hash to configuration created through the installer so it is
// possible to know if the configuration was created by installing an
// extension and to track which version of the default config was used.
if (!$this->isSyncing() && $collection == StorageInterface::DEFAULT_COLLECTION) {
$new_config->set('_core.default_config_hash', Crypt::hashBase64(serialize($config_to_create[$name])));
}
}
if ($collection == StorageInterface::DEFAULT_COLLECTION && $entity_type = $this->configManager->getEntityTypeIdByName($name)) {
// If we are syncing do not create configuration entities. Pluggable

View file

@ -103,6 +103,17 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
*/
protected $third_party_settings = array();
/**
* Information maintained by Drupal core about configuration.
*
* Keys:
* - default_config_hash: A hash calculated by the config.installer service
* and added during installation.
*
* @var array
*/
protected $_core = [];
/**
* Trust supplied data and not use configuration schema on save.
*
@ -296,6 +307,9 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
if (empty($this->third_party_settings)) {
unset($properties['third_party_settings']);
}
if (empty($this->_core)) {
unset($properties['_core']);
}
return $properties;
}

View file

@ -54,6 +54,7 @@ abstract class ConfigEntityBundleBase extends ConfigEntityBase {
}
// Entity bundle field definitions may depend on bundle settings.
$entity_manager->clearCachedFieldDefinitions();
$entity_manager->clearCachedBundles();
}
}

View file

@ -18,10 +18,10 @@ interface ConfigEntityStorageInterface extends EntityStorageInterface {
* Extracts the configuration entity ID from the full configuration name.
*
* @param string $config_name
* The full configuration name to extract the ID from. E.g.
* The full configuration name to extract the ID from; for example,
* 'views.view.archive'.
* @param string $config_prefix
* The config prefix of the configuration entity. E.g. 'views.view'
* The config prefix of the configuration entity; for example, 'views.view'.
*
* @return string
* The ID of the configuration entity.

View file

@ -157,6 +157,7 @@ class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
'status' => 'status',
'dependencies' => 'dependencies',
'third_party_settings' => 'third_party_settings',
'_core' => '_core',
];
foreach ($this->config_export as $property => $name) {
if (is_numeric($property)) {

View file

@ -80,9 +80,9 @@ class InstallStorage extends FileStorage {
* The path to the configuration file.
*
* @todo Improve this when figuring out how we want to handle configuration in
* installation profiles. E.g., a config object actually has to be searched
* in the profile first (whereas the profile is never the owner), only
* afterwards check for a corresponding module or theme.
* installation profiles. For instance, a config object actually has to be
* searched in the profile first (whereas the profile is never the owner);
* only afterwards check for a corresponding module or theme.
*/
public function getFilePath($name) {
$folders = $this->getAllFolders();

View file

@ -105,8 +105,8 @@ class CoreServiceProvider implements ServiceProviderInterface {
/**
* Determines and registers the UUID service.
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* The container.
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
* The container builder.
*
* @return string
* Class name for the UUID service.
@ -131,6 +131,9 @@ class CoreServiceProvider implements ServiceProviderInterface {
/**
* Registers services and event subscribers for a site under test.
*
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
* The container builder.
*/
protected function registerTest(ContainerBuilder $container) {
// Do nothing if we are not in a test environment.

View file

@ -90,7 +90,7 @@ abstract class Connection {
/**
* An index used to generate unique temporary table names.
*
* @var integer
* @var int
*/
protected $temporaryNameIndex = 0;

View file

@ -39,7 +39,7 @@ class Schema extends DatabaseSchema {
* Value will usually be set to a 63 chars limit but PostgreSQL allows
* to higher this value before compiling, so we need to check for that.
*
* @var integer
* @var int
*/
protected $maxIdentifierLength;

View file

@ -428,7 +428,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
];
// @todo Use extension_loaded('apcu') for non-testbot
// https://www.drupal.org/node/2447753.
if (function_exists('apc_fetch')) {
if (function_exists('apcu_fetch')) {
$configuration['default']['cache_backend_class'] = '\Drupal\Component\FileCache\ApcuFileCacheBackend';
}
}
@ -968,11 +968,11 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
}
}
// If the class loader is still the same, possibly upgrade to the APC class
// If the class loader is still the same, possibly upgrade to the APCu class
// loader.
if ($class_loader_class == get_class($this->classLoader)
&& Settings::get('class_loader_auto_detect', TRUE)
&& function_exists('apc_fetch')) {
&& function_exists('apcu_fetch')) {
$prefix = Settings::getApcuPrefix('class_loader', $this->root);
$apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $this->classLoader);
$this->classLoader->unregister();
@ -1307,7 +1307,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
*
* @return array
* Array where each key is a module name, and each value is a path to the
* respective *.module or *.profile file.
* respective *.info.yml file.
*/
protected function getModuleFileNames() {
$filenames = array();
@ -1324,7 +1324,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
*
* @param string[] $module_file_names
* Array where each key is a module name, and each value is a path to the
* respective *.module or *.profile file.
* respective *.info.yml file.
*
* @return string[]
* Array where each key is a module namespace like 'Drupal\system', and each

View file

@ -6,15 +6,14 @@
*/
namespace Drupal\Core\Entity\Annotation;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Defines a config entity type annotation object.
*
* Config Entity type plugins use an object-based annotation method, rather than an
* array-type annotation method (as commonly used on other annotation types).
* The annotation properties of entity types are found on
* \Drupal\Core\Entity\ConfigEntityType and are accessed using
* \Drupal\Core\Config\Entity\ConfigEntityType and are accessed using
* get/set methods defined in \Drupal\Core\Entity\EntityTypeInterface.
*
* @ingroup entity_api

View file

@ -10,6 +10,7 @@ namespace Drupal\Core\Entity\Element;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Tags;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\Textfield;
@ -146,6 +147,7 @@ class EntityAutocomplete extends Textfield {
'handler' => $element['#selection_handler'],
'handler_settings' => $element['#selection_settings'],
);
/** @var /Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */
$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options);
$autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface;
@ -164,6 +166,7 @@ class EntityAutocomplete extends Textfield {
);
}
elseif ($autocreate) {
/** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */
// Auto-create item. See an example of how this is handled in
// \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave().
$value[] = array(
@ -211,6 +214,7 @@ class EntityAutocomplete extends Textfield {
}
foreach ($invalid_new_entities as $entity) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', array('%type' => $element['#target_type'], '%label' => $entity->label())));
}
}
@ -233,6 +237,8 @@ class EntityAutocomplete extends Textfield {
* The method will return an entity ID if one single entity unambuguously
* matches the incoming input, and sill assign form errors otherwise.
*
* @param \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler
* Entity reference selection plugin.
* @param string $input
* Single string from autocomplete element.
* @param array $element
@ -243,10 +249,10 @@ class EntityAutocomplete extends Textfield {
* Whether to trigger a form error if an element from $input (eg. an entity)
* is not found.
*
* @return integer|null
* @return int|null
* Value of a matching entity ID, or NULL if none.
*/
protected static function matchEntityByTitle($handler, $input, &$element, FormStateInterface $form_state, $strict) {
protected static function matchEntityByTitle(SelectionInterface $handler, $input, array &$element, FormStateInterface $form_state, $strict) {
$entities_by_bundle = $handler->getReferenceableEntities($input, '=', 6);
$entities = array_reduce($entities_by_bundle, function ($flattened, $bundle_entities) {
return $flattened + $bundle_entities;

View file

@ -320,11 +320,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* Returns a list of URI relationships supported by this entity.
*
* @return array
* An array of link relationships supported by this entity.
*/
public function uriRelationships() {
return array_keys($this->linkTemplates());
@ -497,9 +492,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* @return static|null
* The entity object or NULL if there is no entity with the given ID.
*/
public static function load($id) {
$entity_manager = \Drupal::entityManager();
@ -508,10 +500,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* @return static[]
* An array of entity objects indexed by their IDs. Returns an empty array
* if no matching entities are found.
*/
public static function loadMultiple(array $ids = NULL) {
$entity_manager = \Drupal::entityManager();
@ -520,9 +508,6 @@ abstract class Entity implements EntityInterface {
/**
* {@inheritdoc}
*
* @return static
* The entity object.
*/
public static function create(array $values = array()) {
$entity_manager = \Drupal::entityManager();

View file

@ -206,6 +206,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce
public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE) {
$account = $this->prepareUser($account);
$context += array(
'entity_type_id' => $this->entityTypeId,
'langcode' => LanguageInterface::LANGCODE_DEFAULT,
);

View file

@ -113,7 +113,7 @@ interface EntityInterface extends AccessibleInterface, CacheableDependencyInterf
* The URL object.
*
* @deprecated in Drupal 8.0.0, intended to be removed in Drupal 9.0.0
* Use toUrl() instead.
* Use \Drupal\Core\Entity\EntityInterface::toUrl() instead.
*
* @see \Drupal\Core\Entity\EntityInterface::toUrl
*/

View file

@ -41,7 +41,7 @@ class EntityReference extends DataReferenceBase {
/**
* The entity ID.
*
* @var integer|string
* @var int|string
*/
protected $id;

View file

@ -257,7 +257,7 @@ class DefaultSelection extends PluginBase implements SelectionInterface, Selecti
$entities = $this->entityManager->getStorage($target_type)->loadMultiple($result);
foreach ($entities as $entity_id => $entity) {
$bundle = $entity->bundle();
$options[$bundle][$entity_id] = Html::escape($entity->label());
$options[$bundle][$entity_id] = Html::escape($this->entityManager->getTranslationFromContext($entity)->label());
}
return $options;

View file

@ -592,7 +592,8 @@ function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $o
* The account trying to access the entity.
* @param array $context
* An associative array of additional context values. By default it contains
* language:
* language and the entity type ID:
* - entity_type_id - the entity type ID.
* - langcode - the current language code.
* @param string $entity_bundle
* The entity bundle name.
@ -1964,7 +1965,7 @@ function hook_ENTITY_TYPE_field_values_init(\Drupal\Core\Entity\FieldableEntityI
*
* @return array
* The array structure is identical to that of the return value of
* \Drupal\Core\Entity\EntityManagerInterface::getExtraFields().
* \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields().
*/
function hook_entity_extra_field_info() {
$extra = array();

View file

@ -70,7 +70,7 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getHandledFormats() {
return ['html'];

View file

@ -160,8 +160,8 @@ class EarlyRenderingControllerWrapperSubscriber implements EventSubscriberInterf
}
else {
// A Response or domain object is returned that does not care about
// attachments nor cacheability. E.g. a RedirectResponse. It is safe to
// discard any early rendering metadata.
// attachments nor cacheability; for instance, a RedirectResponse. It is
// safe to discard any early rendering metadata.
}
}

View file

@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
class ExceptionJsonSubscriber extends HttpExceptionSubscriberBase {
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getHandledFormats() {
return ['json'];

View file

@ -23,7 +23,7 @@ class ExceptionTestSiteSubscriber extends HttpExceptionSubscriberBase {
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getHandledFormats() {
return ['html'];

View file

@ -59,7 +59,7 @@ class Fast404ExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getHandledFormats() {
return ['html'];

View file

@ -15,6 +15,13 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Discovers available extensions in the filesystem.
*
* To also discover test modules, add
* @code
* $settings['extension_discovery_scan_tests'] = TRUE;
* @encode
* to your settings.php.
*
*/
class ExtensionDiscovery {
@ -134,6 +141,12 @@ class ExtensionDiscovery {
* - the site-wide directory; i.e., /
* - the site-specific directory; e.g., /sites/example.com
*
* To also find test modules, add
* @code
* $settings['extension_discovery_scan_tests'] = TRUE;
* @encode
* to your settings.php.
*
* The information is returned in an associative array, keyed by the extension
* name (without .info.yml extension). Extensions found later in the search
* will take precedence over extensions found earlier - unless they are not

View file

@ -23,6 +23,12 @@ interface ModuleInstallerInterface {
* - Invoke hook_install() and add it to the list of installed modules.
* - Invoke hook_modules_installed().
*
* To install test modules add
* @code
* $settings['extension_discovery_scan_tests'] = TRUE;
* @encode
* to your settings.php.
*
* @param string[] $module_list
* An array of module names.
* @param bool $enable_dependencies

View file

@ -19,9 +19,12 @@ class ThemeHandler implements ThemeHandlerInterface {
* Contains the features enabled for themes by default.
*
* @var array
*
* @see _system_default_theme_features()
*/
protected $defaultFeatures = array(
'favicon',
'logo',
'node_user_picture',
'comment_user_picture',
'comment_user_verification',

View file

@ -61,7 +61,7 @@ final class FieldFilteredMarkup implements MarkupInterface, \Countable {
* A list of allowed tags.
*/
public static function allowedTags() {
return ['a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img'];
return ['a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img'];
}
/**

View file

@ -115,7 +115,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE) {
// Support passing in only the value of the first item, either as a litteral
// Support passing in only the value of the first item, either as a literal
// (value of the first property) or as an array of properties.
if (isset($values) && (!is_array($values) || (!empty($values) && !is_numeric(current(array_keys($values)))))) {
$values = array(0 => $values);

View file

@ -156,7 +156,7 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl
}
/**
* @inheritdoc
* {@inheritdoc}
*/
public function getPluginClass($type) {
$plugin_definition = $this->getDefinition($type, FALSE);

View file

@ -136,7 +136,7 @@ class FormatterPluginManager extends DefaultPluginManager {
*
* @param string $field_type
* The field type.
* @param array $properties
* @param array $configuration
* An array of formatter configuration.
*
* @return array

View file

@ -42,7 +42,7 @@ class FieldItemDeriver implements ContainerDeriverInterface {
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager
* The field type plugin manager.
*/
public function __construct($base_plugin_id, FieldTypePluginManagerInterface $field_type_plugin_manager) {

View file

@ -52,8 +52,6 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem
* The view mode.
* @param array $third_party_settings
* Any third party settings settings.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param LoggerChannelFactoryInterface $logger_factory
* The logger factory.
*/

View file

@ -30,7 +30,7 @@ class FTPExtension extends FTP implements ChmodInterface {
* {@inheritdoc}
*/
protected function copyFileJailed($source, $destination) {
if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) {
if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) {
throw new FileTransferException("Cannot move @source to @destination", NULL, array("@source" => $source, "@destination" => $destination));
}
}

View file

@ -212,9 +212,8 @@ class FormState implements FormStateInterface {
*
* The validation functions and submit functions use this array for nearly all
* their decision making. (Note that #tree determines whether the values are a
* flat array or an array whose structure parallels the $form array. See the
* @link forms_api_reference.html Form API reference @endlink for more
* information.)
* flat array or an array whose structure parallels the $form array. See
* \Drupal\Core\Render\Element\FormElement for more information.)
*
* This property is uncacheable.
*

View file

@ -346,7 +346,7 @@ class FormValidator implements FormValidatorInterface {
foreach ($value as $v) {
if (!isset($options[$v])) {
$form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.'));
$this->logger->error('Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
$this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $v, '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
}
}
}

View file

@ -53,7 +53,7 @@
* such as how many total items were processed.
*/
function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
@ -194,7 +194,8 @@ function hook_ajax_render_alter(array &$data) {
*
* @see hook_form_BASE_FORM_ID_alter()
* @see hook_form_FORM_ID_alter()
* @see forms_api_reference.html
*
* @ingroup form_api
*/
function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
@ -237,7 +238,8 @@ function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_stat
* @see hook_form_alter()
* @see hook_form_BASE_FORM_ID_alter()
* @see \Drupal\Core\Form\FormBuilderInterface::prepareForm()
* @see forms_api_reference.html
*
* @ingroup form_api
*/
function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// Modification for the form with the given form ID goes here. For example, if
@ -286,6 +288,8 @@ function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $f
* @see hook_form_alter()
* @see hook_form_FORM_ID_alter()
* @see \Drupal\Core\Form\FormBuilderInterface::prepareForm()
*
* @ingroup form_api
*/
function hook_form_BASE_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// Modification for the form with the given BASE_FORM_ID goes here. For

View file

@ -86,9 +86,12 @@ interface ImageInterface {
* @param string $operation
* The operation to be performed against the image.
* @param array $arguments
* An associative array of arguments to be passed to the toolkit
* operation, e.g. array('width' => 50, 'height' => 100,
* 'upscale' => TRUE).
* (optional) An associative array of arguments to be passed to the toolkit
* operation; for instance,
* @code
* ['width' => 50, 'height' => 100, 'upscale' => TRUE]
* @endcode
* Defaults to an empty array.
*
* @return bool
* TRUE on success, FALSE on failure.
@ -120,11 +123,11 @@ interface ImageInterface {
* @param int $height
* The height of the new image, in pixels.
* @param string $extension
* (Optional) The extension of the image file (e.g. 'png', 'gif', etc.).
* Allowed values depend on the implementation of the image toolkit.
* (optional) The extension of the image file (for instance, 'png', 'gif',
* etc.). Allowed values depend on the implementation of the image toolkit.
* Defaults to 'png'.
* @param string $transparent_color
* (Optional) The hexadecimal string representing the color to be used
* (optional) The hexadecimal string representing the color to be used
* for transparency, needed for GIF images. Defaults to '#ffffff' (white).
*
* @return bool
@ -176,8 +179,8 @@ interface ImageInterface {
* extension.
*
* @param string $extension
* The extension to convert to (e.g. 'jpeg' or 'png'). Allowed values depend
* on the current image toolkit.
* The extension to convert to (for instance, 'jpeg' or 'png'). Allowed
* values depend on the current image toolkit.
*
* @return bool
* TRUE on success, FALSE on failure.
@ -231,10 +234,10 @@ interface ImageInterface {
* The number of (clockwise) degrees to rotate the image.
* @param string|null $background
* (optional) An hexadecimal integer specifying the background color to use
* for the uncovered area of the image after the rotation. E.g. 0x000000 for
* black, 0xff00ff for magenta, and 0xffffff for white. For images that
* support transparency, this will default to transparent. Otherwise it will
* be white.
* for the uncovered area of the image after the rotation; for example,
* 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. When
* NULL (the default) is specified, for images that support transparency,
* this will default to transparent; otherwise, it will default to white.
*
* @return bool
* TRUE on success, FALSE on failure.

View file

@ -7,6 +7,8 @@
namespace Drupal\Core\Language;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* An object containing the information for an interface language.
*
@ -151,7 +153,17 @@ class Language implements LanguageInterface {
$a_weight = $a->getWeight();
$b_weight = $b->getWeight();
if ($a_weight == $b_weight) {
return strnatcasecmp($a->getName(), $b->getName());
$a_name = $a->getName();
$b_name = $b->getName();
// If either name is a TranslatableMarkup object it can not be converted
// to a string. This is because translation requires a sorted list of
// languages thereby causing an infinite loop. Determine the order based
// on ID if this is the case.
if ($a_name instanceof TranslatableMarkup || $b_name instanceof TranslatableMarkup) {
$a_name = $a->getId();
$b_name = $b->getId();
}
return strnatcasecmp($a_name, $b_name);
}
return ($a_weight < $b_weight) ? -1 : 1;
});

View file

@ -224,7 +224,7 @@ class LanguageManager implements LanguageManagerInterface {
}
/**
* @inheritdoc
* {@inheritdoc}
*/
public static function getStandardLanguageList() {
// This list is based on languages available from localize.drupal.org. See

View file

@ -140,11 +140,15 @@ class Link implements RenderableInterface {
/**
* Generates the HTML for this Link object.
*
* Do not use this method to render a link in an HTML context. In an HTML
* context, self::toRenderable() should be used so that render cache
* information is maintained. However, there might be use cases such as tests
* and non-HTML contexts where calling this method directly makes sense.
*
* @return \Drupal\Core\GeneratedLink
* The link HTML markup.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. Use
* self::toRenderable() instead.
* @see \Drupal\Core\Link::toRenderable()
*/
public function toString() {
return $this->getLinkGenerator()->generateFromLink($this);

View file

@ -297,8 +297,8 @@ class MailFormatHelper {
* Note that we are skipping MIME content header lines, because attached
* files, especially applications, could have long MIME types or long
* filenames which result in line length longer than the 77 characters limit
* and wrapping that line will break the email format. E.g., the attached file
* hello_drupal.docx will produce the following Content-Type:
* and wrapping that line will break the email format. For instance, the
* attached file hello_drupal.docx will produce the following Content-Type:
* @code
* Content-Type:
* application/vnd.openxmlformats-officedocument.wordprocessingml.document;

View file

@ -32,9 +32,9 @@ interface ContextInterface extends ComponentContextInterface, CacheableDependenc
/**
* Adds a dependency on an object: merges its cacheability metadata.
*
* E.g. when a context depends on some configuration, an entity, or an access
* result, we must make sure their cacheability metadata is present on the
* response. This method makes doing that simple.
* For example, when a context depends on some configuration, an entity, or an
* access result, we must make sure their cacheability metadata is present on
* the response. This method makes doing that simple.
*
* @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
* The dependency. If the object implements CacheableDependencyInterface,

View file

@ -289,7 +289,7 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
* Invokes the hook to alter the definitions if the alter hook is set.
*
* @param $definitions
* The discovered plugin defintions.
* The discovered plugin definitions.
*/
protected function alterDefinitions(&$definitions) {
if ($this->alterHook) {

View file

@ -120,13 +120,13 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery {
if ($this->namespaceSuffix) {
foreach ($this->rootNamespacesIterator as $namespace => $dirs) {
// Append the namespace suffix to the base namespace, to obtain the
// plugin namespace. E.g. 'Drupal\Views' may become
// plugin namespace; for example, 'Drupal\Views' may become
// 'Drupal\Views\Plugin\Block'.
$namespace .= $this->namespaceSuffix;
foreach ((array) $dirs as $dir) {
// Append the directory suffix to the PSR-4 base directory, to obtain
// the directory where plugins are found.
// E.g. DRUPAL_ROOT . '/core/modules/views/src' may become
// the directory where plugins are found. For example,
// DRUPAL_ROOT . '/core/modules/views/src' may become
// DRUPAL_ROOT . '/core/modules/views/src/Plugin/Block'.
$plugin_namespaces[$namespace][] = $dir . $this->directorySuffix;
}

View file

@ -47,8 +47,8 @@ class YamlDiscovery implements DiscoveryInterface {
* Construct a YamlDiscovery object.
*
* @param string $name
* The file name suffix to use for discovery. E.g. 'test' will become
* 'MODULE.test.yml'.
* The file name suffix to use for discovery; for example, 'test' will
* become 'MODULE.test.yml'.
* @param array $directories
* An array of directories to scan.
*/

View file

@ -30,8 +30,8 @@ class YamlDiscoveryDecorator extends YamlDiscovery {
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
* The discovery object that is being decorated.
* @param string $name
* The file name suffix to use for discovery. E.g. 'test' will become
* 'MODULE.test.yml'.
* The file name suffix to use for discovery; for instance, 'test' will
* become 'MODULE.test.yml'.
* @param array $directories
* An array of directories to scan.
*/

View file

@ -27,8 +27,7 @@ interface PluginFormInterface {
* callback and build the rest of the form in the callback. By the time the
* callback is executed, the element's #parents and #array_parents properties
* will have been set by the form API. For more documentation on #parents and
* #array_parents, see
* https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/8.
* #array_parents, see \Drupal\Core\Render\Element\FormElement.
*
* @param array $form
* An associative array containing the initial structure of the plugin form.

View file

@ -16,6 +16,24 @@ use Drupal\Core\Template\Attribute;
/**
* Provides a render element for any HTML tag, with properties and value.
*
* Properties:
* - #tag: The tag name to output.
* - #attributes: (array, optional) HTML attributes to apply to the tag. The
* attributes are escaped, see \Drupal\Core\Template\Attribute.
* - #value: (string, optional) A string containing the textual contents of
* the tag.
* - #noscript: (bool, optional) When set to TRUE, the markup
* (including any prefix or suffix) will be wrapped in a <noscript> element.
*
* Usage example:
* @code
* $build['hello'] = [
* '#type' => 'html_tag'
* '#tag' => 'p',
* '#value' => $this->t('Hello World'),
* ];
* @endcode
*
* @RenderElement("html_tag")
*/
class HtmlTag extends RenderElement {

View file

@ -10,6 +10,22 @@ namespace Drupal\Core\Render\Element;
/**
* Provides a render element where the user supplies an in-line Twig template.
*
* Properties:
* - #template: The inline Twig template used to render the element.
* - #context: (array) The variables to substitute into the Twig template.
* Each variable may be a string or a render array.
*
* Usage example:
* @code
* $build['hello'] = [
* '#type' => 'inline_template',
* '#template' => "{% trans %} Hello {% endtrans %} <strong>{{name}}</strong>",
* '#context' => [
* 'name' => $name,
* ]
* ];
* @endcode
*
* @RenderElement("inline_template")
*/
class InlineTemplate extends RenderElement {

View file

@ -11,7 +11,8 @@ namespace Drupal\Core\Render\Element;
* Provides a render element for displaying the label for a form element.
*
* Labels are generated automatically from element properties during processing
* of most form elements.
* of most form elements. This element is used internally by the form system
* to render labels for form elements.
*
* @RenderElement("label")
*/

View file

@ -15,6 +15,20 @@ use Drupal\Core\Url as CoreUrl;
/**
* Provides a link render element.
*
* Properties:
* - #title: The link text.
* - #url: \Drupal\Url object containing URL information pointing to a internal
* or external link . See \Drupal\Core\Utility\LinkGeneratorInterface.
*
* Usage example:
* @code
* $build['examples_link'] = [
* '#title' => $this->t('Examples'),
* '#type' => 'link',
* '#url' => Url::fromRoute('examples.description')
* ];
* @endcode
*
* @RenderElement("link")
*/
class Link extends RenderElement {

View file

@ -10,6 +10,19 @@ namespace Drupal\Core\Render\Element;
/**
* Provides a link render element for a "more" link, like those used in blocks.
*
* Properties:
* - #title: The text of the link to generate (defaults to 'More').
*
* See \Drupal\Core\Render\Element\Link for additional properties.
*
* Usage Example:
* @code
* $build['more'] = [
* '#type' => 'more_link',
* '#url' => Url::fromRoute('examples.more_examples')
* ]
* @endcode
*
* @RenderElement("more_link")
*/
class MoreLink extends Link {

View file

@ -12,6 +12,29 @@ use Drupal\Core\Render\Element;
/**
* Provides a render element for a pager.
*
* The pager must be initialized with a call to pager_default_initialize() in
* order to render properly. When used with database queries, this is performed
* for you when you extend a select query with
* \Drupal\Core\Database\Query\PagerSelectExtender.
*
* Properties:
* - #element: (optional, int) The pager ID, to distinguish between multiple
* pagers on the same page (defaults to 0).
* - #parameters: (optional) An associative array of query string parameters to
* append to the pager.
* - #quantity: The maximum number of numbered page links to create (defaults
* to 9).
* - #tags: (optional) An array of labels for the controls in the pages.
* - #route_name: (optional) The name of the route to be used to build pager
* links. Defaults to '<none>', which will make links relative to the current
* URL. This makes the page more effectively cacheable.
*
* @code
* $build['pager'] = [
* '#type' => 'pager',
* ];
* @endcode
*
* @RenderElement("pager")
*/
class Pager extends RenderElement{

View file

@ -14,12 +14,30 @@ use Drupal\Core\Render\Element;
* Provides a form element for a drop-down menu or scrolling selection box.
*
* Properties:
* - #options: An associative array, where the keys are the retured values for
* each option, and the values are the options to be shown in the drop-down
* list.
* - #options: An associative array, where the keys are the values for each
* option, and the values are the option labels to be shown in the drop-down
* list. If a value is an array, it will be rendered similarly, but as an
* optgroup. The key of the sub-array will be used as the label for the
* optgroup. Nesting optgroups is not allowed.
* - #empty_option: The label that will be displayed to denote no selection.
* - #empty_value: The value of the option that is used to denote no selection.
*
* Usage example:
* @code
* $form['example_select'] = [
* '#type' => 'select',
* '#title' => t('Select element'),
* '#options' => [
* '1' => t('One'),
* '2' => [
* '2.1' => t('Two point one'),
* '2.2' => t('Two point two'),
* ],
* '3' => t('Three'),
* ],
* ];
* @endcode
*
* @FormElement("select")
*/
class Select extends FormElement {

View file

@ -10,6 +10,15 @@ namespace Drupal\Core\Render\Element;
/**
* Provides a messages element.
*
* Used to display results of drupal_set_message() calls.
*
* Usage example:
* @code
* $build['status_messages'] = [
* '#type' => 'status_messages',
* ];
* @end
*
* @RenderElement("status_messages")
*/
class StatusMessages extends RenderElement {

View file

@ -11,7 +11,14 @@ use Drupal\Core\Url as BaseUrl;
use Drupal\Component\Utility\NestedArray;
/**
* Provides a link render element to show or hide inline help descriptions.
* Provides a link to show or hide help text on administration pages.
*
* Usage example:
* @code
* $form['system_compact_link'] = [
* '#type' => 'system_compact_link',
* ];
* @endcode
*
* @RenderElement("system_compact_link")
*/

View file

@ -49,19 +49,19 @@ class PlaceholderGenerator implements PlaceholderGeneratorInterface {
* {@inheritdoc}
*/
public function shouldAutomaticallyPlaceholder(array $element) {
// Auto-placeholder if the max-age, cache context or cache tag is specified
// in the auto-placeholder conditions in the 'renderer.config' container
// parameter.
$conditions = $this->rendererConfig['auto_placeholder_conditions'];
// Auto-placeholder if max-age is at or below the configured threshold.
if (isset($element['#cache']['max-age']) && $element['#cache']['max-age'] !== Cache::PERMANENT && $element['#cache']['max-age'] <= $conditions['max-age']) {
return TRUE;
}
// Auto-placeholder if a high-cardinality cache context is set.
if (isset($element['#cache']['contexts']) && array_intersect($element['#cache']['contexts'], $conditions['contexts'])) {
return TRUE;
}
// Auto-placeholder if a high-invalidation frequency cache tag is set.
if (isset($element['#cache']['tags']) && array_intersect($element['#cache']['tags'], $conditions['tags'])) {
return TRUE;
}

View file

@ -35,6 +35,11 @@ interface PlaceholderGeneratorInterface {
/**
* Whether the given render array should be automatically placeholdered.
*
* The render array should be placeholdered if its cacheability either has a
* cache context with too high cardinality, a cache tag with a too high
* invalidation rate, or a max-age that is too low. Either of these would make
* caching ineffective, and thus we choose to placeholder instead.
*
* @param array $element
* The render array whose cacheability to analyze.
*

View file

@ -42,9 +42,9 @@ interface RendererInterface {
*
* Calls ::render() in such a way that placeholders are replaced.
*
* Useful for e.g. rendering the values of tokens or emails, which need a
* render array being turned into a string, but don't need any of the
* bubbleable metadata (the attached assets the cache tags).
* Useful for instance when rendering the values of tokens or emails, which
* need a render array being turned into a string, but do not need any of the
* bubbleable metadata (the attached assets and cache tags).
*
* Some of these are a relatively common use case and happen *within* a
* ::renderRoot() call, but that is generally highly problematic (and hence an
@ -138,8 +138,8 @@ interface RendererInterface {
* - 'keys': An array of one or more keys that identify the element. If
* 'keys' is set, the cache ID is created automatically from these keys.
* - 'contexts': An array of one or more cache context IDs. These are
* converted to a final value depending on the request. (e.g. 'user' is
* mapped to the current user's ID.)
* converted to a final value depending on the request. (For instance,
* 'user' is mapped to the current user's ID.)
* - 'max-age': A time in seconds. Zero seconds means it is not cacheable.
* \Drupal\Core\Cache\Cache::PERMANENT means it is cacheable forever.
* - 'bin': Specify a cache bin to cache the element in. Default is
@ -298,14 +298,14 @@ interface RendererInterface {
* placeholder element containing a #lazy_builder function is rendered in
* isolation. The resulting markup is used to replace the placeholder, and
* any bubbleable metadata is merged.
* Placeholders must be unique, to guarantee that e.g. samples of
* Placeholders must be unique, to guarantee that for instance, samples of
* placeholders are not replaced as well.
* - Just before finishing the rendering of this element, this element's
* stack frame (the topmost one) is bubbled: the two topmost frames are
* popped from the stack, they are merged and the result is pushed back
* onto the stack.
* So if this element e.g. was a child element, then a new frame was
* pushed onto the stack element at the beginning of rendering this
* So if for instance this element was a child element, then a new frame
* was pushed onto the stack element at the beginning of rendering this
* element, it was updated when the rendering was completed, and now we
* merge it with the frame for the parent, so that the parent now has the
* bubbleable rendering metadata for its child.
@ -401,9 +401,9 @@ interface RendererInterface {
/**
* Adds a dependency on an object: merges its cacheability metadata.
*
* E.g. when a render array depends on some configuration, an entity, or an
* access result, we must make sure their cacheability metadata is present on
* the render array. This method makes doing that simple.
* For instance, when a render array depends on some configuration, an entity,
* or an access result, we must make sure their cacheability metadata is
* present on the render array. This method makes doing that simple.
*
* @param array &$elements
* The render array to update.

View file

@ -37,16 +37,16 @@
* http://twig.sensiolabs.org/doc/templates.html
*
* @section sec_theme_hooks Theme Hooks
* The theme system is invoked in drupal_render() by calling the internal
* _theme() function, which operates on the concept of "theme hooks". Theme
* hooks define how a particular type of data should be rendered. They are
* registered by modules by implementing hook_theme(), which specifies the name
* of the hook, the input "variables" used to provide data and options, and
* other information. Modules implementing hook_theme() also need to provide a
* default implementation for each of their theme hooks, normally in a Twig
* file, and they may also provide preprocessing functions. For example, the
* core Search module defines a theme hook for a search result item in
* search_theme():
* The theme system is invoked in \Drupal\Core\Render\Renderer::doRender() by
* calling the \Drupal\Core\Theme\ThemeManagerInterface::render() function,
* which operates on the concept of "theme hooks". Theme hooks define how a
* particular type of data should be rendered. They are registered by modules by
* implementing hook_theme(), which specifies the name of the hook, the input
* "variables" used to provide data and options, and other information. Modules
* implementing hook_theme() also need to provide a default implementation for
* each of their theme hooks, normally in a Twig file, and they may also provide
* preprocessing functions. For example, the core Search module defines a theme
* hook for a search result item in search_theme():
* @code
* return array(
* 'search_result' => array(
@ -366,7 +366,7 @@
* @code
* '#cache' => [
* 'keys' => ['entity_view', 'node', $node->id()],
* 'contexts' => ['language'],
* 'contexts' => ['languages'],
* 'tags' => ['node:' . $node->id()],
* 'max-age' => Cache::PERMANENT,
* ],
@ -429,9 +429,10 @@
*
* @section render_pipeline The render pipeline
* The term "render pipeline" refers to the process Drupal uses to take
* information provided by modules and render it into a response. For more
* details on this process, see https://www.drupal.org/developing/api/8/render;
* for background on routing concepts, see @ref sec_controller.
* information provided by modules and render it into a response. See
* https://www.drupal.org/developing/api/8/render for more details on this
* process. For background on routing concepts, see
* @link routing Routing API. @endlink
*
* There are in fact multiple render pipelines:
* - Drupal always uses the Symfony render pipeline. See
@ -472,6 +473,36 @@
* @}
*/
/**
* @defgroup listing_page_element Page header for Elements page
* @{
* Introduction to form and render elements
*
* Render elements are referenced in render arrays. Render arrays contain data
* to be rendered, along with meta-data and attributes that specify how to
* render the data into markup; see the
* @link theme_render Render API topic @endlink for an overview of render
* arrays and render elements. Form arrays are a subset of render arrays,
* representing HTML forms; form elements are a subset of render elements,
* representing HTML elements for forms. See the
* @link form_api Form API topic @endlink for an overview of forms, form
* processing, and form arrays.
*
* Each form and render element type corresponds to an element plugin class;
* each of them either extends \Drupal\Core\Render\Element\RenderElement
* (render elements) or \Drupal\Core\Render\Element\FormElement (form
* elements). Usage and properties are documented on the individual classes,
* and the two base classes list common properties shared by all render
* elements and the form element subset, respectively.
*
* @see theme_render
* @see form_api
* @see \Drupal\Core\Render\Element\RenderElement
* @see \Drupal\Core\Render\Element\FormElement
*
* @}
*/
/**
* @addtogroup hooks
* @{
@ -512,7 +543,8 @@ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormSta
* preprocess variables for a specific theme hook, whether implemented as a
* template or function.
*
* For more detailed information, see _theme().
* For more detailed information, see the
* @link themeable Theme system overview topic @endlink.
*
* @param $variables
* The variables array (modify in place).
@ -560,7 +592,8 @@ function hook_preprocess(&$variables, $hook) {
* hook. It should only be used if a module needs to override or add to the
* theme preprocessing for a theme hook it didn't define.
*
* For more detailed information, see _theme().
* For more detailed information, see the
* @link themeable Theme system overview topic @endlink.
*
* @param $variables
* The variables array (modify in place).

View file

@ -432,7 +432,7 @@ class UrlGenerator implements UrlGeneratorInterface {
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function supports($name) {
// Support a route object and any string as route name.
@ -440,7 +440,7 @@ class UrlGenerator implements UrlGeneratorInterface {
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getRouteDebugMessage($name, array $parameters = array()) {
if (is_scalar($name)) {

View file

@ -331,8 +331,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
* Migrates the current session to a new session id.
*
* @param string $old_session_id
* The old session id. The new session id is $this->getId() unless
* $new_insecure_session_id is not empty.
* The old session ID. The new session ID is $this->getId().
*/
protected function migrateStoredSession($old_session_id) {
$fields = array('sid' => Crypt::hashBase64($this->getId()));

View file

@ -149,24 +149,24 @@ final class Settings {
}
/**
* Generates a prefix for APC user cache keys.
* Generates a prefix for APCu user cache keys.
*
* A standardized prefix is useful to allow visual inspection of an APC user
* A standardized prefix is useful to allow visual inspection of an APCu user
* cache. By default, this method will produce a unique prefix per site using
* the hash salt. If the setting 'apcu_ensure_unique_prefix' is set to FALSE
* then if the caller does not provide a $site_path only the Drupal root will
* be used. This allows WebTestBase to use the same prefix ensuring that the
* number of APC items created during a full test run is kept to a minimum.
* number of APCu items created during a full test run is kept to a minimum.
* Additionally, if a multi site implementation does not use site specific
* module directories setting apcu_ensure_unique_prefix would allow the sites
* to share APC cache items.
* to share APCu cache items.
*
* @param $identifier
* An identifier for the prefix. For example, 'class_loader' or
* 'cache_backend'.
*
* @return string
* The prefix for APC user cache keys.
* The prefix for APCu user cache keys.
*/
public static function getApcuPrefix($identifier, $root, $site_path = '') {
if (static::get('apcu_ensure_unique_prefix', TRUE)) {

View file

@ -66,8 +66,10 @@ interface StreamWrapperInterface extends PhpStreamWrapperInterface {
*/
/**
* Not visible in the UI or accessible via web, but readable and writable.
* E.g. the temporary directory for uploads.
* Defines the stream wrapper bit flag for a hidden file.
*
* This is not visible in the UI or accessible via web, but readable and
* writable; for instance, the temporary directory for file uploads.
*/
const HIDDEN = 0x000C;

View file

@ -315,8 +315,8 @@ class TwigExtension extends \Twig_Extension {
* ampersand ("&") which separates query params. Thus we cannot mark
* the generated URL as always safe, but only when we are sure there won't be
* multiple query params. This is the case when there are none or only one
* constant parameter given. E.g. we know beforehand this will not need to
* be escaped:
* constant parameter given. For instance, we know beforehand this will not
* need to be escaped:
* - path('route')
* - path('route', {'param': 'value'})
* But the following may need to be escaped:

View file

@ -81,8 +81,10 @@ class TwigSandboxPolicy implements \Twig_Sandbox_SecurityPolicyInterface {
* {@inheritdoc}
*/
public function checkMethodAllowed($obj, $method) {
if (isset($this->whitelisted_classes[get_class($obj)])) {
return TRUE;
foreach ($this->whitelisted_classes as $class => $key) {
if ($obj instanceof $class) {
return TRUE;
}
}
// Return quickly for an exact match of the method name.

View file

@ -84,7 +84,7 @@ class TwigTransTokenParser extends \Twig_TokenParser {
*
* @param \Twig_Node $body
* The expression to check.
* @param integer $lineno
* @param int $lineno
* The source line.
*
* @throws \Twig_Error_Syntax

View file

@ -47,12 +47,12 @@ class Registry implements DestructableInterface {
* - name: The name of the extension the original theme hook originates
* from; e.g., 'node' for theme hook 'node' of Node module.
* - theme path: The effective \Drupal\Core\Theme\ActiveTheme::getPath()
* during _theme(), available as
* 'directory' variable in templates. For functions, it should point to
* the respective theme.For templates, it should point to the directory
* that contains the template.
* during \Drupal\Core\Theme\ThemeManagerInterface::render(), available
* as 'directory' variable in templates. For functions, it should point
* to the respective theme. For templates, it should point to the
* directory that contains the template.
* - includes: (optional) An array of include files to load when the theme
* hook is executed by _theme().
* hook is executed by \Drupal\Core\Theme\ThemeManagerInterface::render().
* - file: (optional) A filename to add to 'includes', either prefixed with
* the value of 'path', or the path of the extension implementing
* hook_theme().
@ -389,7 +389,8 @@ class Registry implements DestructableInterface {
* in hook_theme(). If there is more than one implementation and
* 'render element' is not specified in a later one, then the previous
* definition is kept.
* - 'preprocess functions': See _theme() for detailed documentation.
* - See the @link themeable Theme system overview topic @endlink for
* detailed documentation.
* @param string $name
* The name of the module, theme engine, base theme engine, theme or base
* theme implementing hook_theme().
@ -530,7 +531,8 @@ class Registry implements DestructableInterface {
}
foreach ($prefixes as $prefix) {
// Only use non-hook-specific variable preprocessors for theming
// hooks implemented as templates. See _theme().
// hooks implemented as templates. See the @defgroup themeable
// topic.
if (isset($info['template']) && function_exists($prefix . '_preprocess')) {
$info['preprocess functions'][] = $prefix . '_preprocess';
}
@ -566,7 +568,7 @@ class Registry implements DestructableInterface {
$cache[$hook]['preprocess functions'] = array();
}
// Only use non-hook-specific variable preprocessors for theme hooks
// implemented as templates. See _theme().
// implemented as templates. See the @defgroup themeable topic.
if (isset($info['template']) && function_exists($name . '_preprocess')) {
$cache[$hook]['preprocess functions'][] = $name . '_preprocess';
}

View file

@ -267,7 +267,7 @@ class ThemeInitialization implements ThemeInitializationInterface {
*/
protected function getExtensions() {
if (!isset($this->extensions)) {
$this->extensions = array_merge($this->moduleHandler->getModuleList(), $this->themeHandler->listInfo());
$this->extensions = array_merge($this->moduleHandler->getModuleList(), $this->themeHandler->listInfo());
}
return $this->extensions;
}

View file

@ -138,11 +138,11 @@ class ThemeManager implements ThemeManagerInterface {
$active_theme = $this->getActiveTheme();
// If called before all modules are loaded, we do not necessarily have a full
// theme registry to work with, and therefore cannot process the theme
// If called before all modules are loaded, we do not necessarily have a
// full theme registry to work with, and therefore cannot process the theme
// request properly. See also \Drupal\Core\Theme\Registry::get().
if (!$this->moduleHandler->isLoaded() && !defined('MAINTENANCE_MODE')) {
throw new \Exception(t('_theme() may not be called until all modules are loaded.'));
throw new \Exception('The theme implementations may not be rendered until all modules are loaded.');
}
$theme_registry = $this->themeRegistry->getRuntime();
@ -180,9 +180,10 @@ class ThemeManager implements ThemeManagerInterface {
\Drupal::logger('theme')->warning('Theme hook %hook not found.', array('%hook' => $hook));
}
// There is no theme implementation for the hook passed. Return FALSE so
// the function calling _theme() can differentiate between a hook that
// exists and renders an empty string and a hook that is not
// implemented.
// the function calling
// \Drupal\Core\Theme\ThemeManagerInterface::render() can differentiate
// between a hook that exists and renders an empty string, and a hook
// that is not implemented.
return FALSE;
}
}
@ -233,8 +234,8 @@ class ThemeManager implements ThemeManagerInterface {
// Invoke hook_theme_suggestions_HOOK().
$suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, array($variables));
// If _theme() was invoked with a direct theme suggestion like
// '#theme' => 'node__article', add it to the suggestions array before
// If the theme implementation was invoked with a direct theme suggestion
// like '#theme' => 'node__article', add it to the suggestions array before
// invoking suggestion alter hooks.
if (isset($info['base hook'])) {
$suggestions[] = $hook;
@ -250,10 +251,10 @@ class ThemeManager implements ThemeManagerInterface {
$this->alter($hooks, $suggestions, $variables, $base_theme_hook);
// Check if each suggestion exists in the theme registry, and if so,
// use it instead of the hook that _theme() was called with. For example, a
// function may call _theme('node', ...), but a module can add
// 'node__article' as a suggestion via hook_theme_suggestions_HOOK_alter(),
// enabling a theme to have an alternate template file for article nodes.
// use it instead of the base hook. For example, a function may use
// '#theme' => 'node', but a module can add 'node__article' as a suggestion
// via hook_theme_suggestions_HOOK_alter(), enabling a theme to have
// an alternate template file for article nodes.
foreach (array_reverse($suggestions) as $suggestion) {
if ($theme_registry->has($suggestion)) {
$info = $theme_registry->get($suggestion);

View file

@ -23,7 +23,7 @@ class Timestamp extends IntegerData implements DateTimeInterface {
/**
* The data value as a UNIX timestamp.
*
* @var integer
* @var int
*/
protected $value;

View file

@ -260,7 +260,7 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI
$constraints['NotNull'] = array();
}
// Check if the class provides allowed values.
if (is_subclass_of($definition->getClass(),'Drupal\Core\TypedData\OptionsProviderInterface')) {
if (is_subclass_of($definition->getClass(), 'Drupal\Core\TypedData\OptionsProviderInterface')) {
$constraints['AllowedValues'] = array();
}
return $constraints;

View file

@ -26,11 +26,13 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
* The plugin configuration array, i.e. an array with the following keys:
* - data_definition: The data definition object, i.e. an instance of
* \Drupal\Core\TypedData\DataDefinitionInterface.
* - name: (optional) If a property or list item is to be created, the name
* of the property or the delta of the list item.
* - parent: (optional) If a property or list item is to be created, the
* parent typed data object implementing either the ListInterface or the
* ComplexDataInterface.
* - name: The name of the property or the delta of the list item if a
* property or list item is to be created. Otherwise, this should be set
* to NULL, but the key must be specified.
* - parent: The parent typed data object implementing either the
* ListInterface or the ComplexDataInterface if a property or list item is
* to be created. Otherwise, this should be set to NULL, but the key must
* be specified.
*
* @return \Drupal\Core\TypedData\TypedDataInterface
* The instantiated typed data object.
@ -78,7 +80,7 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
* class used by a data type is known, this method allows the creation of data
* definitions for any given data type.
*
* E.g., if a definition for a map is to be created, the following code
* For example, if a definition for a map is to be created, the following code
* could be used instead of calling this method with the argument 'map':
* @code
* $map_definition = \Drupal\Core\TypedData\MapDataDefinition::create();
@ -137,9 +139,10 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
* Get a typed data instance for a property of a given typed data object.
*
* This method will use prototyping for fast and efficient instantiation of
* many property objects with the same property path; e.g.,
* many property objects with the same property path; for example,
* when multiple comments are used comment_body.0.value needs to be
* instantiated very often.
*
* Prototyping is done by the root object's data type and the given
* property path, i.e. all property instances having the same property path
* and inheriting from the same data type are prototyped.
@ -203,9 +206,10 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
* Gets default constraints for the given data definition.
*
* This generates default constraint definitions based on the data definition;
* e.g. a NotNull constraint is generated if the data is defined as required.
* Besides that any constraints defined for the data type, i.e. below the
* 'constraint' key of the type's plugin definition, are taken into account.
* for example, a NotNull constraint is generated if the data is defined as
* required. Besides that, any constraints defined for the data type (that is,
* below the 'constraint' key of the type's plugin definition) are taken into
* account.
*
* @param \Drupal\Core\TypedData\DataDefinitionInterface $definition
* A data definition.
@ -222,12 +226,12 @@ interface TypedDataManagerInterface extends PluginManagerInterface, CachedDiscov
*
* The canonical representation is typically used when data is passed on to
* other code components. In many use cases, the TypedData object is mostly
* unified adapter wrapping a primary value (e.g. a string, an entity...)
* which is the canonical representation that consuming code like constraint
* unified adapter wrapping a primary value (a string, an entity, etc.) which
* is the canonical representation that consuming code like constraint
* validators are really interested in. For some APIs, though, the domain
* object (e.g. Field API's FieldItem and FieldItemList) directly implements
* TypedDataInterface, and the canonical representation is thus the data
* object itself.
* object (for example, Field API's FieldItem and FieldItemList) directly
* implements TypedDataInterface, and the canonical representation is thus the
* data object itself.
*
* When a TypedData object gets validated, for example, its canonical
* representation is passed on to constraint validators, which thus receive

View file

@ -52,7 +52,7 @@ class Error {
// The first element in the stack is the call, the second element gives us
// the caller. We skip calls that occurred in one of the classes of the
// database layer or in one of its global functions.
$db_functions = array('db_query', 'db_query_range');
$db_functions = array('db_query', 'db_query_range');
while (!empty($backtrace[1]) && ($caller = $backtrace[1]) &&
((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) ||
in_array($caller['function'], $db_functions))) {

View file

@ -22,8 +22,8 @@ use Drupal\Core\StringTranslation\TranslatableMarkup;
* plugin configuration during plugin instantiation.
*
* While core does not prefix constraint plugins, modules have to prefix them
* with the module name in order to avoid any naming conflicts. E.g. a "profile"
* module would have to prefix any constraints with "Profile".
* with the module name in order to avoid any naming conflicts; for example, a
* "profile" module would have to prefix any constraints with "Profile".
*
* Constraint plugins may specify data types to which support is limited via the
* 'type' key of plugin definitions. See

View file

@ -68,8 +68,8 @@ class AllowedValuesConstraintValidator extends ChoiceValidator implements Contai
// The parent implementation ignores values that are not set, but makes
// sure some choices are available firstly. However, we want to support
// empty choices for undefined values, e.g. if a term reference field
// points to an empty vocabulary.
// empty choices for undefined values; for instance, if a term reference
// field points to an empty vocabulary.
if (!isset($value)) {
return;
}