updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
@@ -29,7 +29,8 @@ abstract class TextItemBase extends FieldItemBase {
|
||||
->setDescription(t('The text with the text format applied.'))
|
||||
->setComputed(TRUE)
|
||||
->setClass('\Drupal\text\TextProcessed')
|
||||
->setSetting('text source', 'value');
|
||||
->setSetting('text source', 'value')
|
||||
->setInternal(FALSE);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
@@ -87,15 +87,7 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
||||
*/
|
||||
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
|
||||
$element = parent::errorElement($element, $violation, $form, $form_state);
|
||||
if ($element === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
elseif (isset($violation->arrayPropertyPath[0])) {
|
||||
return $element[$violation->arrayPropertyPath[0]];
|
||||
}
|
||||
else {
|
||||
return $element;
|
||||
}
|
||||
return ($element === FALSE) ? FALSE : $element[$violation->arrayPropertyPath[0]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
* "text_long" = "text_long",
|
||||
* "text_with_summary" = "text_with_summary"
|
||||
* },
|
||||
* core = {6,7}
|
||||
* core = {6,7},
|
||||
* source_module = "text",
|
||||
* destination_module = "text",
|
||||
* )
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
|
||||
@@ -14,7 +14,9 @@ use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
* "text_long" = "text_long",
|
||||
* "text_with_summary" = "text_with_summary"
|
||||
* },
|
||||
* core = {6}
|
||||
* core = {6},
|
||||
* source_module = "text",
|
||||
* destination_module = "text",
|
||||
* )
|
||||
*/
|
||||
class TextField extends FieldPluginBase {
|
||||
|
||||
@@ -14,7 +14,9 @@ use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
* "text_long" = "text_long",
|
||||
* "text_with_summary" = "text_with_summary"
|
||||
* },
|
||||
* core = {7}
|
||||
* core = {7},
|
||||
* source_module = "text",
|
||||
* destination_module = "text",
|
||||
* )
|
||||
*/
|
||||
class TextField extends FieldPluginBase {
|
||||
|
||||
@@ -113,7 +113,7 @@ class TextFieldTest extends StringFieldTest {
|
||||
->save();
|
||||
|
||||
$test_file = current($this->drupalGetTestFiles('text'));
|
||||
$edit['files[file_field_0]'] = drupal_realpath($test_file->uri);
|
||||
$edit['files[file_field_0]'] = \Drupal::service('file_system')->realpath($test_file->uri);
|
||||
$this->drupalPostForm('entity_test/add', $edit, 'Upload');
|
||||
$this->assertResponse(200);
|
||||
$edit = [
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace Drupal\text;
|
||||
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\TypedData\DataDefinitionInterface;
|
||||
use Drupal\Core\TypedData\TypedDataInterface;
|
||||
use Drupal\Core\TypedData\TypedData;
|
||||
use Drupal\filter\FilterProcessResult;
|
||||
use Drupal\filter\Render\FilteredMarkup;
|
||||
|
||||
/**
|
||||
* A computed property for processing text with a format.
|
||||
@@ -12,12 +15,12 @@ use Drupal\Core\TypedData\TypedData;
|
||||
* Required settings (below the definition's 'settings' key) are:
|
||||
* - text source: The text property containing the to be processed text.
|
||||
*/
|
||||
class TextProcessed extends TypedData {
|
||||
class TextProcessed extends TypedData implements CacheableDependencyInterface {
|
||||
|
||||
/**
|
||||
* Cached processed text.
|
||||
*
|
||||
* @var string|null
|
||||
* @var \Drupal\filter\FilterProcessResult|null
|
||||
*/
|
||||
protected $processed = NULL;
|
||||
|
||||
@@ -37,20 +40,29 @@ class TextProcessed extends TypedData {
|
||||
*/
|
||||
public function getValue() {
|
||||
if ($this->processed !== NULL) {
|
||||
return $this->processed;
|
||||
return FilteredMarkup::create($this->processed->getProcessedText());
|
||||
}
|
||||
|
||||
$item = $this->getParent();
|
||||
$text = $item->{($this->definition->getSetting('text source'))};
|
||||
|
||||
// Avoid running check_markup() on empty strings.
|
||||
// Avoid doing unnecessary work on empty strings.
|
||||
if (!isset($text) || $text === '') {
|
||||
$this->processed = '';
|
||||
$this->processed = new FilterProcessResult('');
|
||||
}
|
||||
else {
|
||||
$this->processed = check_markup($text, $item->format, $item->getLangcode());
|
||||
$build = [
|
||||
'#type' => 'processed_text',
|
||||
'#text' => $text,
|
||||
'#format' => $item->format,
|
||||
'#filter_types_to_skip' => [],
|
||||
'#langcode' => $item->getLangcode(),
|
||||
];
|
||||
// Capture the cacheability metadata associated with the processed text.
|
||||
$processed_text = $this->getRenderer()->renderPlain($build);
|
||||
$this->processed = FilterProcessResult::createFromRenderArray($build)->setProcessedText((string) $processed_text);
|
||||
}
|
||||
return $this->processed;
|
||||
return FilteredMarkup::create($this->processed->getProcessedText());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,4 +76,37 @@ class TextProcessed extends TypedData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheTags() {
|
||||
$this->getValue();
|
||||
return $this->processed->getCacheTags();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheContexts() {
|
||||
$this->getValue();
|
||||
return $this->processed->getCacheContexts();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheMaxAge() {
|
||||
$this->getValue();
|
||||
return $this->processed->getCacheMaxAge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the renderer service.
|
||||
*
|
||||
* @return \Drupal\Core\Render\RendererInterface
|
||||
*/
|
||||
protected function getRenderer() {
|
||||
return \Drupal::service('renderer');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user