[Solved] How to add a menu link to a menu programmatically?

I want to add a menu link to a menu programmatically. Here is my code

      'title' => 'Example link',
      'link' => ['uri' => 'internal:/node'],
      'menu_name' => 'main',

But it gives me the following error

PHP Fatal error:  Call to a member function get() on a non-object in /var/www/drupal8/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php on line 105
Is there any way to add menu links to a menu programmatically?

How to remove mymodule configurations on uninstall

I have created a custom module and created a yml file to create a menu


id: custom_menu
label: 'Custom menu'
description: 'Custom menu.'
langcode: en
locked: true
  - mymod

When I installed my module it creates the the custom menu. But then When I uninstall the module and try to install it again I get the following exception

Add a external css stylesheet drupal 8

I would like to add an external stylesheet (google font) via the template.libraries.yml file?

Here is the font:
<link href='https://fonts.googleapis.com/css?family=Great+Vibes' rel='stylesheet' type='text/css'>

I tried this with no luck.

  version: VERSION
  remote: https://fonts.googleapis.com/css?family=Great+Vibes

Thanks for any help.

Drupal and Isomorphic JavaScript

The word is out. Headless Drupal with a REST API, is not the future. You're better off rendering your initial view on the server side. The wheel has been reinvented. This is called Isomorphic or Universal Javascript. The jury is still out on what title is the best. But Isomorphic JavaScript, introduced way back in 2013 by AirBNB and others holds some advantages... Drupal REST API and Isomorphic JavaScript

Entity one to many


I was wondering: in Drupal8 when we create an entity we define basefielddefinitions. But is it also possible to define a field that holds multiple values?

ex: A user must indicate wich types of devices he has. There is a ContentEntity type devices to wich the field references. But possibly the user as more than one device.

I can't find how to do this in Drupal. The normal UML way would be to define an extra table that holds the relation to make that technically possible.


Set views configurations settings on custom module install

I have a custom module. On its installation I want to set some configuration settings of views like:


to TRUE.

For this I have added a file mymod_views.settings.yml to modules/mymod/config/install/. the content of the file is:


Subscribe with RSS Subscribe to RSS - Drupal 8.x