diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index 9aa76d4..ba688bc 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -54,6 +54,11 @@ public static function createInstance(ContainerInterface $container, $entity_typ */ public function form(array $form, array &$form_state) { $menu_link = $this->entity; + // This is always loading 'tools' no matter which menu the link is added to. + $menu = menu_load($menu_link->bundle()); + //dpm($menu_link); + //dpm($menu); + // Since menu_link_load() no longer returns a translated and access checked // item, do it here instead. _menu_link_translate($menu_link); @@ -156,11 +161,13 @@ public function form(array $form, array &$form_state) { '#description' => t('Optional. In the menu, the heavier links will sink and the lighter links will be positioned nearer the top.'), ); + $language_configuration = module_invoke('language', 'get_default_configuration', 'menu_link', $menu->id()); $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), '#languages' => Language::STATE_ALL, '#default_value' => $menu_link->langcode, + '#access' => !is_null($language_configuration['language_show']) && $language_configuration['language_show'], ); return parent::form($form, $form_state, $menu_link); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php index 484f5d0..098e4d2 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php @@ -14,6 +14,7 @@ use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Entity; +use Drupal\Core\Language\Language; /** * Defines the menu link entity class. @@ -165,6 +166,16 @@ class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface { public $depth; /** + * Default values for the link. + * + * @var array + */ + protected $values = array( + 'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))), + 'weight' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 0))), + ); + + /** * A flag to indicate that the user has manually created or edited the link. * * @var int