public function AliasCleaner::getPunctuationCharacters in Pathauto 8
Return an array of arrays for punctuation values.
Returns an array of arrays for punctuation values keyed by a name, including the value and a textual description. Can and should be expanded to include "all" non text punctuation values.
Return value
array An array of arrays for punctuation values keyed by a name, including the value and a textual description.
Overrides AliasCleanerInterface::getPunctuationCharacters
1 call to AliasCleaner::getPunctuationCharacters()
- AliasCleaner::cleanString in src/
AliasCleaner.php - Clean up a string segment to be used in an URL alias.
File
- src/
AliasCleaner.php, line 286
Class
- AliasCleaner
- Provides an alias cleaner.
Namespace
Drupal\pathautoCode
public function getPunctuationCharacters() {
if (empty($this->punctuationCharacters)) {
$langcode = $this->languageManager
->getCurrentLanguage()
->getId();
$cid = 'pathauto:punctuation:' . $langcode;
if ($cache = $this->cacheBackend
->get($cid)) {
$this->punctuationCharacters = $cache->data;
}
else {
$punctuation = [];
$punctuation['double_quotes'] = [
'value' => '"',
'name' => $this
->t('Double quotation marks'),
];
$punctuation['quotes'] = [
'value' => '\'',
'name' => $this
->t("Single quotation marks (apostrophe)"),
];
$punctuation['backtick'] = [
'value' => '`',
'name' => $this
->t('Back tick'),
];
$punctuation['comma'] = [
'value' => ',',
'name' => $this
->t('Comma'),
];
$punctuation['period'] = [
'value' => '.',
'name' => $this
->t('Period'),
];
$punctuation['hyphen'] = [
'value' => '-',
'name' => $this
->t('Hyphen'),
];
$punctuation['underscore'] = [
'value' => '_',
'name' => $this
->t('Underscore'),
];
$punctuation['colon'] = [
'value' => ':',
'name' => $this
->t('Colon'),
];
$punctuation['semicolon'] = [
'value' => ';',
'name' => $this
->t('Semicolon'),
];
$punctuation['pipe'] = [
'value' => '|',
'name' => $this
->t('Vertical bar (pipe)'),
];
$punctuation['left_curly'] = [
'value' => '{',
'name' => $this
->t('Left curly bracket'),
];
$punctuation['left_square'] = [
'value' => '[',
'name' => $this
->t('Left square bracket'),
];
$punctuation['right_curly'] = [
'value' => '}',
'name' => $this
->t('Right curly bracket'),
];
$punctuation['right_square'] = [
'value' => ']',
'name' => $this
->t('Right square bracket'),
];
$punctuation['plus'] = [
'value' => '+',
'name' => $this
->t('Plus sign'),
];
$punctuation['equal'] = [
'value' => '=',
'name' => $this
->t('Equal sign'),
];
$punctuation['asterisk'] = [
'value' => '*',
'name' => $this
->t('Asterisk'),
];
$punctuation['ampersand'] = [
'value' => '&',
'name' => $this
->t('Ampersand'),
];
$punctuation['percent'] = [
'value' => '%',
'name' => $this
->t('Percent sign'),
];
$punctuation['caret'] = [
'value' => '^',
'name' => $this
->t('Caret'),
];
$punctuation['dollar'] = [
'value' => '$',
'name' => $this
->t('Dollar sign'),
];
$punctuation['hash'] = [
'value' => '#',
'name' => $this
->t('Number sign (pound sign, hash)'),
];
$punctuation['at'] = [
'value' => '@',
'name' => $this
->t('At sign'),
];
$punctuation['exclamation'] = [
'value' => '!',
'name' => $this
->t('Exclamation mark'),
];
$punctuation['tilde'] = [
'value' => '~',
'name' => $this
->t('Tilde'),
];
$punctuation['left_parenthesis'] = [
'value' => '(',
'name' => $this
->t('Left parenthesis'),
];
$punctuation['right_parenthesis'] = [
'value' => ')',
'name' => $this
->t('Right parenthesis'),
];
$punctuation['question_mark'] = [
'value' => '?',
'name' => $this
->t('Question mark'),
];
$punctuation['less_than'] = [
'value' => '<',
'name' => $this
->t('Less-than sign'),
];
$punctuation['greater_than'] = [
'value' => '>',
'name' => $this
->t('Greater-than sign'),
];
$punctuation['slash'] = [
'value' => '/',
'name' => $this
->t('Slash'),
];
$punctuation['back_slash'] = [
'value' => '\\',
'name' => $this
->t('Backslash'),
];
// Allow modules to alter the punctuation list and cache the result.
$this->moduleHandler
->alter('pathauto_punctuation_chars', $punctuation);
$this->cacheBackend
->set($cid, $punctuation);
$this->punctuationCharacters = $punctuation;
}
}
return $this->punctuationCharacters;
}