Skip to content

Commit

Permalink
Merge branch 'main' into add-CSS_DEFAULT
Browse files Browse the repository at this point in the history
  • Loading branch information
mglaman authored Nov 16, 2023
2 parents ffbaf99 + f3f2cff commit 02d9179
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/functions/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ function drupal_get_title(): array|string|\Stringable|null
return $titleResolver->getTitle(\Drupal::request(), $route);
}

function request_uri(): string
{
return \Drupal::request()->getRequestUri();
}

/**
* @param mixed[] $variables
*/
Expand Down
14 changes: 14 additions & 0 deletions src/functions/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Drupal\Component\Render\MarkupInterface;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\UrlHelper;
Expand Down Expand Up @@ -376,6 +377,14 @@ function drupal_get_library(string $module, ?string $name = null): array|false
return $libraryDiscovery->getLibrariesByExtension($module);
}

/**
* @return array<int|string, mixed>
*/
function drupal_get_query_array(string $query): array
{
parse_str($query, $result);
return $result;
}

/**
* @param array<string, mixed> $options
Expand All @@ -395,6 +404,11 @@ function drupal_goto(string $path = '', array $options = [], int $http_response_
}
}

function drupal_json_decode(string $var): mixed
{
return Json::decode($var);
}

/**
* @param array<string, mixed>|object $record
* @param string[] $primary_keys
Expand Down
6 changes: 6 additions & 0 deletions src/functions/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

use Drupal\Core\File\FileSystemInterface;

function drupal_realpath(string $path): string|false
{
$service = \Drupal::service('file_system');
return $service instanceof FileSystemInterface ? $service->realpath($path) : false;
}

function file_prepare_directory(string &$directory, ?int $options = FileSystemInterface::MODIFY_PERMISSIONS): bool
{
return \Drupal::service('file_system')->prepareDirectory($directory, $options);
Expand Down

0 comments on commit 02d9179

Please sign in to comment.