This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace AKlump\Knowledge\Helpers; | |
| /** | |
| * Retrieves the home directory of the current user. | |
| * | |
| * The method first attempts to fetch the home directory using the `HOME` | |
| * or `USERPROFILE` environment variables. If neither is set, it combines | |
| * the `HOMEDRIVE` and `HOMEPATH` environment variables to determine the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\typed_entity\RepositoryManager; | |
| /** | |
| * Provides access to the typed entity repository manager. | |
| * | |
| * Prefer dependency injection when the consuming class supports it: | |
| * | |
| * @code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\Core\Logger\LoggerChannelInterface; | |
| use Psr\Log\LogLevel; | |
| /** | |
| * Provides class-scoped logging helpers. | |
| * | |
| * Classes using this trait get a logger channel derived from the consuming | |
| * class name. The channel uses the short class name so Drupal's log UI remains |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # @file | |
| # Handle NPM dependencies in a directory and/or subdirectories | |
| # | |
| # ========= Bootstrap ========= | |
| s="${BASH_SOURCE[0]}";[[ "$s" ]] || s="${(%):-%N}";while [ -h "$s" ];do d="$(cd -P "$(dirname "$s")" && pwd)";s="$(readlink "$s")";[[ $s != /* ]] && s="$d/$s";done;__DIR__=$(cd -P "$(dirname "$s")" && pwd) | |
| basepath="$(cd -P "$__DIR__/.." && pwd)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * The Upfind class provides functionality to locate a file or directory | |
| * by walking up the directory tree from a starting directory. | |
| */ | |
| class Upfind { | |
| public function __invoke(string $basename): string { | |
| $result = $this->upfind($basename); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Windows') | |
| || strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' | |
| || DIRECTORY_SEPARATOR === '\\'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if (!$account instanceof \Drupal\Core\Session\AccountInterface || $account->isAnonymous()) { | |
| $timezone_name = \Drupal::config('system.date')->get('timezone.default'); | |
| } | |
| else { | |
| $timezone_name = $account->getTimeZone(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Drupal\commons_core\Helper; | |
| use http\Exception\InvalidArgumentException; | |
| class GetUrlTemplateByRouteName { | |
| /** | |
| * Generate a URL template from a route. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary | |
| if (isset($GLOBALS['_composer_autoload_path'])) { | |
| // As of Composer 2.2... | |
| $_composer_autoload_path = $GLOBALS['_composer_autoload_path']; | |
| } | |
| else { | |
| // < Composer 2.2 | |
| $ds = DIRECTORY_SEPARATOR; | |
| foreach ([ | |
| __DIR__ . $ds . '..' . $ds . '..' . $ds . 'autoload.php', |
NewerOlder