updated core to 8.6.1 via composer
This commit is contained in:
@@ -333,7 +333,6 @@ class Inspector {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Asserts that all members are strings matching a regular expression.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Drupal\Component\Bridge;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Zend\Feed\Reader\ExtensionManagerInterface as ReaderManagerInterface;
|
||||
use Zend\Feed\Writer\ExtensionManagerInterface as WriterManagerInterface;
|
||||
|
||||
@@ -48,6 +49,11 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
|
||||
*/
|
||||
protected $canonicalNames;
|
||||
|
||||
/**
|
||||
* @var \Zend\Feed\Reader\ExtensionManagerInterface|\Zend\Feed\Writer\ExtensionManagerInterface
|
||||
*/
|
||||
protected $standalone;
|
||||
|
||||
/**
|
||||
* Constructs a ZfExtensionManagerSfContainer object.
|
||||
*
|
||||
@@ -62,14 +68,25 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($extension) {
|
||||
return $this->container->get($this->prefix . $this->canonicalizeName($extension));
|
||||
try {
|
||||
return $this->container->get($this->prefix . $this->canonicalizeName($extension));
|
||||
}
|
||||
catch (ServiceNotFoundException $e) {
|
||||
if ($this->standalone && $this->standalone->has($extension)) {
|
||||
return $this->standalone->get($extension);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($extension) {
|
||||
return $this->container->has($this->prefix . $this->canonicalizeName($extension));
|
||||
if ($this->container->has($this->prefix . $this->canonicalizeName($extension))) {
|
||||
return TRUE;
|
||||
}
|
||||
return $this->standalone && $this->standalone->has($extension);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,4 +119,14 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
*/
|
||||
public function setStandalone($class) {
|
||||
if (!is_subclass_of($class, ReaderManagerInterface::class) && !is_subclass_of($class, WriterManagerInterface::class)) {
|
||||
throw new \RuntimeException("$class must implement Zend\Feed\Reader\ExtensionManagerInterface or Zend\Feed\Writer\ExtensionManagerInterface");
|
||||
}
|
||||
$this->standalone = new $class();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ class DateTimePlus {
|
||||
|
||||
use ToStringTrait;
|
||||
|
||||
const FORMAT = 'Y-m-d H:i:s';
|
||||
const FORMAT = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* A RFC7231 Compliant date.
|
||||
*
|
||||
* http://tools.ietf.org/html/rfc7231#section-7.1.1.1
|
||||
* @see http://tools.ietf.org/html/rfc7231#section-7.1.1.1
|
||||
*
|
||||
* Example: Sun, 06 Nov 1994 08:49:37 GMT
|
||||
*/
|
||||
@@ -477,7 +477,6 @@ class DateTimePlus {
|
||||
return $format;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Examines getLastErrors() to see what errors to report.
|
||||
*
|
||||
@@ -671,7 +670,7 @@ class DateTimePlus {
|
||||
* Formats the date for display.
|
||||
*
|
||||
* @param string $format
|
||||
* A format string using either PHP's date().
|
||||
* Format accepted by date().
|
||||
* @param array $settings
|
||||
* - timezone: (optional) String timezone name. Defaults to the timezone
|
||||
* of the date object.
|
||||
@@ -715,4 +714,14 @@ class DateTimePlus {
|
||||
$this->dateTimeObject->setTime(12, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a clone of the proxied PHP \DateTime object wrapped by this class.
|
||||
*
|
||||
* @return \DateTime
|
||||
* A clone of the wrapped PHP \DateTime object.
|
||||
*/
|
||||
public function getPhpDateTime() {
|
||||
return clone $this->dateTimeObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -282,7 +282,6 @@ class OptimizedPhpArrayDumper extends Dumper {
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dumps a collection to a PHP array.
|
||||
*
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Drupal\Component\Diff\Engine;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Class used internally by Diff to actually compute the diffs.
|
||||
*
|
||||
@@ -134,7 +132,7 @@ class DiffEngine {
|
||||
* Returns the whole line if it's small enough, or the MD5 hash otherwise.
|
||||
*/
|
||||
protected function _line_hash($line) {
|
||||
if (Unicode::strlen($line) > $this::MAX_XREF_LENGTH) {
|
||||
if (mb_strlen($line) > $this::MAX_XREF_LENGTH) {
|
||||
return md5($line);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Drupal\Component\Diff\Engine;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Additions by Axel Boldt follow, partly taken from diff.php, phpwiki-1.3.3
|
||||
*/
|
||||
@@ -64,7 +62,7 @@ class HWLDFWordAccumulator {
|
||||
}
|
||||
if ($word[0] == "\n") {
|
||||
$this->_flushLine($tag);
|
||||
$word = Unicode::substr($word, 1);
|
||||
$word = mb_substr($word, 1);
|
||||
}
|
||||
assert(!strstr($word, "\n"));
|
||||
$this->group .= $word;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\Component\Diff;
|
||||
|
||||
use Drupal\Component\Diff\Engine\HWLDFWordAccumulator;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* @todo document
|
||||
@@ -35,7 +34,7 @@ class WordLevelDiff extends MappedDiff {
|
||||
$words[] = "\n";
|
||||
$stripped[] = "\n";
|
||||
}
|
||||
if (Unicode::strlen($line) > $this::MAX_LINE_LENGTH) {
|
||||
if (mb_strlen($line) > $this::MAX_LINE_LENGTH) {
|
||||
$words[] = $line;
|
||||
$stripped[] = $line;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"license": "GPL-2.0-or-later",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"drupal/core-utility": "^8.2"
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -36,7 +36,7 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
||||
/**
|
||||
* The service container.
|
||||
*
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
|
||||
@@ -27,42 +27,42 @@ class PoHeader {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_langcode;
|
||||
protected $langcode;
|
||||
|
||||
/**
|
||||
* Formula for the plural form.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_pluralForms;
|
||||
protected $pluralForms;
|
||||
|
||||
/**
|
||||
* Author(s) of the file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_authors;
|
||||
protected $authors;
|
||||
|
||||
/**
|
||||
* Date the po file got created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_po_date;
|
||||
protected $poDate;
|
||||
|
||||
/**
|
||||
* Human readable language name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_languageName;
|
||||
protected $languageName;
|
||||
|
||||
/**
|
||||
* Name of the project the translation belongs to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_projectName;
|
||||
protected $projectName;
|
||||
|
||||
/**
|
||||
* Constructor, creates a PoHeader with default values.
|
||||
@@ -71,11 +71,11 @@ class PoHeader {
|
||||
* Language code.
|
||||
*/
|
||||
public function __construct($langcode = NULL) {
|
||||
$this->_langcode = $langcode;
|
||||
$this->langcode = $langcode;
|
||||
// Ignore errors when run during site installation before
|
||||
// date_default_timezone_set() is called.
|
||||
$this->_po_date = @date("Y-m-d H:iO");
|
||||
$this->_pluralForms = 'nplurals=2; plural=(n > 1);';
|
||||
$this->poDate = @date("Y-m-d H:iO");
|
||||
$this->pluralForms = 'nplurals=2; plural=(n > 1);';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ class PoHeader {
|
||||
* 'nplurals=2; plural=(n > 1);'.
|
||||
*/
|
||||
public function getPluralForms() {
|
||||
return $this->_pluralForms;
|
||||
return $this->pluralForms;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +96,7 @@ class PoHeader {
|
||||
* Human readable language name.
|
||||
*/
|
||||
public function setLanguageName($languageName) {
|
||||
$this->_languageName = $languageName;
|
||||
$this->languageName = $languageName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ class PoHeader {
|
||||
* The human readable language name.
|
||||
*/
|
||||
public function getLanguageName() {
|
||||
return $this->_languageName;
|
||||
return $this->languageName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class PoHeader {
|
||||
* Human readable project name.
|
||||
*/
|
||||
public function setProjectName($projectName) {
|
||||
$this->_projectName = $projectName;
|
||||
$this->projectName = $projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ class PoHeader {
|
||||
* The human readable project name.
|
||||
*/
|
||||
public function getProjectName() {
|
||||
return $this->_projectName;
|
||||
return $this->projectName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ class PoHeader {
|
||||
// There is only one value relevant for our header implementation when
|
||||
// reading, and that is the plural formula.
|
||||
if (!empty($values['Plural-Forms'])) {
|
||||
$this->_pluralForms = $values['Plural-Forms'];
|
||||
$this->pluralForms = $values['Plural-Forms'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +152,11 @@ class PoHeader {
|
||||
public function __toString() {
|
||||
$output = '';
|
||||
|
||||
$isTemplate = empty($this->_languageName);
|
||||
$isTemplate = empty($this->languageName);
|
||||
|
||||
$output .= '# ' . ($isTemplate ? 'LANGUAGE' : $this->_languageName) . ' translation of ' . ($isTemplate ? 'PROJECT' : $this->_projectName) . "\n";
|
||||
if (!empty($this->_authors)) {
|
||||
$output .= '# Generated by ' . implode("\n# ", $this->_authors) . "\n";
|
||||
$output .= '# ' . ($isTemplate ? 'LANGUAGE' : $this->languageName) . ' translation of ' . ($isTemplate ? 'PROJECT' : $this->projectName) . "\n";
|
||||
if (!empty($this->authors)) {
|
||||
$output .= '# Generated by ' . implode("\n# ", $this->authors) . "\n";
|
||||
}
|
||||
$output .= "#\n";
|
||||
|
||||
@@ -164,14 +164,14 @@ class PoHeader {
|
||||
$output .= "msgid \"\"\n";
|
||||
$output .= "msgstr \"\"\n";
|
||||
$output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
|
||||
$output .= "\"POT-Creation-Date: " . $this->_po_date . "\\n\"\n";
|
||||
$output .= "\"PO-Revision-Date: " . $this->_po_date . "\\n\"\n";
|
||||
$output .= "\"POT-Creation-Date: " . $this->poDate . "\\n\"\n";
|
||||
$output .= "\"PO-Revision-Date: " . $this->poDate . "\\n\"\n";
|
||||
$output .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
|
||||
$output .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
|
||||
$output .= "\"MIME-Version: 1.0\\n\"\n";
|
||||
$output .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
|
||||
$output .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
|
||||
$output .= "\"Plural-Forms: " . $this->_pluralForms . "\\n\"\n";
|
||||
$output .= "\"Plural-Forms: " . $this->pluralForms . "\\n\"\n";
|
||||
$output .= "\n";
|
||||
|
||||
return $output;
|
||||
|
||||
@@ -15,45 +15,45 @@ class PoItem {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_langcode;
|
||||
protected $langcode;
|
||||
|
||||
/**
|
||||
* The context this translation belongs to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_context = '';
|
||||
protected $context = '';
|
||||
|
||||
/**
|
||||
* The source string or array of strings if it has plurals.
|
||||
*
|
||||
* @var string|array
|
||||
*
|
||||
* @see $_plural
|
||||
* @see $plural
|
||||
*/
|
||||
private $_source;
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* Flag indicating if this translation has plurals.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_plural;
|
||||
protected $plural;
|
||||
|
||||
/**
|
||||
* The comment of this translation.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_comment;
|
||||
protected $comment;
|
||||
|
||||
/**
|
||||
* The translation string or array of strings if it has plurals.
|
||||
*
|
||||
* @var string|array
|
||||
* @see $_plural
|
||||
* @see $plural
|
||||
*/
|
||||
private $_translation;
|
||||
protected $translation;
|
||||
|
||||
/**
|
||||
* Gets the language code of the currently used language.
|
||||
@@ -61,7 +61,7 @@ class PoItem {
|
||||
* @return string with langcode
|
||||
*/
|
||||
public function getLangcode() {
|
||||
return $this->_langcode;
|
||||
return $this->langcode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ class PoItem {
|
||||
* @param string $langcode
|
||||
*/
|
||||
public function setLangcode($langcode) {
|
||||
$this->_langcode = $langcode;
|
||||
$this->langcode = $langcode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ class PoItem {
|
||||
* @return string $context
|
||||
*/
|
||||
public function getContext() {
|
||||
return $this->_context;
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ class PoItem {
|
||||
* @param string $context
|
||||
*/
|
||||
public function setContext($context) {
|
||||
$this->_context = $context;
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ class PoItem {
|
||||
* @return string or array $translation
|
||||
*/
|
||||
public function getSource() {
|
||||
return $this->_source;
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,7 @@ class PoItem {
|
||||
* @param string|array $source
|
||||
*/
|
||||
public function setSource($source) {
|
||||
$this->_source = $source;
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ class PoItem {
|
||||
* @return string or array $translation
|
||||
*/
|
||||
public function getTranslation() {
|
||||
return $this->_translation;
|
||||
return $this->translation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ class PoItem {
|
||||
* @param string|array $translation
|
||||
*/
|
||||
public function setTranslation($translation) {
|
||||
$this->_translation = $translation;
|
||||
$this->translation = $translation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ class PoItem {
|
||||
* @param bool $plural
|
||||
*/
|
||||
public function setPlural($plural) {
|
||||
$this->_plural = $plural;
|
||||
$this->plural = $plural;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +146,7 @@ class PoItem {
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlural() {
|
||||
return $this->_plural;
|
||||
return $this->plural;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ class PoItem {
|
||||
* @return String $comment
|
||||
*/
|
||||
public function getComment() {
|
||||
return $this->_comment;
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ class PoItem {
|
||||
* @param string $comment
|
||||
*/
|
||||
public function setComment($comment) {
|
||||
$this->_comment = $comment;
|
||||
$this->comment = $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,11 +185,11 @@ class PoItem {
|
||||
if (isset($values['comment'])) {
|
||||
$this->setComment($values['comment']);
|
||||
}
|
||||
if (isset($this->_source) &&
|
||||
strpos($this->_source, LOCALE_PLURAL_DELIMITER) !== FALSE) {
|
||||
$this->setSource(explode(LOCALE_PLURAL_DELIMITER, $this->_source));
|
||||
$this->setTranslation(explode(LOCALE_PLURAL_DELIMITER, $this->_translation));
|
||||
$this->setPlural(count($this->_source) > 1);
|
||||
if (isset($this->source) &&
|
||||
strpos($this->source, LOCALE_PLURAL_DELIMITER) !== FALSE) {
|
||||
$this->setSource(explode(LOCALE_PLURAL_DELIMITER, $this->source));
|
||||
$this->setTranslation(explode(LOCALE_PLURAL_DELIMITER, $this->translation));
|
||||
$this->setPlural(count($this->source) > 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,12 +207,12 @@ class PoItem {
|
||||
$output = '';
|
||||
|
||||
// Format string context.
|
||||
if (!empty($this->_context)) {
|
||||
$output .= 'msgctxt ' . $this->formatString($this->_context);
|
||||
if (!empty($this->context)) {
|
||||
$output .= 'msgctxt ' . $this->formatString($this->context);
|
||||
}
|
||||
|
||||
// Format translation.
|
||||
if ($this->_plural) {
|
||||
if ($this->plural) {
|
||||
$output .= $this->formatPlural();
|
||||
}
|
||||
else {
|
||||
@@ -232,11 +232,11 @@ class PoItem {
|
||||
$output = '';
|
||||
|
||||
// Format source strings.
|
||||
$output .= 'msgid ' . $this->formatString($this->_source[0]);
|
||||
$output .= 'msgid_plural ' . $this->formatString($this->_source[1]);
|
||||
$output .= 'msgid ' . $this->formatString($this->source[0]);
|
||||
$output .= 'msgid_plural ' . $this->formatString($this->source[1]);
|
||||
|
||||
foreach ($this->_translation as $i => $trans) {
|
||||
if (isset($this->_translation[$i])) {
|
||||
foreach ($this->translation as $i => $trans) {
|
||||
if (isset($this->translation[$i])) {
|
||||
$output .= 'msgstr[' . $i . '] ' . $this->formatString($trans);
|
||||
}
|
||||
else {
|
||||
@@ -252,8 +252,8 @@ class PoItem {
|
||||
*/
|
||||
private function formatSingular() {
|
||||
$output = '';
|
||||
$output .= 'msgid ' . $this->formatString($this->_source);
|
||||
$output .= 'msgstr ' . (isset($this->_translation) ? $this->formatString($this->_translation) : '""');
|
||||
$output .= 'msgid ' . $this->formatString($this->source);
|
||||
$output .= 'msgstr ' . (isset($this->translation) ? $this->formatString($this->translation) : '""');
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_items;
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* Constructor, initialize empty items.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_items = [];
|
||||
$this->items = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
$item->setTranslation(implode(LOCALE_PLURAL_DELIMITER, $item->getTranslation()));
|
||||
}
|
||||
$context = $item->getContext();
|
||||
$this->_items[$context != NULL ? $context : ''][$item->getSource()] = $item->getTranslation();
|
||||
$this->items[$context != NULL ? $context : ''][$item->getSource()] = $item->getTranslation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ class PoMemoryWriter implements PoWriterInterface {
|
||||
* @return array PoItem
|
||||
*/
|
||||
public function getData() {
|
||||
return $this->_items;
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Component\Gettext;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
|
||||
/**
|
||||
* Implements Gettext PO stream reader.
|
||||
@@ -17,7 +17,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_line_number = 0;
|
||||
protected $lineNumber = 0;
|
||||
|
||||
/**
|
||||
* Parser context for the stream reader state machine.
|
||||
@@ -32,90 +32,90 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_context = 'COMMENT';
|
||||
protected $context = 'COMMENT';
|
||||
|
||||
/**
|
||||
* Current entry being read. Incomplete.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_current_item = [];
|
||||
protected $currentItem = [];
|
||||
|
||||
/**
|
||||
* Current plural index for plural translations.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_current_plural_index = 0;
|
||||
protected $currentPluralIndex = 0;
|
||||
|
||||
/**
|
||||
* URI of the PO stream that is being read.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_uri = '';
|
||||
protected $uri = '';
|
||||
|
||||
/**
|
||||
* Language code for the PO stream being read.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_langcode = NULL;
|
||||
protected $langcode = NULL;
|
||||
|
||||
/**
|
||||
* File handle of the current PO stream.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_fd;
|
||||
protected $fd;
|
||||
|
||||
/**
|
||||
* The PO stream header.
|
||||
*
|
||||
* @var \Drupal\Component\Gettext\PoHeader
|
||||
*/
|
||||
private $_header;
|
||||
protected $header;
|
||||
|
||||
/**
|
||||
* Object wrapper for the last read source/translation pair.
|
||||
*
|
||||
* @var \Drupal\Component\Gettext\PoItem
|
||||
*/
|
||||
private $_last_item;
|
||||
protected $lastItem;
|
||||
|
||||
/**
|
||||
* Indicator of whether the stream reading is finished.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_finished;
|
||||
protected $finished;
|
||||
|
||||
/**
|
||||
* Array of translated error strings recorded on reading this stream so far.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_errors;
|
||||
protected $errors;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLangcode() {
|
||||
return $this->_langcode;
|
||||
return $this->langcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setLangcode($langcode) {
|
||||
$this->_langcode = $langcode;
|
||||
$this->langcode = $langcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHeader() {
|
||||
return $this->_header;
|
||||
return $this->header;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,14 +130,14 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getURI() {
|
||||
return $this->_uri;
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setURI($uri) {
|
||||
$this->_uri = $uri;
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,8 +150,8 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
* If the URI is not yet set.
|
||||
*/
|
||||
public function open() {
|
||||
if (!empty($this->_uri)) {
|
||||
$this->_fd = fopen($this->_uri, 'rb');
|
||||
if (!empty($this->uri)) {
|
||||
$this->fd = fopen($this->uri, 'rb');
|
||||
$this->readHeader();
|
||||
}
|
||||
else {
|
||||
@@ -166,8 +166,8 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
* If the stream is not open.
|
||||
*/
|
||||
public function close() {
|
||||
if ($this->_fd) {
|
||||
fclose($this->_fd);
|
||||
if ($this->fd) {
|
||||
fclose($this->fd);
|
||||
}
|
||||
else {
|
||||
throw new \Exception('Cannot close stream that is not open.');
|
||||
@@ -179,14 +179,14 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
*/
|
||||
public function readItem() {
|
||||
// Clear out the last item.
|
||||
$this->_last_item = NULL;
|
||||
$this->lastItem = NULL;
|
||||
|
||||
// Read until finished with the stream or a complete item was identified.
|
||||
while (!$this->_finished && is_null($this->_last_item)) {
|
||||
while (!$this->finished && is_null($this->lastItem)) {
|
||||
$this->readLine();
|
||||
}
|
||||
|
||||
return $this->_last_item;
|
||||
return $this->lastItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,14 +196,14 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
* The new seek position to set.
|
||||
*/
|
||||
public function setSeek($seek) {
|
||||
fseek($this->_fd, $seek);
|
||||
fseek($this->fd, $seek);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pointer position of the current PO stream.
|
||||
*/
|
||||
public function getSeek() {
|
||||
return ftell($this->_fd);
|
||||
return ftell($this->fd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,18 +221,18 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
}
|
||||
$header = new PoHeader();
|
||||
$header->setFromString(trim($item->getTranslation()));
|
||||
$this->_header = $header;
|
||||
$this->header = $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a line from the PO stream and stores data internally.
|
||||
*
|
||||
* Expands $this->_current_item based on new data for the current item. If
|
||||
* Expands $this->current_item based on new data for the current item. If
|
||||
* this line ends the current item, it is saved with setItemFromArray() with
|
||||
* data from $this->_current_item.
|
||||
* data from $this->current_item.
|
||||
*
|
||||
* An internal state machine is maintained in this reader using
|
||||
* $this->_context as the reading state. PO items are in between COMMENT
|
||||
* $this->context as the reading state. PO items are in between COMMENT
|
||||
* states (when items have at least one line or comment in between them) or
|
||||
* indicated by MSGSTR or MSGSTR_ARR followed immediately by an MSGID or
|
||||
* MSGCTXT (when items closely follow each other).
|
||||
@@ -245,25 +245,25 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
private function readLine() {
|
||||
// Read a line and set the stream finished indicator if it was not
|
||||
// possible anymore.
|
||||
$line = fgets($this->_fd);
|
||||
$this->_finished = ($line === FALSE);
|
||||
$line = fgets($this->fd);
|
||||
$this->finished = ($line === FALSE);
|
||||
|
||||
if (!$this->_finished) {
|
||||
if (!$this->finished) {
|
||||
|
||||
if ($this->_line_number == 0) {
|
||||
if ($this->lineNumber == 0) {
|
||||
// The first line might come with a UTF-8 BOM, which should be removed.
|
||||
$line = str_replace("\xEF\xBB\xBF", '', $line);
|
||||
// Current plurality for 'msgstr[]'.
|
||||
$this->_current_plural_index = 0;
|
||||
$this->currentPluralIndex = 0;
|
||||
}
|
||||
|
||||
// Track the line number for error reporting.
|
||||
$this->_line_number++;
|
||||
$this->lineNumber++;
|
||||
|
||||
// Initialize common values for error logging.
|
||||
$log_vars = [
|
||||
'%uri' => $this->getURI(),
|
||||
'%line' => $this->_line_number,
|
||||
'%line' => $this->lineNumber,
|
||||
];
|
||||
|
||||
// Trim away the linefeed. \\n might appear at the end of the string if
|
||||
@@ -273,24 +273,24 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
if (!strncmp('#', $line, 1)) {
|
||||
// Lines starting with '#' are comments.
|
||||
|
||||
if ($this->_context == 'COMMENT') {
|
||||
if ($this->context == 'COMMENT') {
|
||||
// Already in comment context, add to current comment.
|
||||
$this->_current_item['#'][] = substr($line, 1);
|
||||
$this->currentItem['#'][] = substr($line, 1);
|
||||
}
|
||||
elseif (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
|
||||
elseif (($this->context == 'MSGSTR') || ($this->context == 'MSGSTR_ARR')) {
|
||||
// We are currently in string context, save current item.
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
$this->setItemFromArray($this->currentItem);
|
||||
|
||||
// Start a new entry for the comment.
|
||||
$this->_current_item = [];
|
||||
$this->_current_item['#'][] = substr($line, 1);
|
||||
$this->currentItem = [];
|
||||
$this->currentItem['#'][] = substr($line, 1);
|
||||
|
||||
$this->_context = 'COMMENT';
|
||||
$this->context = 'COMMENT';
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// A comment following any other context is a syntax error.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
return;
|
||||
@@ -298,9 +298,9 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
elseif (!strncmp('msgid_plural', $line, 12)) {
|
||||
// A plural form for the current source string.
|
||||
|
||||
if ($this->_context != 'MSGID') {
|
||||
if ($this->context != 'MSGID') {
|
||||
// A plural form can only be added to an msgid directly.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -311,34 +311,34 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$quoted = $this->parseQuoted($line);
|
||||
if ($quoted === FALSE) {
|
||||
// The plural form must be wrapped in quotes.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains a syntax error on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains a syntax error on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Append the plural source to the current entry.
|
||||
if (is_string($this->_current_item['msgid'])) {
|
||||
if (is_string($this->currentItem['msgid'])) {
|
||||
// The first value was stored as string. Now we know the context is
|
||||
// plural, it is converted to array.
|
||||
$this->_current_item['msgid'] = [$this->_current_item['msgid']];
|
||||
$this->currentItem['msgid'] = [$this->currentItem['msgid']];
|
||||
}
|
||||
$this->_current_item['msgid'][] = $quoted;
|
||||
$this->currentItem['msgid'][] = $quoted;
|
||||
|
||||
$this->_context = 'MSGID_PLURAL';
|
||||
$this->context = 'MSGID_PLURAL';
|
||||
return;
|
||||
}
|
||||
elseif (!strncmp('msgid', $line, 5)) {
|
||||
// Starting a new message.
|
||||
|
||||
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
|
||||
if (($this->context == 'MSGSTR') || ($this->context == 'MSGSTR_ARR')) {
|
||||
// We are currently in string context, save current item.
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
$this->setItemFromArray($this->currentItem);
|
||||
|
||||
// Start a new context for the msgid.
|
||||
$this->_current_item = [];
|
||||
$this->currentItem = [];
|
||||
}
|
||||
elseif ($this->_context == 'MSGID') {
|
||||
elseif ($this->context == 'MSGID') {
|
||||
// We are currently already in the context, meaning we passed an id with no data.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -349,25 +349,25 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$quoted = $this->parseQuoted($line);
|
||||
if ($quoted === FALSE) {
|
||||
// The message id must be wrapped in quotes.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_current_item['msgid'] = $quoted;
|
||||
$this->_context = 'MSGID';
|
||||
$this->currentItem['msgid'] = $quoted;
|
||||
$this->context = 'MSGID';
|
||||
return;
|
||||
}
|
||||
elseif (!strncmp('msgctxt', $line, 7)) {
|
||||
// Starting a new context.
|
||||
|
||||
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
|
||||
if (($this->context == 'MSGSTR') || ($this->context == 'MSGSTR_ARR')) {
|
||||
// We are currently in string context, save current item.
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
$this->_current_item = [];
|
||||
$this->setItemFromArray($this->currentItem);
|
||||
$this->currentItem = [];
|
||||
}
|
||||
elseif (!empty($this->_current_item['msgctxt'])) {
|
||||
elseif (!empty($this->currentItem['msgctxt'])) {
|
||||
// A context cannot apply to another context.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -378,37 +378,37 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$quoted = $this->parseQuoted($line);
|
||||
if ($quoted === FALSE) {
|
||||
// The context string must be quoted.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_current_item['msgctxt'] = $quoted;
|
||||
$this->currentItem['msgctxt'] = $quoted;
|
||||
|
||||
$this->_context = 'MSGCTXT';
|
||||
$this->context = 'MSGCTXT';
|
||||
return;
|
||||
}
|
||||
elseif (!strncmp('msgstr[', $line, 7)) {
|
||||
// A message string for a specific plurality.
|
||||
|
||||
if (($this->_context != 'MSGID') &&
|
||||
($this->_context != 'MSGCTXT') &&
|
||||
($this->_context != 'MSGID_PLURAL') &&
|
||||
($this->_context != 'MSGSTR_ARR')) {
|
||||
if (($this->context != 'MSGID') &&
|
||||
($this->context != 'MSGCTXT') &&
|
||||
($this->context != 'MSGID_PLURAL') &&
|
||||
($this->context != 'MSGSTR_ARR')) {
|
||||
// Plural message strings must come after msgid, msgxtxt,
|
||||
// msgid_plural, or other msgstr[] entries.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Ensure the plurality is terminated.
|
||||
if (strpos($line, ']') === FALSE) {
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Extract the plurality.
|
||||
$frombracket = strstr($line, '[');
|
||||
$this->_current_plural_index = substr($frombracket, 1, strpos($frombracket, ']') - 1);
|
||||
$this->currentPluralIndex = substr($frombracket, 1, strpos($frombracket, ']') - 1);
|
||||
|
||||
// Skip to the next whitespace and trim away any further whitespace,
|
||||
// bringing $line to the message text only.
|
||||
@@ -417,24 +417,24 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$quoted = $this->parseQuoted($line);
|
||||
if ($quoted === FALSE) {
|
||||
// The string must be quoted.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) {
|
||||
$this->_current_item['msgstr'] = [];
|
||||
if (!isset($this->currentItem['msgstr']) || !is_array($this->currentItem['msgstr'])) {
|
||||
$this->currentItem['msgstr'] = [];
|
||||
}
|
||||
|
||||
$this->_current_item['msgstr'][$this->_current_plural_index] = $quoted;
|
||||
$this->currentItem['msgstr'][$this->currentPluralIndex] = $quoted;
|
||||
|
||||
$this->_context = 'MSGSTR_ARR';
|
||||
$this->context = 'MSGSTR_ARR';
|
||||
return;
|
||||
}
|
||||
elseif (!strncmp("msgstr", $line, 6)) {
|
||||
// A string pair for an msgid (with optional context).
|
||||
|
||||
if (($this->_context != 'MSGID') && ($this->_context != 'MSGCTXT')) {
|
||||
if (($this->context != 'MSGID') && ($this->context != 'MSGCTXT')) {
|
||||
// Strings are only valid within an id or context scope.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -445,13 +445,13 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$quoted = $this->parseQuoted($line);
|
||||
if ($quoted === FALSE) {
|
||||
// The string must be quoted.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_current_item['msgstr'] = $quoted;
|
||||
$this->currentItem['msgstr'] = $quoted;
|
||||
|
||||
$this->_context = 'MSGSTR';
|
||||
$this->context = 'MSGSTR';
|
||||
return;
|
||||
}
|
||||
elseif ($line != '') {
|
||||
@@ -460,37 +460,37 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$quoted = $this->parseQuoted($line);
|
||||
if ($quoted === FALSE) {
|
||||
// This string must be quoted.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Append the string to the current item.
|
||||
if (($this->_context == 'MSGID') || ($this->_context == 'MSGID_PLURAL')) {
|
||||
if (is_array($this->_current_item['msgid'])) {
|
||||
if (($this->context == 'MSGID') || ($this->context == 'MSGID_PLURAL')) {
|
||||
if (is_array($this->currentItem['msgid'])) {
|
||||
// Add string to last array element for plural sources.
|
||||
$last_index = count($this->_current_item['msgid']) - 1;
|
||||
$this->_current_item['msgid'][$last_index] .= $quoted;
|
||||
$last_index = count($this->currentItem['msgid']) - 1;
|
||||
$this->currentItem['msgid'][$last_index] .= $quoted;
|
||||
}
|
||||
else {
|
||||
// Singular source, just append the string.
|
||||
$this->_current_item['msgid'] .= $quoted;
|
||||
$this->currentItem['msgid'] .= $quoted;
|
||||
}
|
||||
}
|
||||
elseif ($this->_context == 'MSGCTXT') {
|
||||
elseif ($this->context == 'MSGCTXT') {
|
||||
// Multiline context name.
|
||||
$this->_current_item['msgctxt'] .= $quoted;
|
||||
$this->currentItem['msgctxt'] .= $quoted;
|
||||
}
|
||||
elseif ($this->_context == 'MSGSTR') {
|
||||
elseif ($this->context == 'MSGSTR') {
|
||||
// Multiline translation string.
|
||||
$this->_current_item['msgstr'] .= $quoted;
|
||||
$this->currentItem['msgstr'] .= $quoted;
|
||||
}
|
||||
elseif ($this->_context == 'MSGSTR_ARR') {
|
||||
elseif ($this->context == 'MSGSTR_ARR') {
|
||||
// Multiline plural translation string.
|
||||
$this->_current_item['msgstr'][$this->_current_plural_index] .= $quoted;
|
||||
$this->currentItem['msgstr'][$this->currentPluralIndex] .= $quoted;
|
||||
}
|
||||
else {
|
||||
// No valid context to append to.
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
return;
|
||||
@@ -498,12 +498,12 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
}
|
||||
|
||||
// Empty line read or EOF of PO stream, close out the last entry.
|
||||
if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) {
|
||||
$this->setItemFromArray($this->_current_item);
|
||||
$this->_current_item = [];
|
||||
if (($this->context == 'MSGSTR') || ($this->context == 'MSGSTR_ARR')) {
|
||||
$this->setItemFromArray($this->currentItem);
|
||||
$this->currentItem = [];
|
||||
}
|
||||
elseif ($this->_context != 'COMMENT') {
|
||||
$this->_errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
|
||||
elseif ($this->context != 'COMMENT') {
|
||||
$this->errors[] = new FormattableMarkup('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -533,11 +533,11 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
|
||||
$item->setTranslation($value['msgstr']);
|
||||
$item->setPlural($plural);
|
||||
$item->setComment($comments);
|
||||
$item->setLangcode($this->_langcode);
|
||||
$item->setLangcode($this->langcode);
|
||||
|
||||
$this->_last_item = $item;
|
||||
$this->lastItem = $item;
|
||||
|
||||
$this->_context = 'COMMENT';
|
||||
$this->context = 'COMMENT';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,21 +12,28 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_uri;
|
||||
protected $uri;
|
||||
|
||||
/**
|
||||
* The Gettext PO header.
|
||||
*
|
||||
* @var \Drupal\Component\Gettext\PoHeader
|
||||
*/
|
||||
private $_header;
|
||||
protected $header;
|
||||
|
||||
/**
|
||||
* File handle of the current PO stream.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
private $_fd;
|
||||
protected $fd;
|
||||
|
||||
/**
|
||||
* The language code of this writer.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $langcode;
|
||||
|
||||
/**
|
||||
* Gets the PO header of the current stream.
|
||||
@@ -35,7 +42,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* The Gettext PO header.
|
||||
*/
|
||||
public function getHeader() {
|
||||
return $this->_header;
|
||||
return $this->header;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +52,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* The Gettext PO header to set.
|
||||
*/
|
||||
public function setHeader(PoHeader $header) {
|
||||
$this->_header = $header;
|
||||
$this->header = $header;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +62,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* The language code.
|
||||
*/
|
||||
public function getLangcode() {
|
||||
return $this->_langcode;
|
||||
return $this->langcode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +72,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* The language code.
|
||||
*/
|
||||
public function setLangcode($langcode) {
|
||||
$this->_langcode = $langcode;
|
||||
$this->langcode = $langcode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +80,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
*/
|
||||
public function open() {
|
||||
// Open in write mode. Will overwrite the stream if it already exists.
|
||||
$this->_fd = fopen($this->getURI(), 'w');
|
||||
$this->fd = fopen($this->getURI(), 'w');
|
||||
// Write the header at the start.
|
||||
$this->writeHeader();
|
||||
}
|
||||
@@ -85,8 +92,8 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* If the stream is not open.
|
||||
*/
|
||||
public function close() {
|
||||
if ($this->_fd) {
|
||||
fclose($this->_fd);
|
||||
if ($this->fd) {
|
||||
fclose($this->fd);
|
||||
}
|
||||
else {
|
||||
throw new \Exception('Cannot close stream that is not open.');
|
||||
@@ -104,7 +111,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* If writing the data is not possible.
|
||||
*/
|
||||
private function write($data) {
|
||||
$result = fwrite($this->_fd, $data);
|
||||
$result = fwrite($this->fd, $data);
|
||||
if ($result === FALSE || $result != strlen($data)) {
|
||||
throw new \Exception('Unable to write data: ' . substr($data, 0, 20));
|
||||
}
|
||||
@@ -114,7 +121,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* Write the PO header to the stream.
|
||||
*/
|
||||
private function writeHeader() {
|
||||
$this->write($this->_header);
|
||||
$this->write($this->header);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,17 +148,17 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
|
||||
* If the URI is not set.
|
||||
*/
|
||||
public function getURI() {
|
||||
if (empty($this->_uri)) {
|
||||
if (empty($this->uri)) {
|
||||
throw new \Exception('No URI set.');
|
||||
}
|
||||
return $this->_uri;
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setURI($uri) {
|
||||
$this->_uri = $uri;
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ EOF;
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
|
||||
$lines
|
||||
EOF;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Definition;
|
||||
|
||||
use Drupal\Component\Plugin\Context\ContextDefinitionInterface;
|
||||
|
||||
/**
|
||||
* Provides an interface for plugin definitions which use contexts.
|
||||
*
|
||||
* @ingroup Plugin
|
||||
*/
|
||||
interface ContextAwarePluginDefinitionInterface extends PluginDefinitionInterface {
|
||||
|
||||
/**
|
||||
* Checks if the plugin defines a particular context.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the plugin defines the given context, otherwise FALSE.
|
||||
*/
|
||||
public function hasContextDefinition($name);
|
||||
|
||||
/**
|
||||
* Returns all context definitions for this plugin.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface[]
|
||||
* The context definitions.
|
||||
*/
|
||||
public function getContextDefinitions();
|
||||
|
||||
/**
|
||||
* Returns a particular context definition for this plugin.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
|
||||
* The context definition.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\ContextException
|
||||
* Thrown if the plugin does not define the given context.
|
||||
*/
|
||||
public function getContextDefinition($name);
|
||||
|
||||
/**
|
||||
* Adds a context to this plugin definition.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
* @param \Drupal\Component\Plugin\Context\ContextDefinitionInterface $definition
|
||||
* The context definition.
|
||||
*
|
||||
* @return $this
|
||||
* The called object.
|
||||
*/
|
||||
public function addContextDefinition($name, ContextDefinitionInterface $definition);
|
||||
|
||||
/**
|
||||
* Removes a context definition from this plugin.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
*
|
||||
* @return $this
|
||||
* The called object.
|
||||
*/
|
||||
public function removeContextDefinition($name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Definition;
|
||||
|
||||
use Drupal\Component\Plugin\Context\ContextDefinitionInterface;
|
||||
use Drupal\Component\Plugin\Exception\ContextException;
|
||||
|
||||
/**
|
||||
* Provides a trait for context-aware object-based plugin definitions.
|
||||
*/
|
||||
trait ContextAwarePluginDefinitionTrait {
|
||||
|
||||
/**
|
||||
* The context definitions for this plugin definition.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\Context\ContextDefinitionInterface[]
|
||||
*/
|
||||
protected $contextDefinitions = [];
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::hasContextDefinition().
|
||||
*/
|
||||
public function hasContextDefinition($name) {
|
||||
return array_key_exists($name, $this->contextDefinitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinitions().
|
||||
*/
|
||||
public function getContextDefinitions() {
|
||||
return $this->contextDefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinition().
|
||||
*/
|
||||
public function getContextDefinition($name) {
|
||||
if ($this->hasContextDefinition($name)) {
|
||||
return $this->contextDefinitions[$name];
|
||||
}
|
||||
throw new ContextException($this->id() . " does not define a '$name' context");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::addContextDefinition().
|
||||
*/
|
||||
public function addContextDefinition($name, ContextDefinitionInterface $definition) {
|
||||
$this->contextDefinitions[$name] = $definition;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::removeContextDefinition().
|
||||
*/
|
||||
public function removeContextDefinition($name) {
|
||||
unset($this->contextDefinitions[$name]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,8 @@ interface DiscoveryInterface {
|
||||
* @return mixed[]
|
||||
* An array of plugin definitions (empty array if no definitions were
|
||||
* found). Keys are plugin IDs.
|
||||
*
|
||||
* @see \Drupal\Core\Plugin\FilteredPluginManagerInterface::getFilteredDefinitions()
|
||||
*/
|
||||
public function getDefinitions();
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Exception;
|
||||
|
||||
/**
|
||||
* An exception class thrown when contexts exist but are missing a value.
|
||||
*/
|
||||
class MissingValueContextException extends ContextException {
|
||||
|
||||
/**
|
||||
* MissingValueContextException constructor.
|
||||
*
|
||||
* @param string[] $contexts_without_value
|
||||
* List of contexts with missing value.
|
||||
*/
|
||||
public function __construct(array $contexts_without_value = []) {
|
||||
$message = 'Required contexts without a value: ' . implode(', ', $contexts_without_value);
|
||||
parent::__construct($message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class DefaultFactory implements FactoryInterface {
|
||||
* @param \Drupal\Component\Plugin\Definition\PluginDefinitionInterface|mixed[] $plugin_definition
|
||||
* The plugin definition associated with the plugin ID.
|
||||
* @param string $required_interface
|
||||
* (optional) THe required plugin interface.
|
||||
* (optional) The required plugin interface.
|
||||
*
|
||||
* @return string
|
||||
* The appropriate class name.
|
||||
|
||||
@@ -41,7 +41,7 @@ abstract class PluginBase implements PluginInspectionInterface, DerivativeInspec
|
||||
protected $configuration;
|
||||
|
||||
/**
|
||||
* Constructs a Drupal\Component\Plugin\PluginBase object.
|
||||
* Constructs a \Drupal\Component\Plugin\PluginBase object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
|
||||
@@ -76,8 +76,7 @@ abstract class PluginManagerBase implements PluginManagerInterface {
|
||||
return $this->getFactory()->createInstance($plugin_id, $configuration);
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
$fallback_id = $this->getFallbackPluginId($plugin_id, $configuration);
|
||||
return $this->getFactory()->createInstance($fallback_id, $configuration);
|
||||
return $this->handlePluginNotFound($plugin_id, $configuration);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -85,6 +84,22 @@ abstract class PluginManagerBase implements PluginManagerInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows plugin managers to specify custom behavior if a plugin is not found.
|
||||
*
|
||||
* @param string $plugin_id
|
||||
* The ID of the missing requested plugin.
|
||||
* @param array $configuration
|
||||
* An array of configuration relevant to the plugin instance.
|
||||
*
|
||||
* @return object
|
||||
* A fallback plugin instance.
|
||||
*/
|
||||
protected function handlePluginNotFound($plugin_id, array $configuration) {
|
||||
$fallback_id = $this->getFallbackPluginId($plugin_id, $configuration);
|
||||
return $this->getFactory()->createInstance($fallback_id, $configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\Component\Render;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
|
||||
/**
|
||||
@@ -107,7 +106,7 @@ class FormattableMarkup implements MarkupInterface, \Countable {
|
||||
* The length of the string.
|
||||
*/
|
||||
public function count() {
|
||||
return Unicode::strlen($this->string);
|
||||
return mb_strlen($this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\Component\Render;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Escapes HTML syntax characters to HTML entities for display in markup.
|
||||
@@ -43,7 +42,7 @@ class HtmlEscapedText implements MarkupInterface, \Countable {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return Unicode::strlen($this->string);
|
||||
return mb_strlen($this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Drupal\Component\Render;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Implements MarkupInterface and Countable for rendered objects.
|
||||
*
|
||||
@@ -61,7 +59,7 @@ trait MarkupTrait {
|
||||
* The length of the string.
|
||||
*/
|
||||
public function count() {
|
||||
return Unicode::strlen($this->string);
|
||||
return mb_strlen($this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class YamlSymfony implements SerializationInterface {
|
||||
$yaml = new Parser();
|
||||
// Make sure we have a single trailing newline. A very simple config like
|
||||
// 'foo: bar' with no newline will fail to parse otherwise.
|
||||
return $yaml->parse($raw, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE | SymfonyYaml::PARSE_KEYS_AS_STRINGS);
|
||||
return $yaml->parse($raw, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
|
||||
|
||||
@@ -14,11 +14,11 @@ $base = [
|
||||
0x50 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x60 => '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
0x70 => NULL, NULL, NULL, NULL, '\'', ',', NULL, NULL, NULL, NULL, 'i', NULL, NULL, NULL, '?', NULL,
|
||||
0x80 => NULL, NULL, NULL, NULL, '', '', 'A', ':', 'E', 'E', 'I', NULL, 'O', NULL, 'Y', 'O',
|
||||
0x90 => 'i', 'A', 'B', 'G', 'D', 'E', 'Z', 'E', 'TH', 'I', 'K', 'L', 'M', 'N', 'X', 'O',
|
||||
0xA0 => 'P', 'R', NULL, 'S', 'T', 'Y', 'PH', 'CH', 'PS', 'O', 'I', 'Y', 'a', 'e', 'e', 'i',
|
||||
0xB0 => 'y', 'a', 'b', 'g', 'd', 'e', 'z', 'e', 'th', 'i', 'k', 'l', 'm', 'n', 'x', 'o',
|
||||
0xC0 => 'p', 'r', 's', 's', 't', 'y', 'ph', 'ch', 'ps', 'o', 'i', 'y', 'o', 'y', 'o', NULL,
|
||||
0x80 => NULL, NULL, NULL, NULL, '', '', 'A', ';', 'E', 'I', 'I', NULL, 'O', NULL, 'U', 'O',
|
||||
0x90 => 'I', 'A', 'B', 'G', 'D', 'E', 'Z', 'I', 'Th', 'I', 'K', 'L', 'M', 'N', 'X', 'O',
|
||||
0xA0 => 'P', 'R', NULL, 'S', 'T', 'Y', 'F', 'H', 'Ps', 'O', 'I', 'Y', 'a', 'e', 'i', 'i',
|
||||
0xB0 => 'y', 'a', 'b', 'g', 'd', 'e', 'z', 'i', 'th', 'i', 'k', 'l', 'm', 'n', 'x', 'o',
|
||||
0xC0 => 'p', 'r', 's', 's', 't', 'y', 'f', 'h', 'ps', 'o', 'i', 'y', 'o', 'y', 'o', NULL,
|
||||
0xD0 => 'b', 'th', 'Y', 'Y', 'Y', 'ph', 'p', '&', NULL, NULL, 'St', 'st', 'W', 'w', 'Q', 'q',
|
||||
0xE0 => 'Sp', 'sp', 'Sh', 'sh', 'F', 'f', 'Kh', 'kh', 'H', 'h', 'G', 'g', 'CH', 'ch', 'Ti', 'ti',
|
||||
0xF0 => 'k', 'r', 's', 'j', 'TH', 'e', NULL, 'S', 's', 'S', 'S', 's', NULL, NULL, NULL, NULL,
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
*/
|
||||
|
||||
$base = [
|
||||
0x00 => 'E', 'E', 'D', 'G', 'E', 'Z', 'I', 'I', 'J', 'L', 'N', 'C', 'K', 'I', 'U', 'D',
|
||||
0x10 => 'A', 'B', 'V', 'G', 'D', 'E', 'Z', 'Z', 'I', 'I', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
0x20 => 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'C', 'S', 'S', '', 'Y', '', 'E', 'U', 'A',
|
||||
0x30 => 'a', 'b', 'v', 'g', 'd', 'e', 'z', 'z', 'i', 'i', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||
0x40 => 'r', 's', 't', 'u', 'f', 'h', 'c', 'c', 's', 's', '', 'y', '', 'e', 'u', 'a',
|
||||
0x50 => 'e', 'e', 'd', 'g', 'e', 'z', 'i', 'i', 'j', 'l', 'n', 'c', 'k', 'i', 'u', 'd',
|
||||
0x00 => 'E', 'YO', 'D', 'G', 'E', 'Z', 'I', 'I', 'J', 'L', 'N', 'C', 'K', 'I', 'U', 'D',
|
||||
0x10 => 'A', 'B', 'V', 'G', 'D', 'E', 'ZH', 'Z', 'I', 'Y', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
0x20 => 'R', 'S', 'T', 'U', 'F', 'KH', 'C', 'CH', 'SH', 'SCH', '', 'Y', '', 'E', 'YU', 'YA',
|
||||
0x30 => 'a', 'b', 'v', 'g', 'd', 'e', 'zh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p',
|
||||
0x40 => 'r', 's', 't', 'u', 'f', 'kh', 'c', 'ch', 'sh', 'sch', '', 'y', '', 'e', 'yu', 'ya',
|
||||
0x50 => 'e', 'yo', 'd', 'g', 'e', 'z', 'i', 'i', 'j', 'l', 'n', 'c', 'k', 'i', 'u', 'd',
|
||||
0x60 => 'O', 'o', 'E', 'e', 'Ie', 'ie', 'E', 'e', 'Ie', 'ie', 'O', 'o', 'Io', 'io', 'Ks', 'ks',
|
||||
0x70 => 'Ps', 'ps', 'F', 'f', 'Y', 'y', 'Y', 'y', 'u', 'u', 'O', 'o', 'O', 'o', 'Ot', 'ot',
|
||||
0x80 => 'Q', 'q', '*1000*', '', '', '', '', NULL, '*100.000*', '*1.000.000*', NULL, NULL, '"', '"', 'R\'', 'r\'',
|
||||
|
||||
@@ -23,7 +23,7 @@ class Color {
|
||||
// Hash prefix is optional.
|
||||
$hex = ltrim($hex, '#');
|
||||
// Must be either RGB or RRGGBB.
|
||||
$length = Unicode::strlen($hex);
|
||||
$length = mb_strlen($hex);
|
||||
$valid = $valid && ($length === 3 || $length === 6);
|
||||
// Must be a valid hex value.
|
||||
$valid = $valid && ctype_xdigit($hex);
|
||||
|
||||
@@ -71,7 +71,7 @@ class Html {
|
||||
public static function getClass($class) {
|
||||
$class = (string) $class;
|
||||
if (!isset(static::$classes[$class])) {
|
||||
static::$classes[$class] = static::cleanCssIdentifier(Unicode::strtolower($class));
|
||||
static::$classes[$class] = static::cleanCssIdentifier(mb_strtolower($class));
|
||||
}
|
||||
return static::$classes[$class];
|
||||
}
|
||||
@@ -79,9 +79,10 @@ class Html {
|
||||
/**
|
||||
* Prepares a string for use as a CSS identifier (element, class, or ID name).
|
||||
*
|
||||
* http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for
|
||||
* valid CSS identifiers (including element names, classes, and IDs in
|
||||
* selectors.)
|
||||
* Link below shows the syntax for valid CSS identifiers (including element
|
||||
* names, classes, and IDs in selectors).
|
||||
*
|
||||
* @see http://www.w3.org/TR/CSS21/syndata.html#characters
|
||||
*
|
||||
* @param string $identifier
|
||||
* The identifier to clean.
|
||||
@@ -124,7 +125,7 @@ class Html {
|
||||
// Identifiers cannot start with a digit, two hyphens, or a hyphen followed by a digit.
|
||||
$identifier = preg_replace([
|
||||
'/^[0-9]/',
|
||||
'/^(-[0-9])|^(--)/'
|
||||
'/^(-[0-9])|^(--)/',
|
||||
], ['_', '__'], $identifier);
|
||||
return $identifier;
|
||||
}
|
||||
@@ -215,7 +216,7 @@ class Html {
|
||||
* @see self::getUniqueId()
|
||||
*/
|
||||
public static function getId($id) {
|
||||
$id = str_replace([' ', '_', '[', ']'], ['-', '-', '-', ''], Unicode::strtolower($id));
|
||||
$id = str_replace([' ', '_', '[', ']'], ['-', '-', '-', ''], mb_strtolower($id));
|
||||
|
||||
// As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can
|
||||
// only contain letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
|
||||
|
||||
@@ -259,7 +259,6 @@ class Random {
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a placeholder image.
|
||||
*
|
||||
|
||||
@@ -40,6 +40,7 @@ class SafeMarkup {
|
||||
* @see https://www.drupal.org/node/2549395
|
||||
*/
|
||||
public static function isSafe($string, $strategy = 'html') {
|
||||
@trigger_error('SafeMarkup::isSafe() is scheduled for removal in Drupal 9.0.0. Instead, you should just check if a variable is an instance of \Drupal\Component\Render\MarkupInterface. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
|
||||
return $string instanceof MarkupInterface;
|
||||
}
|
||||
|
||||
@@ -66,6 +67,7 @@ class SafeMarkup {
|
||||
* @see drupal_validate_utf8()
|
||||
*/
|
||||
public static function checkPlain($text) {
|
||||
@trigger_error('SafeMarkup::checkPlain() is scheduled for removal in Drupal 9.0.0. Rely on Twig\'s auto-escaping feature, or use the @link theme_render #plain_text @endlink key when constructing a render array that contains plain text in order to use the renderer\'s auto-escaping feature. If neither of these are possible, \Drupal\Component\Utility\Html::escape() can be used in places where explicit escaping is needed. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
|
||||
return new HtmlEscapedText($text);
|
||||
}
|
||||
|
||||
@@ -93,6 +95,7 @@ class SafeMarkup {
|
||||
* @see https://www.drupal.org/node/2549395
|
||||
*/
|
||||
public static function format($string, array $args) {
|
||||
@trigger_error('SafeMarkup::format() is scheduled for removal in Drupal 9.0.0. Use \Drupal\Component\Render\FormattableMarkup. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
|
||||
return new FormattableMarkup($string, $args);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,13 +87,6 @@ EOD;
|
||||
*/
|
||||
const STATUS_ERROR = -1;
|
||||
|
||||
/**
|
||||
* Holds the multibyte capabilities of the current environment.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected static $status = 0;
|
||||
|
||||
/**
|
||||
* Gets the current status of unicode/multibyte support on this environment.
|
||||
*
|
||||
@@ -107,7 +100,13 @@ EOD;
|
||||
* An error occurred. No unicode support.
|
||||
*/
|
||||
public static function getStatus() {
|
||||
return static::$status;
|
||||
switch (static::check()) {
|
||||
case 'mb_strlen':
|
||||
return Unicode::STATUS_SINGLEBYTE;
|
||||
case '':
|
||||
return Unicode::STATUS_MULTIBYTE;
|
||||
}
|
||||
return Unicode::STATUS_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,12 +122,16 @@ EOD;
|
||||
*
|
||||
* @param int $status
|
||||
* The new status of multibyte support.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In
|
||||
* Drupal 9 there will be no way to set the status and in Drupal 8 this
|
||||
* ability has been removed because mb_*() functions are supplied using
|
||||
* Symfony's polyfill.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2850048
|
||||
*/
|
||||
public static function setStatus($status) {
|
||||
if (!in_array($status, [static::STATUS_SINGLEBYTE, static::STATUS_MULTIBYTE, static::STATUS_ERROR])) {
|
||||
throw new \InvalidArgumentException('Invalid status value for unicode support.');
|
||||
}
|
||||
static::$status = $status;
|
||||
@trigger_error('\Drupal\Component\Utility\Unicode::setStatus() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. In Drupal 9 there will be no way to set the status and in Drupal 8 this ability has been removed because mb_*() functions are supplied using Symfony\'s polyfill. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,38 +146,33 @@ EOD;
|
||||
* Otherwise, an empty string.
|
||||
*/
|
||||
public static function check() {
|
||||
// Set appropriate configuration.
|
||||
mb_internal_encoding('utf-8');
|
||||
mb_language('uni');
|
||||
|
||||
// Check for mbstring extension.
|
||||
if (!function_exists('mb_strlen')) {
|
||||
static::$status = static::STATUS_SINGLEBYTE;
|
||||
if (!extension_loaded('mbstring')) {
|
||||
return 'mb_strlen';
|
||||
}
|
||||
|
||||
// Check mbstring configuration.
|
||||
if (ini_get('mbstring.func_overload') != 0) {
|
||||
static::$status = static::STATUS_ERROR;
|
||||
return 'mbstring.func_overload';
|
||||
}
|
||||
if (ini_get('mbstring.encoding_translation') != 0) {
|
||||
static::$status = static::STATUS_ERROR;
|
||||
return 'mbstring.encoding_translation';
|
||||
}
|
||||
// mbstring.http_input and mbstring.http_output are deprecated and empty by
|
||||
// default in PHP 5.6.
|
||||
if (version_compare(PHP_VERSION, '5.6.0') == -1) {
|
||||
if (ini_get('mbstring.http_input') != 'pass') {
|
||||
static::$status = static::STATUS_ERROR;
|
||||
return 'mbstring.http_input';
|
||||
}
|
||||
if (ini_get('mbstring.http_output') != 'pass') {
|
||||
static::$status = static::STATUS_ERROR;
|
||||
return 'mbstring.http_output';
|
||||
}
|
||||
}
|
||||
|
||||
// Set appropriate configuration.
|
||||
mb_internal_encoding('utf-8');
|
||||
mb_language('uni');
|
||||
static::$status = static::STATUS_MULTIBYTE;
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -224,17 +222,7 @@ EOD;
|
||||
* Converted data or FALSE.
|
||||
*/
|
||||
public static function convertToUtf8($data, $encoding) {
|
||||
if (function_exists('iconv')) {
|
||||
return @iconv($encoding, 'utf-8', $data);
|
||||
}
|
||||
elseif (function_exists('mb_convert_encoding')) {
|
||||
return @mb_convert_encoding($data, 'utf-8', $encoding);
|
||||
}
|
||||
elseif (function_exists('recode_string')) {
|
||||
return @recode_string($encoding . '..utf-8', $data);
|
||||
}
|
||||
// Cannot convert.
|
||||
return FALSE;
|
||||
return @iconv($encoding, 'utf-8', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,15 +269,15 @@ EOD;
|
||||
*
|
||||
* @return int
|
||||
* The length of the string.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use
|
||||
* mb_strlen() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2850048
|
||||
*/
|
||||
public static function strlen($text) {
|
||||
if (static::getStatus() == static::STATUS_MULTIBYTE) {
|
||||
return mb_strlen($text);
|
||||
}
|
||||
else {
|
||||
// Do not count UTF-8 continuation bytes.
|
||||
return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
|
||||
}
|
||||
@trigger_error('\Drupal\Component\Utility\Unicode::strlen() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use mb_strlen() instead. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
|
||||
return mb_strlen($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,18 +288,15 @@ EOD;
|
||||
*
|
||||
* @return string
|
||||
* The string in uppercase.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use
|
||||
* mb_strtoupper() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2850048
|
||||
*/
|
||||
public static function strtoupper($text) {
|
||||
if (static::getStatus() == static::STATUS_MULTIBYTE) {
|
||||
return mb_strtoupper($text);
|
||||
}
|
||||
else {
|
||||
// Use C-locale for ASCII-only uppercase.
|
||||
$text = strtoupper($text);
|
||||
// Case flip Latin-1 accented letters.
|
||||
$text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text);
|
||||
return $text;
|
||||
}
|
||||
@trigger_error('\Drupal\Component\Utility\Unicode::strtoupper() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use mb_strtoupper() instead. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
|
||||
return mb_strtoupper($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,18 +307,15 @@ EOD;
|
||||
*
|
||||
* @return string
|
||||
* The string in lowercase.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use
|
||||
* mb_strtolower() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2850048
|
||||
*/
|
||||
public static function strtolower($text) {
|
||||
if (static::getStatus() == static::STATUS_MULTIBYTE) {
|
||||
return mb_strtolower($text);
|
||||
}
|
||||
else {
|
||||
// Use C-locale for ASCII-only lowercase.
|
||||
$text = strtolower($text);
|
||||
// Case flip Latin-1 accented letters.
|
||||
$text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text);
|
||||
return $text;
|
||||
}
|
||||
@trigger_error('\Drupal\Component\Utility\Unicode::strtolower() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use mb_strtolower() instead. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
|
||||
return mb_strtolower($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +328,7 @@ EOD;
|
||||
* The string with the first character as uppercase.
|
||||
*/
|
||||
public static function ucfirst($text) {
|
||||
return static::strtoupper(static::substr($text, 0, 1)) . static::substr($text, 1);
|
||||
return mb_strtoupper(mb_substr($text, 0, 1)) . mb_substr($text, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +344,7 @@ EOD;
|
||||
*/
|
||||
public static function lcfirst($text) {
|
||||
// Note: no mbstring equivalent!
|
||||
return static::strtolower(static::substr($text, 0, 1)) . static::substr($text, 1);
|
||||
return mb_strtolower(mb_substr($text, 0, 1)) . mb_substr($text, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +361,7 @@ EOD;
|
||||
public static function ucwords($text) {
|
||||
$regex = '/(^|[' . static::PREG_CLASS_WORD_BOUNDARY . '])([^' . static::PREG_CLASS_WORD_BOUNDARY . '])/u';
|
||||
return preg_replace_callback($regex, function (array $matches) {
|
||||
return $matches[1] . Unicode::strtoupper($matches[2]);
|
||||
return $matches[1] . mb_strtoupper($matches[2]);
|
||||
}, $text);
|
||||
}
|
||||
|
||||
@@ -399,92 +381,15 @@ EOD;
|
||||
*
|
||||
* @return string
|
||||
* The shortened string.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use
|
||||
* mb_substr() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2850048
|
||||
*/
|
||||
public static function substr($text, $start, $length = NULL) {
|
||||
if (static::getStatus() == static::STATUS_MULTIBYTE) {
|
||||
return $length === NULL ? mb_substr($text, $start) : mb_substr($text, $start, $length);
|
||||
}
|
||||
else {
|
||||
$strlen = strlen($text);
|
||||
// Find the starting byte offset.
|
||||
$bytes = 0;
|
||||
if ($start > 0) {
|
||||
// Count all the characters except continuation bytes from the start
|
||||
// until we have found $start characters or the end of the string.
|
||||
$bytes = -1; $chars = -1;
|
||||
while ($bytes < $strlen - 1 && $chars < $start) {
|
||||
$bytes++;
|
||||
$c = ord($text[$bytes]);
|
||||
if ($c < 0x80 || $c >= 0xC0) {
|
||||
$chars++;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($start < 0) {
|
||||
// Count all the characters except continuation bytes from the end
|
||||
// until we have found abs($start) characters.
|
||||
$start = abs($start);
|
||||
$bytes = $strlen; $chars = 0;
|
||||
while ($bytes > 0 && $chars < $start) {
|
||||
$bytes--;
|
||||
$c = ord($text[$bytes]);
|
||||
if ($c < 0x80 || $c >= 0xC0) {
|
||||
$chars++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$istart = $bytes;
|
||||
|
||||
// Find the ending byte offset.
|
||||
if ($length === NULL) {
|
||||
$iend = $strlen;
|
||||
}
|
||||
elseif ($length > 0) {
|
||||
// Count all the characters except continuation bytes from the starting
|
||||
// index until we have found $length characters or reached the end of
|
||||
// the string, then backtrace one byte.
|
||||
$iend = $istart - 1;
|
||||
$chars = -1;
|
||||
$last_real = FALSE;
|
||||
while ($iend < $strlen - 1 && $chars < $length) {
|
||||
$iend++;
|
||||
$c = ord($text[$iend]);
|
||||
$last_real = FALSE;
|
||||
if ($c < 0x80 || $c >= 0xC0) {
|
||||
$chars++;
|
||||
$last_real = TRUE;
|
||||
}
|
||||
}
|
||||
// Backtrace one byte if the last character we found was a real
|
||||
// character and we don't need it.
|
||||
if ($last_real && $chars >= $length) {
|
||||
$iend--;
|
||||
}
|
||||
}
|
||||
elseif ($length < 0) {
|
||||
// Count all the characters except continuation bytes from the end
|
||||
// until we have found abs($start) characters, then backtrace one byte.
|
||||
$length = abs($length);
|
||||
$iend = $strlen; $chars = 0;
|
||||
while ($iend > 0 && $chars < $length) {
|
||||
$iend--;
|
||||
$c = ord($text[$iend]);
|
||||
if ($c < 0x80 || $c >= 0xC0) {
|
||||
$chars++;
|
||||
}
|
||||
}
|
||||
// Backtrace one byte if we are not at the beginning of the string.
|
||||
if ($iend > 0) {
|
||||
$iend--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// $length == 0, return an empty string.
|
||||
return '';
|
||||
}
|
||||
|
||||
return substr($text, $istart, max(0, $iend - $istart + 1));
|
||||
}
|
||||
@trigger_error('\Drupal\Component\Utility\Unicode::substr() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use mb_substr() instead. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
|
||||
return mb_substr($text, $start, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,15 +431,15 @@ EOD;
|
||||
$max_length = max($max_length, 0);
|
||||
$min_wordsafe_length = max($min_wordsafe_length, 0);
|
||||
|
||||
if (static::strlen($string) <= $max_length) {
|
||||
if (mb_strlen($string) <= $max_length) {
|
||||
// No truncation needed, so don't add ellipsis, just return.
|
||||
return $string;
|
||||
}
|
||||
|
||||
if ($add_ellipsis) {
|
||||
// Truncate ellipsis in case $max_length is small.
|
||||
$ellipsis = static::substr('…', 0, $max_length);
|
||||
$max_length -= static::strlen($ellipsis);
|
||||
$ellipsis = mb_substr('…', 0, $max_length);
|
||||
$max_length -= mb_strlen($ellipsis);
|
||||
$max_length = max($max_length, 0);
|
||||
}
|
||||
|
||||
@@ -553,11 +458,11 @@ EOD;
|
||||
$string = $matches[1];
|
||||
}
|
||||
else {
|
||||
$string = static::substr($string, 0, $max_length);
|
||||
$string = mb_substr($string, 0, $max_length);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$string = static::substr($string, 0, $max_length);
|
||||
$string = mb_substr($string, 0, $max_length);
|
||||
}
|
||||
|
||||
if ($add_ellipsis) {
|
||||
@@ -583,7 +488,7 @@ EOD;
|
||||
* $str2, and 0 if they are equal.
|
||||
*/
|
||||
public static function strcasecmp($str1, $str2) {
|
||||
return strcmp(static::strtoupper($str1), static::strtoupper($str2));
|
||||
return strcmp(mb_strtoupper($str1), mb_strtoupper($str2));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -715,18 +620,15 @@ EOD;
|
||||
* The position where $needle occurs in $haystack, always relative to the
|
||||
* beginning (independent of $offset), or FALSE if not found. Note that
|
||||
* a return value of 0 is not the same as FALSE.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. Use
|
||||
* mb_strpos() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2850048
|
||||
*/
|
||||
public static function strpos($haystack, $needle, $offset = 0) {
|
||||
if (static::getStatus() == static::STATUS_MULTIBYTE) {
|
||||
return mb_strpos($haystack, $needle, $offset);
|
||||
}
|
||||
else {
|
||||
// Remove Unicode continuation characters, to be compatible with
|
||||
// Unicode::strlen() and Unicode::substr().
|
||||
$haystack = preg_replace("/[\x80-\xBF]/", '', $haystack);
|
||||
$needle = preg_replace("/[\x80-\xBF]/", '', $needle);
|
||||
return strpos($haystack, $needle, $offset);
|
||||
}
|
||||
@trigger_error('\Drupal\Component\Utility\Unicode::strpos() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Use mb_strpos() instead. See https://www.drupal.org/node/2850048.', E_USER_DEPRECATED);
|
||||
return mb_strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class UrlHelper {
|
||||
/**
|
||||
* Parses an array into a valid, rawurlencoded query string.
|
||||
*
|
||||
* rawurlencode() is RFC3986 compliant, and as a consequence RFC3987
|
||||
* Function rawurlencode() is RFC3986 compliant, and as a consequence RFC3987
|
||||
* compliant. The latter defines the required format of "URLs" in HTML5.
|
||||
* urlencode() is almost the same as rawurlencode(), except that it encodes
|
||||
* spaces as "+" instead of "%20". This makes its result non compliant to
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"paragonie/random_compat": "^1.0|^2.0",
|
||||
"drupal/core-render": "^8.2"
|
||||
"drupal/core-render": "^8.2",
|
||||
"symfony/polyfill-iconv": "~1.0",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Drupal\Component\Uuid;
|
||||
* @see http://php.net/com_create_guid
|
||||
*/
|
||||
class Com implements UuidInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "drupal/core-uuid",
|
||||
"description": "PHP library for reading PO files.",
|
||||
"description": "UUID generation and validation.",
|
||||
"type": "library",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"support": {
|
||||
|
||||
Reference in New Issue
Block a user