src/Drupal/functions common.php

Functions

drupal_encode_path()

drupal_encode_path(string  $path) : string

Parameters

string $path

Returns

string —

url()

url(?string  $path = null, array  $options = []) : string

Parameters

?string $path
array $options

Returns

string —

l()

l(string  $text, string  $path, array{attributes?: array, html?: bool}  $options = []) : string

Parameters

string $text
string $path
array{attributes?: array, html?: bool} $options

Returns

string —

drupal_attributes()

drupal_attributes(array  $attributes = []) : string

Parameters

array $attributes

Returns

string —

entity_load()

entity_load(string  $entity_type, array|false  $ids = false, array  $conditions = [], bool  $reset = false) : array<int|string,\Drupal\Core\Entity\EntityInterface>

Parameters

string $entity_type
array|false $ids
array $conditions
bool $reset

Returns

array —

_entity_load()

_entity_load(string  $entity_type, array|int|string|false  $ids, array|bool  $conditions, bool  $reset) : array|\Drupal\Core\Entity\EntityInterface|null

Parameters

string $entity_type
array|int|string|false $ids
array|bool $conditions
bool $reset

Returns

array|\Drupal\Core\Entity\EntityInterface|null —

entity_get_info()

entity_get_info(?string  $entity_type = null) : array<string,mixed>

Parameters

?string $entity_type

Returns

array —

drupal_sort_weight()

drupal_sort_weight(mixed  $a, mixed  $b) : int

Orders two items by their `weight` key; an item without one weighs 0, as in Drupal 7.

Parameters

mixed $a
mixed $b

Returns

int —

drupal_sort_title()

drupal_sort_title(mixed  $a, mixed  $b) : int

Orders two items by their `title` key, ignoring case.

Parameters

mixed $a
mixed $b

Returns

int —

entity_load_unchanged()

entity_load_unchanged(string  $entity_type, int|string  $id) : mixed

Parameters

string $entity_type
int|string $id

Returns

mixed —

entity_get_controller()

entity_get_controller(string  $entity_type) : object

Parameters

string $entity_type

Returns

object —

entity_uri()

entity_uri(string  $entity_type, \Drupal\Core\Entity\EntityInterface  $entity) : string

Parameters

string $entity_type
\Drupal\Core\Entity\EntityInterface $entity

Returns

string —

entity_extract_ids()

entity_extract_ids(string  $entity_type, \Drupal\Core\Entity\EntityInterface  $entity) : array{int|string|null, int|string|null, string}

Parameters

string $entity_type
\Drupal\Core\Entity\EntityInterface $entity

Returns

array{int|string|null, int|string|null, string} —

entity_language()

entity_language(string  $entity_type, \Drupal\Core\Entity\EntityInterface  $entity) : ?string

Parameters

string $entity_type
\Drupal\Core\Entity\EntityInterface $entity

Returns

?string —

element_children()

element_children(array  $elements, bool  $sort = false) : array<string,mixed>

Parameters

array $elements
bool $sort

Returns

array —

drupal_get_path()

drupal_get_path(string  $type, string  $name) : string

Parameters

string $type
string $name

Returns

string —

anachron_request_time()

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.

Returns

int —

drupal_get_schema_unprocessed()

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.

Parameters

string $module
?string $table

Returns

array —

drupal_render_children()

drupal_render_children(array  $element, string[]|null  $children_keys = null) : string

Parameters

array $element
string[]|null $children_keys

Returns

string —

drupal_render()

drupal_render(array  $elements) : \Drupal\Component\Render\MarkupInterface|string

Parameters

array $elements

Returns

\Drupal\Component\Render\MarkupInterface|string —

render()

render(array|mixed  $element) : string|mixed

Parameters

array|mixed $element

Returns

string|mixed —

drupal_add_library()

drupal_add_library(string  $module, string  $name, ?bool  $every_page = null) : void

Parameters

string $module
string $name
?bool $every_page

Returns

void —

drupal_add_js()

drupal_add_js(array|string|null  $data = null, array|string|null  $options = null) : string[]

Parameters

array|string|null $data
array|string|null $options

Returns

string[] —

drupal_add_css()

drupal_add_css(string|null  $data = null, array|string|null  $options = null) : string[]

Parameters

string|null $data
array|string|null $options

Returns

string[] —

drupal_html_class()

drupal_html_class(string  $class) : string

Parameters

string $class

Returns

string —

filter_xss_admin()

filter_xss_admin(string  $string) : string

Parameters

string $string

Returns

string —

filter_xss()

filter_xss(string  $string, string[]  $allowed_tags = ['a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd']) : string

Parameters

string $string
string[] $allowed_tags

Returns

string —

filter_xss_bad_protocol()

filter_xss_bad_protocol(string  $string, bool  $decode = true) : string

Parameters

string $string
bool $decode

Returns

string —

drupal_map_assoc()

drupal_map_assoc((string|int)[]  $array, ?callable  $function = null) : array<string|int,mixed>

Parameters

(string|int)[] $array
?callable $function

Returns

array —

drupal_clean_css_identifier()

drupal_clean_css_identifier(string  $identifier, string[]  $filter = [' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '']) : string

Parameters

string $identifier
string[] $filter

Returns

string —

drupal_array_get_nested_value()

& drupal_array_get_nested_value(array  $array, array  $parents, ?bool  $key_exists = null) : mixed

Parameters

array $array
array $parents
?bool $key_exists

Returns

mixed —

drupal_array_set_nested_value()

drupal_array_set_nested_value(array  $array, array  $parents, mixed  $value, bool  $force = false) : void

Parameters

array $array
array $parents
mixed $value
bool $force

Returns

void —

drupal_array_nested_key_exists()

drupal_array_nested_key_exists(array  $array, array  $parents) : bool

Parameters

array $array
array $parents

Returns

bool —

drupal_get_library()

drupal_get_library(string  $module, ?string  $name = null) : array<string,mixed>|false

Parameters

string $module
?string $name

Returns

array|false —

drupal_get_query_array()

drupal_get_query_array(string  $query) : array<int|string,mixed>

Parameters

string $query

Returns

array —

drupal_goto()

drupal_goto(string  $path = '', array  $options = [], int  $http_response_code = 302) : void

Parameters

string $path
array $options
int $http_response_code

Returns

void —

drupal_json_decode()

drupal_json_decode(string  $var) : mixed

Parameters

string $var

Returns

mixed —

drupal_json_encode()

drupal_json_encode(mixed  $var) : string

Parameters

mixed $var

Returns

string —

drupal_write_record()

drupal_write_record(string  $table, array|object  $record, string[]  $primary_keys = []) : int|false

Parameters

string $table
array|object $record
string[] $primary_keys

Returns

int|false —

drupal_parse_info_file()

drupal_parse_info_file(string  $filename) : array

Parameters

string $filename

Returns

array —

drupal_parse_info_format()

drupal_parse_info_format(mixed  $data) : array

Parameters

mixed $data

Returns

array —