diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php index 5497efb..b3686cc 100644 --- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php @@ -754,7 +754,7 @@ protected function mapToStorageRecord(EntityInterface $entity, $table_key = 'bas // If we are creating a new entity, we must not populate the record with // NULL values otherwise defaults would not be applied. if (isset($value) || !$is_new) { - $record->$name = drupal_schema_get_field_value($info, $value); + $record->$name = $value; } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php deleted file mode 100644 index f1d13b0..0000000 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/MapItem.php +++ /dev/null @@ -1,98 +0,0 @@ -properties as $name => $property) { - $definitions[$name] = $property->getDefinition(); - } - - return $definitions; - } - - /** - * {@inheritdoc} - */ - public function setValue($values, $notify = TRUE) { - $this->properties = array(); - if (!isset($values)) { - return; - } - - if (!is_array($values)) { - if ($values instanceof MapItem) { - $values = $values->getValue(); - } - else { - $values = unserialize($values); - } - } - - foreach ($values as $name => $value) { - $this->properties[$name] = $this->valueToProperty($value, $name); - } - } - - /** - * {@inheritdoc} - */ - public function __get($name) { - if (!isset($this->properties[$name])) { - $this->properties[$name] = $this->valueToProperty(array(), $name); - } - - return $this->properties[$name]->getValue(); - } - - /** - * {@inheritdoc} - */ - public function __set($name, $value) { - if (isset($value)) { - if (isset($this->properties[$name])) { - $this->properties[$name]->setValue($value); - } - else { - $this->properties[$name] = $this->valueToProperty($value, $name); - } - } - else { - unset($this->properties[$name]); - } - } - - protected function valueToProperty($value, $name) { - $definition = array('type' => 'any'); - if ($value instanceof TypedData) { - $definition = $value->getDefinition(); - $value = $value->getValue(); - } - - return \Drupal::typedData()->create($definition, $value, $name, $this); - } - -} diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php new file mode 100644 index 0000000..957b0e8 --- /dev/null +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php @@ -0,0 +1,73 @@ +values = array(); + if (!isset($values)) { + return; + } + + if (!is_array($values)) { + if ($values instanceof MapItem) { + $values = $values->getValue(); + } + else { + $values = unserialize($values); + } + } + + $this->values = $values; + + // Notify the parent of any changes. + if ($notify && isset($this->parent)) { + $this->parent->onChange($this->name); + } + } + + /** + * {@inheritdoc} + */ + public function __get($name) { + if (!isset($this->values[$name])) { + $this->values[$name] = array(); + } + + return $this->values[$name]; + } + + /** + * {@inheritdoc} + */ + public function __set($name, $value) { + if (isset($value)) { + $this->values[$name] = $value; + } + else { + unset($this->values[$name]); + } + } + +} diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php index 485c13d..a5fb4a1 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php @@ -37,12 +37,6 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques $link = $request->query->get('link'); $name = $request->query->get('name'); if (isset($token) && \Drupal::csrfToken()->validate($token, 'shortcut-add-link') && shortcut_valid_link($link)) { - // Normalize the path in case it is an alias. - $link = $this->container()->get('path.alias_manager')->getSystemPath($link); - if (empty($link)) { - $link = ''; - } - $shortcut = $this->entityManager()->getStorageController('shortcut')->create(array( 'title' => $name, 'shortcut_set' => $shortcut_set->id(), @@ -51,10 +45,10 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques try { $shortcut->save(); - drupal_set_message(t('Added a shortcut for %title.', array('%title' => $name))); + drupal_set_message($this->t('Added a shortcut for %title.', array('%title' => $name))); } catch (\Exception $e) { - drupal_set_message(t('Unable to add a shortcut for %path.', array('%path' => $link))); + drupal_set_message($this->t('Unable to add a shortcut for %path.', array('%path' => $link))); } return $this->redirect(''); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php b/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php index 12c425d..d55a713 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php @@ -20,14 +20,14 @@ * label = @Translation("Shortcut link"), * module = "shortcut", * controllers = { - * "storage" = "Drupal\Core\Entity\DatabaseStorageControllerNG", + * "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController", * "access" = "Drupal\shortcut\ShortcutAccessController", * "form" = { * "default" = "Drupal\shortcut\ShortcutFormController", * "add" = "Drupal\shortcut\ShortcutFormController", * "delete" = "Drupal\shortcut\Form\ShortcutDeleteForm" * }, - * "translation" = "Drupal\content_translation\ContentTranslationControllerNG" + * "translation" = "Drupal\content_translation\ContentTranslationController" * }, * base_table = "shortcut", * data_table = "shortcut_property_data", diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php index 932c90e..68b7fc2 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutDeleteForm.php @@ -17,7 +17,7 @@ class ShortcutDeleteForm extends ContentEntityConfirmFormBase { /** * {@inheritdoc} */ - public function getFormID() { + public function getFormId() { return 'shortcut_confirm_delete'; } @@ -25,7 +25,7 @@ public function getFormID() { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete the shortcut %title?', array('%title' => $this->entity->title->value)); + return $this->t('Are you sure you want to delete the shortcut %title?', array('%title' => $this->entity->title->value)); } /** @@ -44,7 +44,7 @@ public function getCancelRoute() { * {@inheritdoc} */ public function getConfirmText() { - return t('Delete'); + return $this->t('Delete'); } /** @@ -53,7 +53,7 @@ public function getConfirmText() { public function submit(array $form, array &$form_state) { $this->entity->delete(); $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $this->entity->bundle(); - drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $this->entity->title->value))); + drupal_set_message($this->t('The shortcut %title has been deleted.', array('%title' => $this->entity->title->value))); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php deleted file mode 100644 index fc5fec2..0000000 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php +++ /dev/null @@ -1,48 +0,0 @@ -value; } + /** + * {@inheritdoc} + */ + public function setValue($value, $notify = TRUE) { + // Normalize the path in case it is an alias. + $value = \Drupal::service('path.alias_manager')->getSystemPath($value); + if (empty($value)) { + $value = ''; + } + + parent::setValue($value, $notify); + } + } diff --git a/core/modules/shortcut/shortcut.info.yml b/core/modules/shortcut/shortcut.info.yml index 1d7a237..dde0e9c 100644 --- a/core/modules/shortcut/shortcut.info.yml +++ b/core/modules/shortcut/shortcut.info.yml @@ -4,10 +4,4 @@ description: 'Allows users to manage customizable lists of shortcut links.' package: Core version: VERSION core: 8.x -<<<<<<< HEAD -dependencies: - - menu_link configure: shortcut.set_admin -======= -configure: admin/config/user-interface/shortcut ->>>>>>> wip