commit 284c4cdb5f524d9bab14e851d2fddd87c75d84fd (HEAD, 2003892-date-format) Author: Tim Plunkett Date: Wed Jun 5 00:19:54 2013 -0700 Restore locked functionality. diff --git a/core/modules/system/config/system.date_format.html_date.yml b/core/modules/system/config/system.date_format.html_date.yml index 72ec3b2..9098f3e 100644 --- a/core/modules/system/config/system.date_format.html_date.yml +++ b/core/modules/system/config/system.date_format.html_date.yml @@ -5,3 +5,4 @@ pattern: intl: 'yyyy-MM-dd' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/config/system.date_format.html_datetime.yml b/core/modules/system/config/system.date_format.html_datetime.yml index 8f2c382..20df544 100644 --- a/core/modules/system/config/system.date_format.html_datetime.yml +++ b/core/modules/system/config/system.date_format.html_datetime.yml @@ -5,3 +5,4 @@ pattern: intl: 'yyyy-MM-dd''T''kk:mm:ssZZ' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/config/system.date_format.html_month.yml b/core/modules/system/config/system.date_format.html_month.yml index a82eb59..5b7d31d 100644 --- a/core/modules/system/config/system.date_format.html_month.yml +++ b/core/modules/system/config/system.date_format.html_month.yml @@ -5,3 +5,4 @@ pattern: intl: 'Y-MM' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/config/system.date_format.html_time.yml b/core/modules/system/config/system.date_format.html_time.yml index a890cd3..8de6fc0 100644 --- a/core/modules/system/config/system.date_format.html_time.yml +++ b/core/modules/system/config/system.date_format.html_time.yml @@ -5,3 +5,4 @@ pattern: intl: 'H:mm:ss' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/config/system.date_format.html_week.yml b/core/modules/system/config/system.date_format.html_week.yml index e820bff..ab59e37 100644 --- a/core/modules/system/config/system.date_format.html_week.yml +++ b/core/modules/system/config/system.date_format.html_week.yml @@ -5,3 +5,4 @@ pattern: intl: 'Y-''W''WW' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/config/system.date_format.html_year.yml b/core/modules/system/config/system.date_format.html_year.yml index 9bf4a5e..9e07384 100644 --- a/core/modules/system/config/system.date_format.html_year.yml +++ b/core/modules/system/config/system.date_format.html_year.yml @@ -5,3 +5,4 @@ pattern: intl: 'Y' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/config/system.date_format.html_yearless_date.yml b/core/modules/system/config/system.date_format.html_yearless_date.yml index f2a6bde..69f5e22 100644 --- a/core/modules/system/config/system.date_format.html_yearless_date.yml +++ b/core/modules/system/config/system.date_format.html_yearless_date.yml @@ -5,3 +5,4 @@ pattern: intl: 'MM-d' status: '1' langcode: en +locked: '1' diff --git a/core/modules/system/lib/Drupal/system/DateFormatEditFormController.php b/core/modules/system/lib/Drupal/system/DateFormatEditFormController.php index e24f555..6fc2f3c 100644 --- a/core/modules/system/lib/Drupal/system/DateFormatEditFormController.php +++ b/core/modules/system/lib/Drupal/system/DateFormatEditFormController.php @@ -7,6 +7,8 @@ namespace Drupal\system; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; + /** * @todo. */ @@ -15,6 +17,15 @@ class DateFormatEditFormController extends DateFormatFormControllerBase { /** * {@inheritdoc} */ + protected function prepareEntity() { + if ($this->entity->isLocked()) { + throw new AccessDeniedHttpException(); + } + } + + /** + * {@inheritdoc} + */ public function form(array $form, array &$form_state) { $form = parent::form($form, $form_state); diff --git a/core/modules/system/lib/Drupal/system/DateFormatInterface.php b/core/modules/system/lib/Drupal/system/DateFormatInterface.php index ae35fae..eb456a4 100644 --- a/core/modules/system/lib/Drupal/system/DateFormatInterface.php +++ b/core/modules/system/lib/Drupal/system/DateFormatInterface.php @@ -54,4 +54,9 @@ public function getLocales(); */ public function hasLocales(); + /** + * @return bool + */ + public function isLocked(); + } diff --git a/core/modules/system/lib/Drupal/system/DateFormatListController.php b/core/modules/system/lib/Drupal/system/DateFormatListController.php index bc86400..737f5ac 100644 --- a/core/modules/system/lib/Drupal/system/DateFormatListController.php +++ b/core/modules/system/lib/Drupal/system/DateFormatListController.php @@ -18,6 +18,15 @@ class DateFormatListController extends ConfigEntityListController { /** * {@inheritdoc} */ + public function load() { + return array_filter(parent::load(), function ($entity) { + return !$entity->isLocked(); + }); + } + + /** + * {@inheritdoc} + */ public function buildHeader() { $header['id'] = t('Machine name'); $header['label'] = t('Name'); diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index e1597a7..d0613ad 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -12,6 +12,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\system\DateFormatInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** * Builds a form to delete a date format. @@ -86,6 +87,9 @@ protected function getCancelPath() { * The date format ID. */ public function buildForm(array $form, array &$form_state, DateFormatInterface $date_format = NULL) { + if ($date_format->isLocked()) { + throw new AccessDeniedHttpException(); + } $this->format = $date_format; return parent::buildForm($form, $form_state); diff --git a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php index 7cb8a3f..98c8080 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/DateFormat.php @@ -153,4 +153,11 @@ public function addLocale($locale) { return $this; } + /** + * {@inheritdoc} + */ + public function isLocked() { + return (bool) $this->locked; + } + }