Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -165,7 +165,7 @@ function _batch_progress_page() {
|
|||
$query_options['op'] = $new_op;
|
||||
$batch['url']->setOption('query', $query_options);
|
||||
|
||||
$url = $batch['url']->toString();
|
||||
$url = $batch['url']->toString(TRUE)->getGeneratedUrl();
|
||||
|
||||
$build = array(
|
||||
'#theme' => 'progress_bar',
|
||||
|
|
|
@ -23,7 +23,7 @@ use Drupal\Core\Language\LanguageInterface;
|
|||
/**
|
||||
* Minimum supported version of PHP.
|
||||
*/
|
||||
const DRUPAL_MINIMUM_PHP = '5.4.5';
|
||||
const DRUPAL_MINIMUM_PHP = '5.5.9';
|
||||
|
||||
/**
|
||||
* Minimum recommended value of PHP memory_limit.
|
||||
|
@ -174,7 +174,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
|
|||
if (!empty($config_directories[$type])) {
|
||||
return $config_directories[$type];
|
||||
}
|
||||
throw new \Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type)));
|
||||
throw new \Exception("The configuration directory type '$type' does not exist");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -563,7 +563,7 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE)
|
|||
|
||||
$new = array(
|
||||
'safe' => SafeMarkup::isSafe($message),
|
||||
'message' => $message,
|
||||
'message' => (string) $message,
|
||||
);
|
||||
if ($repeat || !in_array($new, $_SESSION['messages'][$type])) {
|
||||
$_SESSION['messages'][$type][] = $new;
|
||||
|
@ -679,7 +679,7 @@ function _drupal_error_handler($error_level, $message, $filename, $line, $contex
|
|||
* always fatal: the execution of the script will stop as soon as the exception
|
||||
* handler exits.
|
||||
*
|
||||
* @param \Exception|\BaseException $exception
|
||||
* @param \Exception|\Throwable $exception
|
||||
* The exception object that was thrown.
|
||||
*/
|
||||
function _drupal_exception_handler($exception) {
|
||||
|
@ -689,12 +689,13 @@ function _drupal_exception_handler($exception) {
|
|||
// Log the message to the watchdog and return an error page to the user.
|
||||
_drupal_log_error(Error::decodeException($exception), TRUE);
|
||||
}
|
||||
// PHP 7 introduces BaseExceptions.
|
||||
catch (BaseException $exception2) {
|
||||
_drupal_exception_handler_additional($exception, $exception2);
|
||||
// PHP 7 introduces Throwable, which covers both Error and
|
||||
// Exception throwables.
|
||||
catch (\Throwable $error) {
|
||||
_drupal_exception_handler_additional($exception, $error);
|
||||
}
|
||||
// In order to be compatibile with PHP 5 we also catch regular Exceptions.
|
||||
catch (Exception $exception2) {
|
||||
catch (\Exception $exception2) {
|
||||
_drupal_exception_handler_additional($exception, $exception2);
|
||||
}
|
||||
}
|
||||
|
@ -702,9 +703,9 @@ function _drupal_exception_handler($exception) {
|
|||
/**
|
||||
* Displays any additional errors caught while handling an exception.
|
||||
*
|
||||
* @param \Exception|\BaseException $exception
|
||||
* @param \Exception|\Throwable $exception
|
||||
* The first exception object that was thrown.
|
||||
* @param \Exception|\BaseException $exception
|
||||
* @param \Exception|\Throwable $exception2
|
||||
* The second exception object that was thrown.
|
||||
*/
|
||||
function _drupal_exception_handler_additional($exception, $exception2) {
|
||||
|
@ -1098,12 +1099,13 @@ function _drupal_shutdown_function() {
|
|||
call_user_func_array($callback['callback'], $callback['arguments']);
|
||||
}
|
||||
}
|
||||
// PHP 7 introduces BaseExceptions.
|
||||
catch (BaseException $exception) {
|
||||
_drupal_shutdown_function_handle_exception($exception);
|
||||
// PHP 7 introduces Throwable, which covers both Error and
|
||||
// Exception throwables.
|
||||
catch (\Throwable $error) {
|
||||
_drupal_shutdown_function_handle_exception($error);
|
||||
}
|
||||
// In order to be compatibile with PHP 5 we also catch regular Exceptions.
|
||||
catch (Exception $exception) {
|
||||
catch (\Exception $exception) {
|
||||
_drupal_shutdown_function_handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
@ -1111,7 +1113,7 @@ function _drupal_shutdown_function() {
|
|||
/**
|
||||
* Displays and logs any errors that may happen during shutdown.
|
||||
*
|
||||
* @param \Exception|\BaseException $exception
|
||||
* @param \Exception|\Throwable $exception
|
||||
* The exception object that was thrown.
|
||||
*
|
||||
* @see _drupal_shutdown_function()
|
||||
|
|
|
@ -856,9 +856,9 @@ function drupal_process_states(&$elements) {
|
|||
* foreach ($regions as $region) {
|
||||
* drupal_attach_tabledrag('my-module-table', array(
|
||||
* 'action' => 'order',
|
||||
* 'relationship' => sibling',
|
||||
* 'relationship' => 'sibling',
|
||||
* 'group' => 'my-elements-weight',
|
||||
* 'subgroup' => my-elements-weight-' . $region,
|
||||
* 'subgroup' => 'my-elements-weight-' . $region,
|
||||
* ));
|
||||
* }
|
||||
* @endcode
|
||||
|
@ -1036,7 +1036,7 @@ function drupal_pre_render_links($element) {
|
|||
$child = &$element[$key];
|
||||
// If the child has links which have not been printed yet and the user has
|
||||
// access to it, merge its links in to the parent.
|
||||
if (isset($child['#links']) && empty($child['#printed']) && (!isset($child['#access']) || $child['#access'])) {
|
||||
if (isset($child['#links']) && empty($child['#printed']) && Element::isVisibleElement($child)) {
|
||||
$element['#links'] += $child['#links'];
|
||||
// Mark the child as having been printed already (so that its links
|
||||
// cannot be mistakenly rendered twice).
|
||||
|
@ -1295,8 +1295,10 @@ function drupal_flush_all_caches() {
|
|||
// Reset all static caches.
|
||||
drupal_static_reset();
|
||||
|
||||
// Wipe the PHP Storage caches.
|
||||
PhpStorageFactory::get('service_container')->deleteAll();
|
||||
// Invalidate the container.
|
||||
\Drupal::service('kernel')->invalidateContainer();
|
||||
|
||||
// Wipe the Twig PHP Storage cache.
|
||||
PhpStorageFactory::get('twig')->deleteAll();
|
||||
|
||||
// Rebuild module and theme data.
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
use Drupal\Core\Site\Settings;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Core systems for the database layer.
|
||||
|
@ -13,6 +9,10 @@ use Drupal\Core\Site\Settings;
|
|||
* file only, as they cannot auto-load the way classes can.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Database\Query\Condition;
|
||||
use Drupal\Core\Site\Settings;
|
||||
|
||||
/**
|
||||
* @addtogroup database
|
||||
* @{
|
||||
|
@ -28,23 +28,29 @@ use Drupal\Core\Site\Settings;
|
|||
* Do not use this function for INSERT, UPDATE, or DELETE queries. Those should
|
||||
* be handled via db_insert(), db_update() and db_delete() respectively.
|
||||
*
|
||||
* @param $query
|
||||
* @param string|\Drupal\Core\Database\StatementInterface $query
|
||||
* The prepared statement query to run. Although it will accept both named and
|
||||
* unnamed placeholders, named placeholders are strongly preferred as they are
|
||||
* more self-documenting. If the argument corresponding to a placeholder is
|
||||
* an array of values to be expanded, e.g. for an IN query, the placeholder
|
||||
* should be named with a trailing bracket like :example[]
|
||||
* @param $args
|
||||
* @param array $args
|
||||
* An array of values to substitute into the query. If the query uses named
|
||||
* placeholders, this is an associative array in any order. If the query uses
|
||||
* unnamed placeholders (?), this is an indexed array and the order must match
|
||||
* the order of placeholders in the query string.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\StatementInterface
|
||||
* A prepared statement object, already executed.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call query() on it. E.g.
|
||||
* $injected_database->query($query, $args, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::query()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_query($query, array $args = array(), array $options = array()) {
|
||||
|
@ -58,7 +64,7 @@ function db_query($query, array $args = array(), array $options = array()) {
|
|||
/**
|
||||
* Executes a query against the active database, restricted to a range.
|
||||
*
|
||||
* @param $query
|
||||
* @param string $query
|
||||
* The prepared statement query to run. Although it will accept both named and
|
||||
* unnamed placeholders, named placeholders are strongly preferred as they are
|
||||
* more self-documenting.
|
||||
|
@ -66,17 +72,23 @@ function db_query($query, array $args = array(), array $options = array()) {
|
|||
* The first record from the result set to return.
|
||||
* @param $count
|
||||
* The number of records to return from the result set.
|
||||
* @param $args
|
||||
* @param array $args
|
||||
* An array of values to substitute into the query. If the query uses named
|
||||
* placeholders, this is an associative array in any order. If the query uses
|
||||
* unnamed placeholders (?), this is an indexed array and the order must match
|
||||
* the order of placeholders in the query string.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\StatementInterface
|
||||
* A prepared statement object, already executed.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call queryRange() on it. E.g.
|
||||
* $injected_database->queryRange($query, $from, $count, $args, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::queryRange()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_query_range($query, $from, $count, array $args = array(), array $options = array()) {
|
||||
|
@ -92,21 +104,27 @@ function db_query_range($query, $from, $count, array $args = array(), array $opt
|
|||
*
|
||||
* The execution of the query string happens against the active database.
|
||||
*
|
||||
* @param $query
|
||||
* @param string $query
|
||||
* The prepared SELECT statement query to run. Although it will accept both
|
||||
* named and unnamed placeholders, named placeholders are strongly preferred
|
||||
* as they are more self-documenting.
|
||||
* @param $args
|
||||
* @param array $args
|
||||
* An array of values to substitute into the query. If the query uses named
|
||||
* placeholders, this is an associative array in any order. If the query uses
|
||||
* unnamed placeholders (?), this is an indexed array and the order must match
|
||||
* the order of placeholders in the query string.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return
|
||||
* The name of the temporary table.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call queryTemporary() on it. E.g.
|
||||
* $injected_database->queryTemporary($query, $args, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::queryTemporary()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_query_temporary($query, array $args = array(), array $options = array()) {
|
||||
|
@ -120,13 +138,20 @@ function db_query_temporary($query, array $args = array(), array $options = arra
|
|||
/**
|
||||
* Returns a new InsertQuery object for the active database.
|
||||
*
|
||||
* @param $table
|
||||
* @param string $table
|
||||
* The table into which to insert.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Insert
|
||||
* A new Insert object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call insert() on it. E.g. $injected_database->insert($table, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::insert()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_insert($table, array $options = array()) {
|
||||
if (empty($options['target']) || $options['target'] == 'replica') {
|
||||
|
@ -138,13 +163,20 @@ function db_insert($table, array $options = array()) {
|
|||
/**
|
||||
* Returns a new MergeQuery object for the active database.
|
||||
*
|
||||
* @param $table
|
||||
* The table into which to merge.
|
||||
* @param $options
|
||||
* @param string $table
|
||||
* Name of the table to associate with this query.
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Merge
|
||||
* A new Merge object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call merge() on it. E.g. $injected_database->merge($table, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::merge()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_merge($table, array $options = array()) {
|
||||
if (empty($options['target']) || $options['target'] == 'replica') {
|
||||
|
@ -156,13 +188,20 @@ function db_merge($table, array $options = array()) {
|
|||
/**
|
||||
* Returns a new UpdateQuery object for the active database.
|
||||
*
|
||||
* @param $table
|
||||
* @param string $table
|
||||
* The table to update.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Update
|
||||
* A new Update object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call update() on it. E.g. $injected_database->update($table, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::update()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_update($table, array $options = array()) {
|
||||
if (empty($options['target']) || $options['target'] == 'replica') {
|
||||
|
@ -174,13 +213,20 @@ function db_update($table, array $options = array()) {
|
|||
/**
|
||||
* Returns a new DeleteQuery object for the active database.
|
||||
*
|
||||
* @param $table
|
||||
* @param string $table
|
||||
* The table from which to delete.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Delete
|
||||
* A new Delete object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call delete() on it. E.g. $injected_database->delete($table, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::delete()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_delete($table, array $options = array()) {
|
||||
if (empty($options['target']) || $options['target'] == 'replica') {
|
||||
|
@ -192,13 +238,20 @@ function db_delete($table, array $options = array()) {
|
|||
/**
|
||||
* Returns a new TruncateQuery object for the active database.
|
||||
*
|
||||
* @param $table
|
||||
* The table from which to delete.
|
||||
* @param $options
|
||||
* @param string $table
|
||||
* The table from which to truncate.
|
||||
* @param array $options
|
||||
* An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Truncate
|
||||
* A new Truncate object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call truncate() on it. E.g. $injected_database->truncate($table, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::truncate()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_truncate($table, array $options = array()) {
|
||||
if (empty($options['target']) || $options['target'] == 'replica') {
|
||||
|
@ -210,16 +263,25 @@ function db_truncate($table, array $options = array()) {
|
|||
/**
|
||||
* Returns a new SelectQuery object for the active database.
|
||||
*
|
||||
* @param $table
|
||||
* The base table for this query. May be a string or another SelectQuery
|
||||
* object. If a query object is passed, it will be used as a subselect.
|
||||
* @param $alias
|
||||
* @param string|\Drupal\Core\Database\Query\SelectInterface $table
|
||||
* The base table for this query. May be a string or another SelectInterface
|
||||
* object. If a SelectInterface object is passed, it will be used as a
|
||||
* subselect.
|
||||
* @param string $alias
|
||||
* (optional) The alias for the base table of this query.
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* (optional) An array of options to control how the query operates.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Select
|
||||
* A new Select object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call select() on it. E.g.
|
||||
* $injected_database->select($table, $alias, $options);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::select()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_select($table, $alias = NULL, array $options = array()) {
|
||||
if (empty($options['target'])) {
|
||||
|
@ -239,6 +301,14 @@ function db_select($table, $alias = NULL, array $options = array()) {
|
|||
*
|
||||
* @return \Drupal\Core\Database\Transaction
|
||||
* A new Transaction object for this connection.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call startTransaction() on it. E.g.
|
||||
* $injected_database->startTransaction($name);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::startTransaction()
|
||||
* @see \Drupal\Core\Database\Connection::defaultOptions()
|
||||
*/
|
||||
function db_transaction($name = NULL, array $options = array()) {
|
||||
if (empty($options['target'])) {
|
||||
|
@ -253,8 +323,11 @@ function db_transaction($name = NULL, array $options = array()) {
|
|||
* @param $key
|
||||
* The key in the $databases array to set as the default database.
|
||||
*
|
||||
* @return
|
||||
* @return string|null
|
||||
* The key of the formerly active database.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Database\Database::setActiveConnection().
|
||||
*/
|
||||
function db_set_active($key = 'default') {
|
||||
return Database::setActiveConnection($key);
|
||||
|
@ -268,8 +341,14 @@ function db_set_active($key = 'default') {
|
|||
* @param $table
|
||||
* The table name to escape.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The escaped table name as a string.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call escapeTable() on it. E.g. $injected_database->escapeTable($table);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::escapeTable()
|
||||
*/
|
||||
function db_escape_table($table) {
|
||||
return Database::getConnection()->escapeTable($table);
|
||||
|
@ -280,11 +359,17 @@ function db_escape_table($table) {
|
|||
*
|
||||
* Only keeps alphanumeric and underscores.
|
||||
*
|
||||
* @param $field
|
||||
* @param string $field
|
||||
* The field name to escape.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The escaped field name as a string.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call escapeTable() on it. E.g. $injected_database->escapeTable($table);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::escapeField()
|
||||
*/
|
||||
function db_escape_field($field) {
|
||||
return Database::getConnection()->escapeField($field);
|
||||
|
@ -314,11 +399,17 @@ function db_escape_field($field) {
|
|||
* Backslash is defined as escape character for LIKE patterns in
|
||||
* DatabaseCondition::mapConditionOperator().
|
||||
*
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* The string to escape.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The escaped string.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call escapeLike() on it. E.g. $injected_database->escapeLike($string);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::escapeLike()
|
||||
*/
|
||||
function db_like($string) {
|
||||
return Database::getConnection()->escapeLike($string);
|
||||
|
@ -327,8 +418,14 @@ function db_like($string) {
|
|||
/**
|
||||
* Retrieves the name of the currently active database driver.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The name of the currently active database driver.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call driver() on it. E.g. $injected_database->driver($string);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::driver()
|
||||
*/
|
||||
function db_driver() {
|
||||
return Database::getConnection()->driver();
|
||||
|
@ -337,9 +434,14 @@ function db_driver() {
|
|||
/**
|
||||
* Closes the active database connection.
|
||||
*
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array of options to control which connection is closed. Only the target
|
||||
* key has any meaning in this case.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Database\Database::closeConnection($target).
|
||||
*
|
||||
* @see \Drupal\Core\Database\Database::closeConnection()
|
||||
*/
|
||||
function db_close(array $options = array()) {
|
||||
if (empty($options['target'])) {
|
||||
|
@ -355,13 +457,19 @@ function db_close(array $options = array()) {
|
|||
* serial field is preferred, and InsertQuery::execute() returns the value of
|
||||
* the last ID inserted.
|
||||
*
|
||||
* @param $existing_id
|
||||
* @param int $existing_id
|
||||
* After a database import, it might be that the sequences table is behind, so
|
||||
* by passing in a minimum ID, it can be assured that we never issue the same
|
||||
* ID.
|
||||
*
|
||||
* @return
|
||||
* @return int
|
||||
* An integer number larger than any number returned before for this sequence.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container and
|
||||
* call nextId() on it. E.g. $injected_database->nextId($existing_id);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Connection::nextId()
|
||||
*/
|
||||
function db_next_id($existing_id = 0) {
|
||||
return Database::getConnection()->nextId($existing_id);
|
||||
|
@ -372,6 +480,12 @@ function db_next_id($existing_id = 0) {
|
|||
*
|
||||
* @return \Drupal\Core\Database\Query\Condition
|
||||
* A new Condition object, set to "OR" all conditions together.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Create
|
||||
* a \Drupal\Core\Database\Query\Condition object, specifying an OR
|
||||
* conjunction: new Condition('OR');
|
||||
*
|
||||
* @see \Drupal\Core\Database\Query\Condition
|
||||
*/
|
||||
function db_or() {
|
||||
return new Condition('OR');
|
||||
|
@ -382,6 +496,12 @@ function db_or() {
|
|||
*
|
||||
* @return \Drupal\Core\Database\Query\Condition
|
||||
* A new Condition object, set to "AND" all conditions together.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Create
|
||||
* a \Drupal\Core\Database\Query\Condition object, specifying an AND
|
||||
* conjunction: new Condition('AND');
|
||||
*
|
||||
* @see \Drupal\Core\Database\Query\Condition
|
||||
*/
|
||||
function db_and() {
|
||||
return new Condition('AND');
|
||||
|
@ -392,6 +512,12 @@ function db_and() {
|
|||
*
|
||||
* @return \Drupal\Core\Database\Query\Condition
|
||||
* A new Condition object, set to "XOR" all conditions together.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Create
|
||||
* a \Drupal\Core\Database\Query\Condition object, specifying an XOR
|
||||
* conjunction: new Condition('XOR');
|
||||
*
|
||||
* @see \Drupal\Core\Database\Query\Condition
|
||||
*/
|
||||
function db_xor() {
|
||||
return new Condition('XOR');
|
||||
|
@ -403,11 +529,17 @@ function db_xor() {
|
|||
* Internal API function call. The db_and(), db_or(), and db_xor()
|
||||
* functions are preferred.
|
||||
*
|
||||
* @param $conjunction
|
||||
* @param string $conjunction
|
||||
* The conjunction to use for query conditions (AND, OR or XOR).
|
||||
*
|
||||
* @return \Drupal\Core\Database\Query\Condition
|
||||
* A new Condition object, set to the specified conjunction.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Create
|
||||
* a \Drupal\Core\Database\Query\Condition object, specifying the desired
|
||||
* conjunction: new Condition($conjunctin);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Query\Condition
|
||||
*/
|
||||
function db_condition($conjunction) {
|
||||
return new Condition($conjunction);
|
||||
|
@ -426,10 +558,17 @@ function db_condition($conjunction) {
|
|||
/**
|
||||
* Creates a new table from a Drupal table definition.
|
||||
*
|
||||
* @param $name
|
||||
* @param string $name
|
||||
* The name of the table to create.
|
||||
* @param $table
|
||||
* @param array $table
|
||||
* A Schema API table definition array.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call createTable() on it. E.g.
|
||||
* $injected_database->schema()->createTable($name, $table);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::createTable()
|
||||
*/
|
||||
function db_create_table($name, $table) {
|
||||
return Database::getConnection()->schema()->createTable($name, $table);
|
||||
|
@ -441,11 +580,18 @@ function db_create_table($name, $table) {
|
|||
* This is usually an identity function but if a key/index uses a column prefix
|
||||
* specification, this function extracts just the name.
|
||||
*
|
||||
* @param $fields
|
||||
* @param array $fields
|
||||
* An array of key/index column specifiers.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array of field names.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call fieldNames() on it. E.g.
|
||||
* $injected_database->schema()->fieldNames($fields);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::fieldNames()
|
||||
*/
|
||||
function db_field_names($fields) {
|
||||
return Database::getConnection()->schema()->fieldNames($fields);
|
||||
|
@ -454,13 +600,20 @@ function db_field_names($fields) {
|
|||
/**
|
||||
* Checks if an index exists in the given table.
|
||||
*
|
||||
* @param $table
|
||||
* @param string $table
|
||||
* The name of the table in drupal (no prefixing).
|
||||
* @param $name
|
||||
* @param string $name
|
||||
* The name of the index in drupal (no prefixing).
|
||||
*
|
||||
* @return
|
||||
* @return bool
|
||||
* TRUE if the given index exists, otherwise FALSE.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call indexExists() on it. E.g.
|
||||
* $injected_database->schema()->indexExists($table, $name);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::indexExists()
|
||||
*/
|
||||
function db_index_exists($table, $name) {
|
||||
return Database::getConnection()->schema()->indexExists($table, $name);
|
||||
|
@ -469,11 +622,18 @@ function db_index_exists($table, $name) {
|
|||
/**
|
||||
* Checks if a table exists.
|
||||
*
|
||||
* @param $table
|
||||
* @param string $table
|
||||
* The name of the table in drupal (no prefixing).
|
||||
*
|
||||
* @return
|
||||
* @return bool
|
||||
* TRUE if the given table exists, otherwise FALSE.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call tableExists() on it. E.g.
|
||||
* $injected_database->schema()->tableExists($table);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::tableExists()
|
||||
*/
|
||||
function db_table_exists($table) {
|
||||
return Database::getConnection()->schema()->tableExists($table);
|
||||
|
@ -487,8 +647,15 @@ function db_table_exists($table) {
|
|||
* @param $field
|
||||
* The name of the field.
|
||||
*
|
||||
* @return
|
||||
* @return bool
|
||||
* TRUE if the given column exists, otherwise FALSE.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call fieldExists() on it. E.g.
|
||||
* $injected_database->schema()->fieldExists($table, $field);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::fieldExists()
|
||||
*/
|
||||
function db_field_exists($table, $field) {
|
||||
return Database::getConnection()->schema()->fieldExists($table, $field);
|
||||
|
@ -497,21 +664,24 @@ function db_field_exists($table, $field) {
|
|||
/**
|
||||
* Finds all tables that are like the specified base table name.
|
||||
*
|
||||
* @param $table_expression
|
||||
* @param string $table_expression
|
||||
* An SQL expression, for example "simpletest%" (without the quotes).
|
||||
* BEWARE: this is not prefixed, the caller should take care of that.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* Array, both the keys and the values are the matching tables.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call findTables() on it. E.g.
|
||||
* $injected_database->schema()->findTables($table_expression);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::findTables()
|
||||
*/
|
||||
function db_find_tables($table_expression) {
|
||||
return Database::getConnection()->schema()->findTables($table_expression);
|
||||
}
|
||||
|
||||
function _db_create_keys_sql($spec) {
|
||||
return Database::getConnection()->schema()->createKeysSql($spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a table.
|
||||
*
|
||||
|
@ -519,6 +689,13 @@ function _db_create_keys_sql($spec) {
|
|||
* The current name of the table to be renamed.
|
||||
* @param $new_name
|
||||
* The new name for the table.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call renameTable() on it. E.g.
|
||||
* $injected_database->schema()->renameTable($table, $new_name);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::renameTable()
|
||||
*/
|
||||
function db_rename_table($table, $new_name) {
|
||||
return Database::getConnection()->schema()->renameTable($table, $new_name);
|
||||
|
@ -529,6 +706,13 @@ function db_rename_table($table, $new_name) {
|
|||
*
|
||||
* @param $table
|
||||
* The table to be dropped.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call dropTable() on it. E.g.
|
||||
* $injected_database->schema()->dropTable($table);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::dropTable()
|
||||
*/
|
||||
function db_drop_table($table) {
|
||||
return Database::getConnection()->schema()->dropTable($table);
|
||||
|
@ -541,18 +725,24 @@ function db_drop_table($table) {
|
|||
* Name of the table to be altered.
|
||||
* @param $field
|
||||
* Name of the field to be added.
|
||||
* @param $spec
|
||||
* @param array $spec
|
||||
* The field specification array, as taken from a schema definition. The
|
||||
* specification may also contain the key 'initial'; the newly-created field
|
||||
* will be set to the value of the key in all rows. This is most useful for
|
||||
* creating NOT NULL columns with no default value in existing tables.
|
||||
* @param $keys_new
|
||||
* @param array $keys_new
|
||||
* (optional) Keys and indexes specification to be created on the table along
|
||||
* with adding the field. The format is the same as a table specification, but
|
||||
* without the 'fields' element. If you are adding a type 'serial' field, you
|
||||
* MUST specify at least one key or index including it in this array. See
|
||||
* db_change_field() for more explanation why.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call addField() on it. E.g.
|
||||
* $injected_database->schema()->addField($table, $field, $spec, $keys_new);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::addField()
|
||||
* @see db_change_field()
|
||||
*/
|
||||
function db_add_field($table, $field, $spec, $keys_new = array()) {
|
||||
|
@ -566,6 +756,17 @@ function db_add_field($table, $field, $spec, $keys_new = array()) {
|
|||
* The table to be altered.
|
||||
* @param $field
|
||||
* The field to be dropped.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the field was successfully dropped, FALSE if there was no field by
|
||||
* that name to begin with.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call dropField() on it. E.g.
|
||||
* $injected_database->schema()->dropField($table, $field);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::dropField()
|
||||
*/
|
||||
function db_drop_field($table, $field) {
|
||||
return Database::getConnection()->schema()->dropField($table, $field);
|
||||
|
@ -580,6 +781,13 @@ function db_drop_field($table, $field) {
|
|||
* The field to be altered.
|
||||
* @param $default
|
||||
* Default value to be set. NULL for 'default NULL'.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call fieldSetDefault() on it. E.g.
|
||||
* $injected_database->schema()->fieldSetDefault($table, $field, $default);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::fieldSetDefault()
|
||||
*/
|
||||
function db_field_set_default($table, $field, $default) {
|
||||
return Database::getConnection()->schema()->fieldSetDefault($table, $field, $default);
|
||||
|
@ -592,6 +800,13 @@ function db_field_set_default($table, $field, $default) {
|
|||
* The table to be altered.
|
||||
* @param $field
|
||||
* The field to be altered.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call fieldSetNoDefault() on it. E.g.
|
||||
* $injected_database->schema()->fieldSetNoDefault($table, $field);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::fieldSetNoDefault()
|
||||
*/
|
||||
function db_field_set_no_default($table, $field) {
|
||||
return Database::getConnection()->schema()->fieldSetNoDefault($table, $field);
|
||||
|
@ -604,6 +819,13 @@ function db_field_set_no_default($table, $field) {
|
|||
* Name of the table to be altered.
|
||||
* @param $fields
|
||||
* Array of fields for the primary key.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call addPrimaryKey() on it. E.g.
|
||||
* $injected_database->schema()->addPrimaryKey($table, $fields);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::addPrimaryKey()
|
||||
*/
|
||||
function db_add_primary_key($table, $fields) {
|
||||
return Database::getConnection()->schema()->addPrimaryKey($table, $fields);
|
||||
|
@ -614,6 +836,17 @@ function db_add_primary_key($table, $fields) {
|
|||
*
|
||||
* @param $table
|
||||
* Name of the table to be altered.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the primary key was successfully dropped, FALSE if there was no
|
||||
* primary key on this table to begin with.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call dropPrimaryKey() on it. E.g.
|
||||
* $injected_database->schema()->dropPrimaryKey($table);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::dropPrimaryKey()
|
||||
*/
|
||||
function db_drop_primary_key($table) {
|
||||
return Database::getConnection()->schema()->dropPrimaryKey($table);
|
||||
|
@ -626,8 +859,15 @@ function db_drop_primary_key($table) {
|
|||
* The table to be altered.
|
||||
* @param $name
|
||||
* The name of the key.
|
||||
* @param $fields
|
||||
* @param array $fields
|
||||
* An array of field names.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call addUniqueKey() on it. E.g.
|
||||
* $injected_database->schema()->addUniqueKey($table, $name, $fields);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::addUniqueKey()
|
||||
*/
|
||||
function db_add_unique_key($table, $name, $fields) {
|
||||
return Database::getConnection()->schema()->addUniqueKey($table, $name, $fields);
|
||||
|
@ -640,6 +880,17 @@ function db_add_unique_key($table, $name, $fields) {
|
|||
* The table to be altered.
|
||||
* @param $name
|
||||
* The name of the key.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the key was successfully dropped, FALSE if there was no key by
|
||||
* that name to begin with.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call dropUniqueKey() on it. E.g.
|
||||
* $injected_database->schema()->dropUniqueKey($table, $name);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::dropUniqueKey()
|
||||
*/
|
||||
function db_drop_unique_key($table, $name) {
|
||||
return Database::getConnection()->schema()->dropUniqueKey($table, $name);
|
||||
|
@ -652,8 +903,15 @@ function db_drop_unique_key($table, $name) {
|
|||
* The table to be altered.
|
||||
* @param $name
|
||||
* The name of the index.
|
||||
* @param $fields
|
||||
* @param array $fields
|
||||
* An array of field names.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call addIndex() on it. E.g.
|
||||
* $injected_database->schema()->addIndex($table, $name, $fields);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::addIndex()
|
||||
*/
|
||||
function db_add_index($table, $name, $fields) {
|
||||
return Database::getConnection()->schema()->addIndex($table, $name, $fields);
|
||||
|
@ -666,6 +924,17 @@ function db_add_index($table, $name, $fields) {
|
|||
* The table to be altered.
|
||||
* @param $name
|
||||
* The name of the index.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the index was successfully dropped, FALSE if there was no index
|
||||
* by that name to begin with.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call dropIndex() on it. E.g.
|
||||
* $injected_database->schema()->dropIndex($table, $name);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::dropIndex()
|
||||
*/
|
||||
function db_drop_index($table, $name) {
|
||||
return Database::getConnection()->schema()->dropIndex($table, $name);
|
||||
|
@ -726,10 +995,17 @@ function db_drop_index($table, $name) {
|
|||
* change the name).
|
||||
* @param $spec
|
||||
* The field specification for the new field.
|
||||
* @param $keys_new
|
||||
* @param array $keys_new
|
||||
* (optional) Keys and indexes specification to be created on the table along
|
||||
* with changing the field. The format is the same as a table specification
|
||||
* but without the 'fields' element.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
|
||||
* a database connection injected into your service from the container, get
|
||||
* its schema driver, and call changeField() on it. E.g.
|
||||
* $injected_database->schema()->changeField($table, $field, $field_new, $spec, $keys_new);
|
||||
*
|
||||
* @see \Drupal\Core\Database\Schema::changeField()
|
||||
*/
|
||||
function db_change_field($table, $field, $field_new, $spec, $keys_new = array()) {
|
||||
return Database::getConnection()->schema()->changeField($table, $field, $field_new, $spec, $keys_new);
|
||||
|
|
|
@ -31,6 +31,11 @@ function entity_render_cache_clear() {
|
|||
* @return array
|
||||
* The bundle info for a specific entity type, or all entity types.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Entity\EntityManagerInterface::getBundleInfo() for a single
|
||||
* bundle, or \Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo()
|
||||
* for all bundles.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getBundleInfo()
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo()
|
||||
*/
|
||||
|
@ -56,8 +61,18 @@ function entity_get_bundles($entity_type = NULL) {
|
|||
* @return \Drupal\Core\Entity\EntityInterface|null
|
||||
* The entity object, or NULL if there is no entity with the given ID.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* The method overriding Entity::load() for the entity type, e.g.
|
||||
* \Drupal\node\Entity\Node::load() if the entity type is known. If the
|
||||
* entity type is variable, use the entity manager service to load the entity
|
||||
* from the entity storage:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->load($id)
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::load()
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::load()
|
||||
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
|
||||
* @see \Drupal\Core\Entity\Query\QueryInterface
|
||||
*/
|
||||
|
@ -81,8 +96,15 @@ function entity_load($entity_type, $id, $reset = FALSE) {
|
|||
* The entity object, or NULL if there is no entity with the given revision
|
||||
* id.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadRevision() method to load a specific entity
|
||||
* revision:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadRevision($revision_id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadRevision()
|
||||
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
|
||||
*/
|
||||
function entity_revision_load($entity_type, $revision_id) {
|
||||
|
@ -98,6 +120,16 @@ function entity_revision_load($entity_type, $revision_id) {
|
|||
* The entity type to load, e.g. node or user.
|
||||
* @param $revision_id
|
||||
* The revision ID to delete.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's deleteRevision() method to delete a specific entity
|
||||
* revision:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)>deleteRevision($revision_id);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::deleteRevision()
|
||||
*/
|
||||
function entity_revision_delete($entity_type, $revision_id) {
|
||||
\Drupal::entityManager()
|
||||
|
@ -134,8 +166,18 @@ function entity_revision_delete($entity_type, $revision_id) {
|
|||
* @return array
|
||||
* An array of entity objects indexed by their IDs.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* The method overriding Entity::loadMultiple() for the entity type, e.g.
|
||||
* \Drupal\node\Entity\Node::loadMultiple() if the entity type is known. If
|
||||
* the entity type is variable, use the entity manager service to load the
|
||||
* entity from the entity storage:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadMultiple($id)
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage
|
||||
* @see \Drupal\Core\Entity\Query\QueryInterface
|
||||
*/
|
||||
|
@ -159,6 +201,16 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
|
|||
* @return array
|
||||
* An array of entity objects indexed by their IDs. Returns an empty array if
|
||||
* no matching entities are found.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadByProperties() method to load an entity by their
|
||||
* property values:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadByProperties($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadByProperties()
|
||||
*/
|
||||
function entity_load_multiple_by_properties($entity_type, array $values) {
|
||||
return \Drupal::entityManager()
|
||||
|
@ -179,8 +231,17 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
|
|||
* @param $id
|
||||
* The ID of the entity to load.
|
||||
*
|
||||
* @return
|
||||
* @return \Drupal\Core\Entity\EntityInterface|null
|
||||
* The unchanged entity, or FALSE if the entity cannot be loaded.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's loadUnchanged() method to load an unchanged entity:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->loadUnchanged($id).
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged()
|
||||
*/
|
||||
function entity_load_unchanged($entity_type, $id) {
|
||||
return \Drupal::entityManager()
|
||||
|
@ -195,6 +256,18 @@ function entity_load_unchanged($entity_type, $id) {
|
|||
* The type of the entity.
|
||||
* @param array $ids
|
||||
* An array of entity IDs of the entities to delete.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity storage's delete() method to delete multiple entities:
|
||||
* @code
|
||||
* $storage_handler = \Drupal::entityManager()->getStorage($entity_type);
|
||||
* $entities = $storage_handler->loadMultiple($ids);
|
||||
* $storage_handler->delete($entities);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::loadMultiple()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::delete()
|
||||
*/
|
||||
function entity_delete_multiple($entity_type, array $ids) {
|
||||
$controller = \Drupal::entityManager()->getStorage($entity_type);
|
||||
|
@ -214,10 +287,17 @@ function entity_delete_multiple($entity_type, array $ids) {
|
|||
* @return \Drupal\Core\Entity\EntityInterface
|
||||
* A new entity object.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 9.0.0. Use
|
||||
* the <EntityType>::create($values) method if the entity type is known or
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->create($values) if the
|
||||
* entity type is variable.
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* The method overriding Entity::create() for the entity type, e.g.
|
||||
* \Drupal\node\Entity\Node::create() if the entity type is known. If the
|
||||
* entity type is variable, use the entity storage's create() method to
|
||||
* construct a new entity:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage($entity_type)->create($values)
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
*/
|
||||
function entity_create($entity_type, array $values = array()) {
|
||||
return \Drupal::entityManager()
|
||||
|
@ -228,9 +308,6 @@ function entity_create($entity_type, array $values = array()) {
|
|||
/**
|
||||
* Returns the label of an entity.
|
||||
*
|
||||
* This is a wrapper for Drupal\Core\Entity\EntityInterface::label(). This function
|
||||
* should only be used as a callback, e.g. for menu title callbacks.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity for which to generate the label.
|
||||
* @param $langcode
|
||||
|
@ -238,9 +315,15 @@ function entity_create($entity_type, array $values = array()) {
|
|||
* getting the label. If set to NULL, the entity's default language is
|
||||
* used.
|
||||
*
|
||||
* @return
|
||||
* @return string|null
|
||||
* The label of the entity, or NULL if there is no label defined.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* the entity's label() method to get the label of the entity:
|
||||
* @code
|
||||
* $entity->label($langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityInterface::label()
|
||||
*/
|
||||
function entity_page_label(EntityInterface $entity, $langcode = NULL) {
|
||||
|
@ -263,6 +346,16 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) {
|
|||
*
|
||||
* @return array
|
||||
* A render array for the entity.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* Use the entity view builder's view() method for creating a render array:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->view($entity, $view_mode, $langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::view()
|
||||
*/
|
||||
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
|
@ -289,6 +382,17 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
|
|||
* @return array
|
||||
* A render array for the entities, indexed by the same keys as the
|
||||
* entities array passed in $entities.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* Use the entity view builder's viewMultiple() method for creating a render
|
||||
* array for the provided entities:
|
||||
* @code
|
||||
* $view_builder = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
* return $view_builder->viewMultiple($entities, $view_mode, $langcode);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewBuilder()
|
||||
* @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple()
|
||||
*/
|
||||
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId());
|
||||
|
@ -336,6 +440,26 @@ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $re
|
|||
*
|
||||
* @return \Drupal\Core\Entity\Display\EntityViewDisplayInterface
|
||||
* The entity view display associated to the view mode.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* If the display is available in configuration use:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage('entity_view_display')->load($entity_type . '.' . $bundle . '.' . $view_mode);
|
||||
* @endcode
|
||||
* When the display is not available in configuration, you can create a new
|
||||
* EntityViewDisplay object using:
|
||||
* @code
|
||||
* $values = ('entity_view_display', array(
|
||||
* 'targetEntityType' => $entity_type,
|
||||
* 'bundle' => $bundle,
|
||||
* 'mode' => $view_mode,
|
||||
* 'status' => TRUE,
|
||||
* ));
|
||||
* \Drupal::entityManager()->getStorage('entity_view_display')->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::load()
|
||||
*/
|
||||
function entity_get_display($entity_type, $bundle, $view_mode) {
|
||||
// Try loading the display from configuration.
|
||||
|
@ -392,6 +516,26 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
|
|||
*
|
||||
* @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface
|
||||
* The entity form display associated to the given form mode.
|
||||
*
|
||||
* @deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
|
||||
* If the entity form display is available in configuration use:
|
||||
* @code
|
||||
* \Drupal::entityManager()->getStorage('entity_form_display')->load($entity_type . '.' . $bundle . '.' . $form_mode);
|
||||
* @endcode
|
||||
* When the entity form display is not available in configuration, you can create a new
|
||||
* EntityFormDisplay object using:
|
||||
* @code
|
||||
* $values = ('entity_form_display', array(
|
||||
* 'targetEntityType' => $entity_type,
|
||||
* 'bundle' => $bundle,
|
||||
* 'mode' => $form_mode,
|
||||
* 'status' => TRUE,
|
||||
* ));
|
||||
* \Drupal::entityManager()->getStorage('entity_form_display')->create($values);
|
||||
* @endcode
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
|
||||
* @see \Drupal\Core\Entity\EntityStorageInterface::load()
|
||||
*/
|
||||
function entity_get_form_display($entity_type, $bundle, $form_mode) {
|
||||
// Try loading the entity from configuration.
|
||||
|
|
|
@ -9,6 +9,7 @@ use Drupal\Component\Utility\SafeMarkup;
|
|||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Maps PHP error constants to watchdog severity levels.
|
||||
|
@ -117,21 +118,6 @@ function error_displayable($error = NULL) {
|
|||
*/
|
||||
function _drupal_log_error($error, $fatal = FALSE) {
|
||||
$is_installer = drupal_installation_attempted();
|
||||
// Initialize a maintenance theme if the bootstrap was not complete.
|
||||
// Do it early because drupal_set_message() triggers a
|
||||
// \Drupal\Core\Theme\ThemeManager::initTheme().
|
||||
if ($fatal && \Drupal::hasService('theme.manager')) {
|
||||
// The installer initializes a maintenance theme at the earliest possible
|
||||
// point in time already. Do not unset that.
|
||||
if (!$is_installer) {
|
||||
\Drupal::theme()->resetActiveTheme();
|
||||
}
|
||||
if (!defined('MAINTENANCE_MODE')) {
|
||||
define('MAINTENANCE_MODE', 'error');
|
||||
}
|
||||
// No-op if the active theme is set already.
|
||||
drupal_maintenance_theme();
|
||||
}
|
||||
|
||||
// Backtrace array is not a valid replacement value for t().
|
||||
$backtrace = $error['backtrace'];
|
||||
|
@ -152,22 +138,37 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
'line' => $error['%line'],
|
||||
),
|
||||
);
|
||||
// For non-fatal errors (e.g. PHP notices) _drupal_log_error can be called
|
||||
// multiple times per request. In that case the response is typically
|
||||
// generated outside of the error handler, e.g., in a controller. As a
|
||||
// result it is not possible to use a Response object here but instead the
|
||||
// headers need to be emitted directly.
|
||||
header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
|
||||
$number++;
|
||||
}
|
||||
|
||||
$response = new Response();
|
||||
|
||||
// Only call the logger if there is a logger factory available. This can occur
|
||||
// if there is an error while rebuilding the container or during the
|
||||
// installer.
|
||||
if (\Drupal::hasService('logger.factory')) {
|
||||
\Drupal::logger('php')->log($error['severity_level'], '%type: !message in %function (line %line of %file).', $error);
|
||||
try {
|
||||
\Drupal::logger('php')->log($error['severity_level'], '%type: !message in %function (line %line of %file).', $error);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// We can't log, for example because the database connection is not
|
||||
// available. At least try to log to PHP error log.
|
||||
error_log(sprintf('Failed to log error: %type: !message in %function (line %line of %file).', $error['%type'], $error['%function'], $error['%line'], $error['%file']));
|
||||
}
|
||||
}
|
||||
|
||||
if (PHP_SAPI === 'cli') {
|
||||
if ($fatal) {
|
||||
// When called from CLI, simply output a plain text message.
|
||||
// Should not translate the string to avoid errors producing more errors.
|
||||
print html_entity_decode(strip_tags(format_string('%type: !message in %function (line %line of %file).', $error))). "\n";
|
||||
$response->setContent(html_entity_decode(strip_tags(format_string('%type: !message in %function (line %line of %file).', $error))). "\n");
|
||||
$response->send();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +178,8 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
if (error_displayable($error)) {
|
||||
// When called from JavaScript, simply output the error message.
|
||||
// Should not translate the string to avoid errors producing more errors.
|
||||
print format_string('%type: !message in %function (line %line of %file).', $error);
|
||||
$response->setContent(format_string('%type: !message in %function (line %line of %file).', $error));
|
||||
$response->send();
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
@ -185,6 +187,8 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
else {
|
||||
// Display the message if the current error reporting level allows this type
|
||||
// of message to be displayed, and unconditionally in update.php.
|
||||
$message = '';
|
||||
$class = NULL;
|
||||
if (error_displayable($error)) {
|
||||
$class = 'error';
|
||||
|
||||
|
@ -219,6 +223,32 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
// Generate a backtrace containing only scalar argument values.
|
||||
$message .= '<pre class="backtrace">' . Error::formatBacktrace($backtrace) . '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($fatal) {
|
||||
// We fallback to a maintenance page at this point, because the page generation
|
||||
// itself can generate errors.
|
||||
// Should not translate the string to avoid errors producing more errors.
|
||||
$message = 'The website encountered an unexpected error. Please try again later.' . '<br />' . $message;
|
||||
|
||||
if ($is_installer) {
|
||||
// install_display_output() prints the output and ends script execution.
|
||||
$output = array(
|
||||
'#title' => 'Error',
|
||||
'#markup' => $message,
|
||||
);
|
||||
install_display_output($output, $GLOBALS['install_state'], $response->headers->all());
|
||||
exit;
|
||||
}
|
||||
|
||||
$response->setContent($message);
|
||||
$response->setStatusCode(500, '500 Service unavailable (with message)');
|
||||
|
||||
$response->send();
|
||||
// An exception must halt script execution.
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
if (\Drupal::hasService('session')) {
|
||||
// Message display is dependent on sessions being available.
|
||||
drupal_set_message(SafeMarkup::set($message), $class, TRUE);
|
||||
|
@ -227,29 +257,6 @@ function _drupal_log_error($error, $fatal = FALSE) {
|
|||
print $message;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fatal) {
|
||||
// We fallback to a maintenance page at this point, because the page generation
|
||||
// itself can generate errors.
|
||||
// Should not translate the string to avoid errors producing more errors.
|
||||
$message = 'The website encountered an unexpected error. Please try again later.';
|
||||
if ($is_installer) {
|
||||
// install_display_output() prints the output and ends script execution.
|
||||
$output = array(
|
||||
'#title' => 'Error',
|
||||
'#markup' => $message,
|
||||
);
|
||||
install_display_output($output, $GLOBALS['install_state']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
|
||||
$response = $bare_html_page_renderer->renderBarePage(['#markup' => $message], 'Error', 'maintenance_page');
|
||||
$response->setStatusCode(500, '500 Service unavailable (with message)');
|
||||
// An exception must halt script execution.
|
||||
$response->send();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,9 +284,16 @@ function _drupal_get_error_level() {
|
|||
return ERROR_REPORTING_DISPLAY_VERBOSE;
|
||||
}
|
||||
$error_level = NULL;
|
||||
if (\Drupal::hasService('config.factory')) {
|
||||
// Try to get the error level configuration from database. If this fails,
|
||||
// for example if the database connection is not there, try to read it from
|
||||
// settings.php.
|
||||
try {
|
||||
$error_level = \Drupal::config('system.logging')->get('error_level');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$error_level = isset($GLOBALS['config']['system.logging']['error_level']) ? $GLOBALS['config']['system.logging']['error_level'] : ERROR_REPORTING_HIDE;
|
||||
}
|
||||
|
||||
// If there is no container or if it has no config.factory service, we are
|
||||
// possibly in an edge-case error situation while trying to serve a regular
|
||||
// request on a public site, so use the non-verbose default value.
|
||||
|
|
|
@ -89,49 +89,6 @@ const FILE_EXISTS_ERROR = 2;
|
|||
*/
|
||||
const FILE_STATUS_PERMANENT = 1;
|
||||
|
||||
/**
|
||||
* Provides Drupal stream wrapper registry.
|
||||
*
|
||||
* @param int $filter
|
||||
* (Optional) Filters out all types except those with an on bit for each on
|
||||
* bit in $filter. For example, if $filter is
|
||||
* StreamWrapperInterface::WRITE_VISIBLE, which is equal to
|
||||
* (StreamWrapperInterface::READ | StreamWrapperInterface::WRITE |
|
||||
* StreamWrapperInterface::VISIBLE), then only stream wrappers with all three
|
||||
* of these bits set are returned. Defaults to StreamWrapperInterface::ALL,
|
||||
* which returns all registered stream wrappers.
|
||||
*
|
||||
* @return array
|
||||
* An array keyed by scheme, with values containing an array of information
|
||||
* about the stream wrapper, as returned by hook_stream_wrappers(). If $filter
|
||||
* is omitted or set to StreamWrapperInterface::ALL, the entire Drupal stream
|
||||
* wrapper registry is returned. Otherwise only the stream wrappers whose
|
||||
* 'type' bitmask has an on bit for each bit specified in $filter are
|
||||
* returned.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
|
||||
* Use \Drupal::service('stream_wrapper_manager')->getWrappers().
|
||||
*/
|
||||
function file_get_stream_wrappers($filter = StreamWrapperInterface::ALL) {
|
||||
return \Drupal::service('stream_wrapper_manager')->getWrappers($filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stream wrapper class name for a given scheme.
|
||||
*
|
||||
* @param string $scheme
|
||||
* Stream scheme.
|
||||
*
|
||||
* @return string|bool
|
||||
* Return string if a scheme has a registered handler, or FALSE.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
|
||||
* Use \Drupal::service('stream_wrapper_manager')->getClass().
|
||||
*/
|
||||
function file_stream_wrapper_get_class($scheme) {
|
||||
return \Drupal::service('stream_wrapper_manager')->getClass($scheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scheme of a URI (e.g. a stream).
|
||||
*
|
||||
|
@ -214,55 +171,6 @@ function file_stream_wrapper_uri_normalize($uri) {
|
|||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the stream wrapper class responsible for a given URI.
|
||||
*
|
||||
* The scheme determines the stream wrapper class that should be
|
||||
* used by consulting the stream wrapper registry.
|
||||
*
|
||||
* @param string $uri
|
||||
* A stream, referenced as "scheme://target".
|
||||
*
|
||||
* @return \Drupal\Core\StreamWrapper\StreamWrapperInterface|bool
|
||||
* Returns a new stream wrapper object appropriate for the given URI or FALSE
|
||||
* if no registered handler could be found. For example, a URI of
|
||||
* "private://example.txt" would return a new private stream wrapper object
|
||||
* (Drupal\Core\StreamWrapper\PrivateStream).
|
||||
*
|
||||
* * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
|
||||
* Use \Drupal::service('stream_wrapper_manager')->getViaUri().
|
||||
*/
|
||||
function file_stream_wrapper_get_instance_by_uri($uri) {
|
||||
return \Drupal::service('stream_wrapper_manager')->getViaUri($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the stream wrapper class responsible for a scheme.
|
||||
*
|
||||
* This helper method returns a stream instance using a scheme. That is, the
|
||||
* passed string does not contain a "://". For example, "public" is a scheme
|
||||
* but "public://" is a URI (stream). This is because the later contains both
|
||||
* a scheme and target despite target being empty.
|
||||
*
|
||||
* Note: the instance URI will be initialized to "scheme://" so that you can
|
||||
* make the customary method calls as if you had retrieved an instance by URI.
|
||||
*
|
||||
* @param string $scheme
|
||||
* If the stream was "public://target", "public" would be the scheme.
|
||||
*
|
||||
* @return \Drupal\Core\StreamWrapper\StreamWrapperInterface|bool
|
||||
* Returns a new stream wrapper object appropriate for the given $scheme.
|
||||
* For example, for the public scheme a stream wrapper object
|
||||
* (Drupal\Core\StreamWrapper\PublicStream).
|
||||
* FALSE is returned if no registered handler could be found.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
|
||||
* Use \Drupal::service('stream_wrapper_manager')->getViaScheme().
|
||||
*/
|
||||
function file_stream_wrapper_get_instance_by_scheme($scheme) {
|
||||
return \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a web-accessible URL for a stream to an external or local file.
|
||||
*
|
||||
|
@ -331,7 +239,7 @@ function file_create_url($uri) {
|
|||
}
|
||||
else {
|
||||
// Attempt to return an external URL using the appropriate wrapper.
|
||||
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
|
||||
if ($wrapper = \Drupal::service('stream_wrapper_manager')->getViaUri($uri)) {
|
||||
return $wrapper->getExternalUrl();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -43,7 +43,7 @@ function template_preprocess_select(&$variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts an array of options into HTML, for use in select list form elements.
|
||||
* Converts an options form element into a structured array for output.
|
||||
*
|
||||
* This function calls itself recursively to obtain the values for each optgroup
|
||||
* within the list of options and when the function encounters an object with
|
||||
|
@ -78,13 +78,22 @@ function template_preprocess_select(&$variables) {
|
|||
* $element['#options'] above, or NULL. This parameter is only used internally
|
||||
* and is not intended to be passed in to the initial function call.
|
||||
*
|
||||
* @return string
|
||||
* An HTML string of options and optgroups for use in a select form element.
|
||||
* @return mixed[]
|
||||
* A structured, possibly nested, array of options and optgroups for use in a
|
||||
* select form element.
|
||||
* - label: A translated string whose value is the text of a single HTML
|
||||
* option element, or the label attribute for an optgroup.
|
||||
* - options: Optional, array of options for an optgroup.
|
||||
* - selected: A boolean that indicates whether the option is selected when
|
||||
* rendered.
|
||||
* - type: A string that defines the element type. The value can be 'option'
|
||||
* or 'optgroup'.
|
||||
* - value: A string that contains the value attribute for the option.
|
||||
*/
|
||||
function form_select_options($element, $choices = NULL) {
|
||||
if (!isset($choices)) {
|
||||
if (empty($element['#options'])) {
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
$choices = $element['#options'];
|
||||
}
|
||||
|
@ -94,29 +103,35 @@ function form_select_options($element, $choices = NULL) {
|
|||
$value_is_array = $value_valid && is_array($element['#value']);
|
||||
// Check if the element is multiple select and no value has been selected.
|
||||
$empty_value = (empty($element['#value']) && !empty($element['#multiple']));
|
||||
$options = '';
|
||||
$options = [];
|
||||
foreach ($choices as $key => $choice) {
|
||||
if (is_array($choice)) {
|
||||
$options .= '<optgroup label="' . SafeMarkup::checkPlain($key) . '">';
|
||||
$options .= form_select_options($element, $choice);
|
||||
$options .= '</optgroup>';
|
||||
$options[] = [
|
||||
'type' => 'optgroup',
|
||||
'label' => $key,
|
||||
'options' => form_select_options($element, $choice),
|
||||
];
|
||||
}
|
||||
elseif (is_object($choice) && isset($choice->option)) {
|
||||
$options .= form_select_options($element, $choice->option);
|
||||
$options = array_merge($options, form_select_options($element, $choice->option));
|
||||
}
|
||||
else {
|
||||
$option = [];
|
||||
$key = (string) $key;
|
||||
$empty_choice = $empty_value && $key == '_none';
|
||||
if ($value_valid && ((!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value']))) || $empty_choice)) {
|
||||
$selected = ' selected="selected"';
|
||||
$option['selected'] = TRUE;
|
||||
}
|
||||
else {
|
||||
$selected = '';
|
||||
$option['selected'] = FALSE;
|
||||
}
|
||||
$options .= '<option value="' . SafeMarkup::checkPlain($key) . '"' . $selected . '>' . SafeMarkup::checkPlain($choice) . '</option>';
|
||||
$option['type'] = 'option';
|
||||
$option['value'] = $key;
|
||||
$option['label'] = $choice;
|
||||
$options[] = $option;
|
||||
}
|
||||
}
|
||||
return SafeMarkup::set($options);
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -810,7 +825,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
|
|||
$query_options['op'] = 'finished';
|
||||
$error_url->setOption('query', $query_options);
|
||||
|
||||
$batch['error_message'] = t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => $error_url->toString()));
|
||||
$batch['error_message'] = t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => $error_url->toString(TRUE)->getGeneratedUrl()));
|
||||
|
||||
// Clear the way for the redirection to the batch processing page, by
|
||||
// saving and unsetting the 'destination', if there is any.
|
||||
|
@ -840,7 +855,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
|
|||
$function($batch_url->toString(), ['query' => $query_options]);
|
||||
}
|
||||
else {
|
||||
return new RedirectResponse($batch_url->setAbsolute()->toString());
|
||||
return new RedirectResponse($batch_url->setAbsolute()->toString(TRUE)->getGeneratedUrl());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1350,7 +1350,7 @@ function install_download_translation(&$install_state) {
|
|||
* original name. If the path contains a filename as well, that one will be
|
||||
* used instead.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
* TRUE on success, FALSE on failure.
|
||||
*/
|
||||
function install_retrieve_file($uri, $destination) {
|
||||
|
@ -1364,8 +1364,8 @@ function install_retrieve_file($uri, $destination) {
|
|||
}
|
||||
|
||||
try {
|
||||
$request = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain')));
|
||||
$data = $request->getBody(TRUE);
|
||||
$response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain')));
|
||||
$data = (string) $response->getBody();
|
||||
if (empty($data)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1656,6 +1656,12 @@ function install_profile_themes(&$install_state) {
|
|||
* An array of information about the current installation state.
|
||||
*/
|
||||
function install_install_profile(&$install_state) {
|
||||
// Now that all modules are installed, make sure the entity storage and other
|
||||
// handlers are up to date with the current entity and field definitions. For
|
||||
// example, Path module adds a base field to nodes and taxonomy terms after
|
||||
// those modules are already installed.
|
||||
\Drupal::service('entity.definition_update_manager')->applyUpdates();
|
||||
|
||||
\Drupal::service('module_installer')->install(array(drupal_get_profile()), FALSE);
|
||||
// Install all available optional config. During installation the module order
|
||||
// is determined by dependencies. If there are no dependencies between modules
|
||||
|
|
|
@ -40,10 +40,6 @@ function template_preprocess_menu_local_task(&$variables) {
|
|||
$active = SafeMarkup::format('<span class="visually-hidden">@label</span>', array('@label' => t('(active tab)')));
|
||||
$link_text = t('@local-task-title@active', array('@local-task-title' => $link_text, '@active' => $active));
|
||||
}
|
||||
else {
|
||||
// @todo Remove this once https://www.drupal.org/node/2338081 is fixed.
|
||||
$link_text = SafeMarkup::checkPlain($link_text);
|
||||
}
|
||||
|
||||
$link['localized_options']['set_active_class'] = TRUE;
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ function template_preprocess_pager(&$variables) {
|
|||
$element = $variables['pager']['#element'];
|
||||
$parameters = $variables['pager']['#parameters'];
|
||||
$quantity = $variables['pager']['#quantity'];
|
||||
$route_name = $variables['pager']['#route_name'];
|
||||
global $pager_page_array, $pager_total;
|
||||
|
||||
// Nothing to do if there is only one page.
|
||||
|
@ -218,7 +219,7 @@ function template_preprocess_pager(&$variables) {
|
|||
$options = array(
|
||||
'query' => pager_query_add_page($parameters, $element, 0),
|
||||
);
|
||||
$items['first']['href'] = \Drupal::url('<current>', [], $options);
|
||||
$items['first']['href'] = \Drupal::url($route_name, [], $options);
|
||||
if (isset($tags[0])) {
|
||||
$items['first']['text'] = $tags[0];
|
||||
}
|
||||
|
@ -227,7 +228,7 @@ function template_preprocess_pager(&$variables) {
|
|||
$options = array(
|
||||
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
|
||||
);
|
||||
$items['previous']['href'] = \Drupal::url('<current>', [], $options);
|
||||
$items['previous']['href'] = \Drupal::url($route_name, [], $options);
|
||||
if (isset($tags[1])) {
|
||||
$items['previous']['text'] = $tags[1];
|
||||
}
|
||||
|
@ -243,7 +244,7 @@ function template_preprocess_pager(&$variables) {
|
|||
$options = array(
|
||||
'query' => pager_query_add_page($parameters, $element, $i - 1),
|
||||
);
|
||||
$items['pages'][$i]['href'] = \Drupal::url('<current>', [], $options);
|
||||
$items['pages'][$i]['href'] = \Drupal::url($route_name, [], $options);
|
||||
if ($i == $pager_current) {
|
||||
$variables['current'] = $i;
|
||||
}
|
||||
|
@ -260,7 +261,7 @@ function template_preprocess_pager(&$variables) {
|
|||
$options = array(
|
||||
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
|
||||
);
|
||||
$items['next']['href'] = \Drupal::url('<current>', [], $options);
|
||||
$items['next']['href'] = \Drupal::url($route_name, [], $options);
|
||||
if (isset($tags[3])) {
|
||||
$items['next']['text'] = $tags[3];
|
||||
}
|
||||
|
@ -269,13 +270,18 @@ function template_preprocess_pager(&$variables) {
|
|||
$options = array(
|
||||
'query' => pager_query_add_page($parameters, $element, $pager_max - 1),
|
||||
);
|
||||
$items['last']['href'] = \Drupal::url('<current>', [], $options);
|
||||
$items['last']['href'] = \Drupal::url($route_name, [], $options);
|
||||
if (isset($tags[4])) {
|
||||
$items['last']['text'] = $tags[4];
|
||||
}
|
||||
}
|
||||
|
||||
$variables['items'] = $items;
|
||||
|
||||
// The rendered link needs to play well with any other query parameter
|
||||
// used on the page, like exposed filters, so for the cacheability all query
|
||||
// parameters matter.
|
||||
$variables['#cache']['contexts'][] = 'url.query_args';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1066,30 +1066,6 @@ function template_preprocess_item_list(&$variables) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for feed icon templates.
|
||||
*
|
||||
* Default template: feed-icon.html.twig.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - url: An internal system path or a fully qualified external URL of the
|
||||
* feed.
|
||||
* - title: A descriptive title of the feed.
|
||||
*/
|
||||
function template_preprocess_feed_icon(&$variables) {
|
||||
$text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
|
||||
$variables['icon'] = array(
|
||||
'#theme' => 'image__feed_icon',
|
||||
'#uri' => 'core/misc/feed.png',
|
||||
'#width' => 16,
|
||||
'#height' => 16,
|
||||
'#alt' => $text,
|
||||
);
|
||||
// Stripping tags because that's what l() used to do.
|
||||
$variables['attributes']['title'] = strip_tags($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for an indentation div; used for drag and drop tables.
|
||||
*
|
||||
|
@ -1350,7 +1326,7 @@ function template_preprocess_page(&$variables) {
|
|||
$variables['language'] = $language_interface;
|
||||
$variables['logo'] = theme_get_setting('logo.url');
|
||||
$variables['site_name'] = (theme_get_setting('features.name') ? SafeMarkup::checkPlain($site_config->get('name')) : '');
|
||||
$variables['site_slogan'] = (theme_get_setting('features.slogan') ? Xss::filterAdmin($site_config->get('slogan')) : '');
|
||||
$variables['site_slogan']['#markup'] = (theme_get_setting('features.slogan') ? $site_config->get('slogan') : '');
|
||||
|
||||
// An exception might be thrown.
|
||||
try {
|
||||
|
@ -1462,7 +1438,6 @@ function template_preprocess_maintenance_page(&$variables) {
|
|||
template_preprocess_page($variables);
|
||||
|
||||
// @see system_page_attachments()
|
||||
$variables['#attached']['library'][] = 'core/normalize';
|
||||
$variables['#attached']['library'][] = 'system/maintenance';
|
||||
}
|
||||
|
||||
|
|
|
@ -224,14 +224,10 @@ function update_do_one($module, $number, $dependency_map, &$context) {
|
|||
/**
|
||||
* Performs entity definition updates, which can trigger schema updates.
|
||||
*
|
||||
* @param $module
|
||||
* The module whose update will be run.
|
||||
* @param $number
|
||||
* The update number to run.
|
||||
* @param $context
|
||||
* The batch context array.
|
||||
*/
|
||||
function update_entity_definitions($module, $number, &$context) {
|
||||
function update_entity_definitions(&$context) {
|
||||
try {
|
||||
\Drupal::service('entity.definition_update_manager')->applyUpdates();
|
||||
}
|
||||
|
@ -243,7 +239,7 @@ function update_entity_definitions($module, $number, &$context) {
|
|||
// \Drupal\Component\Utility\SafeMarkup::checkPlain() by
|
||||
// \Drupal\Core\Utility\Error::decodeException().
|
||||
$ret['#abort'] = array('success' => FALSE, 'query' => t('%type: !message in %function (line %line of %file).', $variables));
|
||||
$context['results'][$module][$number] = $ret;
|
||||
$context['results']['core']['update_entity_definitions'] = $ret;
|
||||
$context['results']['#abort'][] = 'update_entity_definitions';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,17 @@ function drupal_rebuild(ClassLoader $class_loader, Request $request) {
|
|||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
|
||||
// Force kernel to rebuild container.
|
||||
PhpStorageFactory::get('service_container')->deleteAll();
|
||||
// Force kernel to rebuild php cache.
|
||||
PhpStorageFactory::get('twig')->deleteAll();
|
||||
|
||||
// Bootstrap up to where caches exist and clear them.
|
||||
$kernel = new DrupalKernel('prod', $class_loader);
|
||||
$kernel->setSitePath(DrupalKernel::findSitePath($request));
|
||||
|
||||
// Invalidate the container.
|
||||
$kernel->invalidateContainer();
|
||||
|
||||
// Prepare a NULL request.
|
||||
$kernel->prepareLegacyRequest($request);
|
||||
|
||||
foreach (Cache::getBins() as $bin) {
|
||||
|
|
Reference in a new issue