BLOCK_CUSTOM_DISABLED
BLOCK_CUSTOM_DISABLED = 2
_cache_get_object(mixed $bin) : mixed
The Drupal 11 backend for a Drupal 7 bin name.
Drupal 7 named bins after their table (cache_bootstrap, cache_features) and Drupal 11 names
the service without the prefix, adding it for the table. A bin with no service, such as one a
contrib module declared in its schema, gets a database backend over the same table.
| mixed | $bin |
_entity_load(string $entity_type, array|int|string|false $ids, array|bool $conditions, bool $reset) : array|\Drupal\Core\Entity\EntityInterface|null
| string | $entity_type | |
| array|int|string|false | $ids | |
| array|bool | $conditions | |
| bool | $reset |
anachron_field_storage_for(string $entity_type, string $field_name) : void
Copies a field's storage to another entity type.
A Drupal 7 field belongs to no entity type and any instance may use it. A Drupal 11 storage is
per entity type, and field_create_field() makes it for node. When the instance names another
type, its storage is the node one made again for that type.
| string | $entity_type | |
| string | $field_name |
anachron_request_time() : int
Answers the time of the current request, for the delivery rewrite of REQUEST_TIME.
A constant freezes at the first request in a process that serves many. With no container, as while a module file is being included, the server value or the clock answers instead.
arg(int|null $index = null, string|null $path = null) : string|array|null
Returns a component of the current path, as Drupal 7's arg() did.
Reads the path from the path.current service instead of Drupal 7's $_GET['q'].
| int|null | $index | The component to return, or null for all components. |
| string|null | $path | The path to split, or null for the current path. |
The component, the full array when no index is given, or null when it is missing.
debug(mixed $data, string|null $label = null, bool $print_r = true) : mixed
Prints a value as an escaped, preformatted notice, as Drupal 7's debug() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). $print_r defaults to true here, where Drupal 7 defaulted to false.
| mixed | $data | The value to print. |
| string|null | $label | An optional label. |
| bool | $print_r | True for print_r() output, false for var_export(). |
drupal_get_installed_schema_version(string $module, bool $reset = false, bool $array = false) : int|array
Returns the installed schema version of a module, as Drupal 7's did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). It reads the update.update_hook_registry service, so the Drupal 7 $reset flag has no effect.
| string | $module | The module machine name. |
| bool | $reset | Ignored. |
| bool | $array | True to return the versions of all modules keyed by name. |
The schema version, or all versions when $array is set.
drupal_get_module_schema(string $module, string|null $table = null) : array
Returns a module's hook_schema() definition, as Drupal 9's did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). Drupal 7 had no function of this name.
| string | $module | The module machine name. |
| string|null | $table | A table name, or null for the whole schema. |
The table definition or the full schema, empty when none exists.
drupal_get_query_parameters(array|null $query = null, array $exclude = ['q'], string $parent = '') : array
Returns the query parameters minus the excluded keys, as Drupal 7's did.
The default source is the current Symfony request instead of Drupal 7's $_GET.
| array|null | $query | The parameters to filter, or null for the current request's query. |
| array | $exclude | The keys to drop. Nested keys use the "a[b]" form. |
| string | $parent | The parent key for nested values. Internal use. |
The filtered parameters.
drupal_get_schema_unprocessed(string $module, ?string $table = null) : array<string,mixed>
Returns a module's hook_schema() definition without the processing Drupal 7 added.
The cache table of system, which Drupal 7 modules copy for their own cache bins, now comes from
the database cache backend, because Drupal 11's system_schema() no longer holds it.
| string | $module | |
| ?string | $table |
drupal_http_build_query(array $query, string $parent = '') : string
Builds a URL-encoded query string from an array, as Drupal 7's did.
Keys without a value are emitted bare, and slashes in values stay unencoded.
| array | $query | The query parameters, which may be nested. |
| string | $parent | The encoded parent key for nested values. Internal use. |
The query string, without a leading question mark.
drupal_set_message(null|string|\Stringable $message = null, string $type = 'status', bool $repeat = true) : string[][]|\Drupal\Component\Render\MarkupInterface[][]
| null|string|\Stringable | $message | |
| string | $type | |
| bool | $repeat |
drupal_strlen(mixed $text) : int
Returns the number of characters in a string, as Drupal 7's drupal_strlen() did.
Always uses mb_strlen(). Drupal 7's byte-counting fallback for sites without mbstring is gone.
| mixed | $text | The string to measure. Null counts as zero characters. |
The length of the string in characters.
drupal_substr(mixed $text, int $start, int|null $length = null) : string
Cuts a piece out of a string by character index, as Drupal 7's drupal_substr() did.
| mixed | $text | The input string. |
| int | $start | The character position at which to start reading. |
| int|null | $length | The number of characters to read, or null to read to the end. |
The shortened string.
drupal_valid_token(string $token, string $value = '', bool $skip_anonymous = false) : bool
Validates a CSRF token, as Drupal 7's drupal_valid_token() did.
| string | $token | The token to validate. |
| string | $value | The additional value the token was based on. |
| bool | $skip_anonymous | Whether to accept any token for anonymous users. |
True for a valid token, or always true for anonymous users when $skip_anonymous is set.
entity_label(string $entity_type, mixed $entity) : string|false
Returns the label of an entity, as Drupal 7's entity_label() did.
| string | $entity_type | The entity type ID. Unused; the entity supplies its own label. |
| mixed | $entity | The entity. |
The label, or false when the value is not an entity or has no label.
field_info_fields() : array<string,array<string,mixed>>
Lists every field the way Drupal 7 did, as arrays keyed by field name.
A name used on several entity types lists the bundles of each under its entity type. The keys
are the ones a Drupal 7 module reads: id, field_name, deleted (always false), type, module, settings, cardinality,
translatable, locked, indexes, columns and bundles. A call made from inside this
function's own load answers an empty list, for the reason field_info_instances() gives.
field_info_instances(?string $entity_type = null, ?string $bundle_name = null) : array
Lists field instances the way Drupal 7 grouped them, each one an array-like `LegacyFieldInstance`.
Drupal 11 calls hook_entity_load for config entities too, and a Drupal 7 implementation often
reads the instances from there, which loads the instances again without end. A call made from
inside this function's own load answers an empty list.
| ?string | $entity_type | |
| ?string | $bundle_name |
Keyed by entity type, bundle and field name, with the levels you named left out.
field_read_instances(array$params = [], array $include_additional = []) : list<\Drupflare\Anachron\Drupal\Field\LegacyFieldInstance>
Reads field instances matching Drupal 7 conditions, as a flat list.
Only entity_type, bundle, field_name and deleted are conditions here. Drupal 11 keeps no
deleted instances to read, so deleted true answers an empty list. Another key is refused and
recorded, and the read answers an empty list rather than every instance.
| array |
$params | |
| array | $include_additional |
file_create_url(mixed $uri) : string|false
Returns an absolute URL for a file URI, as Drupal 7's file_create_url() did.
Uses the file_url_generator service, so Drupal 7's hook_file_url_alter() is not called.
| mixed | $uri | The URI or path of the file. |
The absolute URL, or false when the stream wrapper is invalid.
file_icon_class(string $mime_type) : string
Returns the icon class for a MIME type, as Drupal 10's file_icon_class() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). Drupal 7 had no function of this name.
| string | $mime_type | The MIME type. |
The icon class.
file_munge_filename(string $filename, string $extensions, bool $alerts = true) : string
Renames a file so a double extension cannot run as code, as Drupal 7's did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). The allow_insecure_uploads setting comes from system.file config, where Drupal 7 used a variable.
| string | $filename | The file name. |
| string | $extensions | The space-separated list of allowed extensions. |
| bool | $alerts | Whether to show a status message when the name changes. |
The munged file name.
file_save_data(string $data, string|null $destination = null, int|\Drupal\Core\File\FileExists $replace = \Drupal\Core\File\FileSystemInterface::EXISTS_RENAME) : \Drupal\file\FileInterface|false
Saves a string to a new file entity, as Drupal 7's file_save_data() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). It calls the file.repository service and maps the old integer replace flags to FileExists. It returns false on a file or stream wrapper error.
| string | $data | The contents to write. |
| string|null | $destination | The destination URI, or null for the default scheme root. |
| int|\Drupal\Core\File\FileExists | $replace | The behavior when the file exists: 0 renames, 2 errors, anything else replaces. |
The file entity, or false on failure.
format_date(int|string $timestamp, string $type = 'medium', string $format = '', string|null $timezone = null, string|null $langcode = null) : string
Formats a timestamp with the date formatter service, as Drupal 7's format_date() did.
| int|string | $timestamp | The Unix timestamp. |
| string | $type | The date format type, such as "short", "medium", "long" or "custom". |
| string | $format | The PHP date format, used when the type is "custom". |
| string|null | $timezone | The timezone name, or null for the user's timezone. |
| string|null | $langcode | The language code, or null for the current language. |
The formatted date.
format_interval(int $interval, int $granularity = 2, string|null $langcode = null) : string
Formats a time interval with the requested granularity, as Drupal 7's did.
| int | $interval | The length of the interval in seconds. |
| int | $granularity | The maximum number of units to show. |
| string|null | $langcode | The language code for the units, or null for the current language. |
The interval, such as "1 week 2 days", or "0 sec" for an empty interval.
format_plural(int|float|string $count, string $singular, string $plural, array $args = [], array $options = []) : string
Formats a string containing a count, as Drupal 7's format_plural() did.
Delegates to the translation service's formatPlural().
| int|float|string | $count | The item count. |
| string | $singular | The text for a count of 1. |
| string | $plural | The text for any other count, with "@count" as the placeholder. |
| array | $args | Placeholder replacements. |
| array | $options | Translation options, such as "langcode". |
The translated string.
format_size(int|float $size, string|null $langcode = null) : string
Formats a byte count as a human-readable string, as Drupal 7's format_size() did.
| int|float | $size | The size in bytes. |
| string|null | $langcode | The language code for the units, or null for the current language. |
The size with its unit, such as "1.5 MB".
module_load_include(string $type, string $module, string|null $name = null) : string|false
Includes a file from a module's directory, as Drupal 7's module_load_include() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). Drupal 7 cached each result. This version looks the module path up in the extension.list.module service.
| string | $type | The file extension without the dot, such as "inc". |
| string | $module | The module machine name. |
| string|null | $name | The file base name, or null to use the module name. |
The included file path, or false when the file does not exist.
node_access(string $op, \Drupal\node\NodeInterface|string|null $node, \Drupal\Core\Session\AccountInterface|object|null $account = null) : bool
Checks node access for an operation, as Drupal 7's node_access() did.
Fails closed: a missing node, an unsupported operation, an unresolvable account or a node type string with any operation other than "create" returns false. Access is decided by the node entity access handler, not by Drupal 7's hook_node_access() and node_access table.
| string | $op | The operation: "view", "update", "delete" or "create". |
| \Drupal\node\NodeInterface|string|null | $node | The node, or a node type ID for "create". |
| \Drupal\Core\Session\AccountInterface|object|null | $account | The account to check, or null for the current user. |
True when access is granted.
node_type_set_defaults(array{type?: string, name?: string, base?: string, description?: string, help?: string, custom?: int, modified?: int, locked?: int, disabled?: int, is_new?: int, has_title?: int, title_label?: string} $info = []) : \Drupal\node\NodeTypeInterface
| array{type?: string, name?: string, base?: string, description?: string, help?: string, custom?: int, modified?: int, locked?: int, disabled?: int, is_new?: int, has_title?: int, title_label?: string} | $info |
node_types_rebuild() : void
Creates the node types that enabled modules declare in `hook_node_info()`.
Drupal 7 kept the declared types in a table and added the missing ones here. Drupal 11 has no
such hook, so a type is created as a config entity when none of that name exists. Keys with no
counterpart (has_title, title_label, has_body, locked) are recorded and not applied.
system_rebuild_module_data() : array<string,\stdClass>
Lists every discovered module as Drupal 7 did, keyed by name.
Each value is an object with name, type, filename, status, info, requires and
required_by. The info array is Drupal 11's with dependencies as plain module names.
Keys Drupal 11 has no source for (schema_version, weight, bootstrap) are not set.
taxonomy_term_load(int|string $tid) : \Drupal\taxonomy\TermInterface|false
Loads a taxonomy term by ID, as Drupal 7's taxonomy_term_load() did.
| int|string | $tid | The term ID. |
The term, or false when the ID is not numeric or no term exists.
user_load(int|string $uid, bool $reset = false) : \Drupal\user\UserInterface|false
Loads a user entity by ID, as Drupal 7's user_load() did.
| int|string | $uid | The user ID. |
| bool | $reset | Whether to reset the entity cache first. |
The user entity, or false when none exists.
user_password(int $length = 10) : string
Generates a random password, as Drupal 7's user_password() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). The password comes from the password_generator service.
| int | $length | The password length. |
The generated password.
user_role_names(bool $members_only = false, string|null $permission = null) : array
Returns role labels keyed by role ID, as Drupal 10's user_role_names() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). Drupal 7 had no function of this name; its user_roles() covered the same job.
| bool | $members_only | Whether to leave out the anonymous role. |
| string|null | $permission | When set, only roles holding this permission are returned. |
Role labels keyed by role ID.
user_roles(bool $membersonly = false, string|null $permission = null) : string[]
Returns role labels keyed by role ID, as Drupal 7's user_roles() did.
Roles are sorted by weight, then label. Role IDs are machine names, where Drupal 7 used numeric role IDs.
| bool | $membersonly | Whether to leave out the anonymous role. |
| string|null | $permission | When set, only roles holding this permission are returned. |
Role labels keyed by role ID.
watchdog_exception(string $type, \Exception $exception, string|null $message = null, array $variables = [], int $severity = \Drupal\Core\Logger\RfcLogLevel::ERROR, string|null $link = null) : mixed
Logs an exception through the logger service, as Drupal 7's watchdog_exception() did.
Replaces a function absent from Drupal 11.4.11 core (original cited above). Severity defaults to RfcLogLevel::ERROR where Drupal 7 used WATCHDOG_ERROR.
| string | $type | The logger channel. |
| \Exception | $exception | The exception to log. |
| string|null | $message | The message, or null for the default exception message. |
| array | $variables | Placeholder replacements. Exception details are merged in. |
| int | $severity | The RFC 5424 log level. |
| string|null | $link | An optional link to attach to the entry. |