Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Block/BlockBase.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
2 | 2 |
3 namespace Drupal\Core\Block; | 3 namespace Drupal\Core\Block; |
4 | 4 |
5 use Drupal\Core\Access\AccessResult; | 5 use Drupal\Core\Access\AccessResult; |
6 use Drupal\Core\Form\FormStateInterface; | 6 use Drupal\Core\Form\FormStateInterface; |
7 use Drupal\Core\Messenger\MessengerTrait; | |
7 use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait; | 8 use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait; |
8 use Drupal\Core\Plugin\ContextAwarePluginBase; | 9 use Drupal\Core\Plugin\ContextAwarePluginBase; |
9 use Drupal\Component\Utility\Unicode; | |
10 use Drupal\Component\Utility\NestedArray; | 10 use Drupal\Component\Utility\NestedArray; |
11 use Drupal\Core\Language\LanguageInterface; | 11 use Drupal\Core\Language\LanguageInterface; |
12 use Drupal\Core\Plugin\PluginWithFormsInterface; | 12 use Drupal\Core\Plugin\PluginWithFormsInterface; |
13 use Drupal\Core\Plugin\PluginWithFormsTrait; | 13 use Drupal\Core\Plugin\PluginWithFormsTrait; |
14 use Drupal\Core\Render\PreviewFallbackInterface; | |
14 use Drupal\Core\Session\AccountInterface; | 15 use Drupal\Core\Session\AccountInterface; |
15 use Drupal\Component\Transliteration\TransliterationInterface; | 16 use Drupal\Component\Transliteration\TransliterationInterface; |
16 | 17 |
17 /** | 18 /** |
18 * Defines a base block implementation that most blocks plugins will extend. | 19 * Defines a base block implementation that most blocks plugins will extend. |
21 * block settings, and handling for general user-defined block visibility | 22 * block settings, and handling for general user-defined block visibility |
22 * settings. | 23 * settings. |
23 * | 24 * |
24 * @ingroup block_api | 25 * @ingroup block_api |
25 */ | 26 */ |
26 abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface { | 27 abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewFallbackInterface { |
27 | 28 |
28 use ContextAwarePluginAssignmentTrait; | 29 use ContextAwarePluginAssignmentTrait; |
30 use MessengerTrait; | |
29 use PluginWithFormsTrait; | 31 use PluginWithFormsTrait; |
30 | 32 |
31 /** | 33 /** |
32 * The transliteration service. | 34 * The transliteration service. |
33 * | 35 * |
242 | 244 |
243 // @todo This is basically the same as what is done in | 245 // @todo This is basically the same as what is done in |
244 // \Drupal\system\MachineNameController::transliterate(), so it might make | 246 // \Drupal\system\MachineNameController::transliterate(), so it might make |
245 // sense to provide a common service for the two. | 247 // sense to provide a common service for the two. |
246 $transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_'); | 248 $transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_'); |
247 $transliterated = Unicode::strtolower($transliterated); | 249 $transliterated = mb_strtolower($transliterated); |
248 | 250 |
249 $transliterated = preg_replace('@[^a-z0-9_.]+@', '', $transliterated); | 251 $transliterated = preg_replace('@[^a-z0-9_.]+@', '', $transliterated); |
250 | 252 |
251 return $transliterated; | 253 return $transliterated; |
254 } | |
255 | |
256 /** | |
257 * {@inheritdoc} | |
258 */ | |
259 public function getPreviewFallbackString() { | |
260 return $this->t('Placeholder for the "@block" block', ['@block' => $this->label()]); | |
252 } | 261 } |
253 | 262 |
254 /** | 263 /** |
255 * Wraps the transliteration service. | 264 * Wraps the transliteration service. |
256 * | 265 * |