Tip:
Highlight text to annotate it
X
Now, if you have worked with Drupal before, you are probably familiar with the dot info
file. It includes metadata about the module like the module name, the descriptions, and
the dependencies on other modules.
Now, the dot info structure is actually Drupal-specific. It's not used anywhere else. So in Drupal
8, we switched over to using a YAML file instead. That's the yml extension here.
Now, this is the first place in this video series where we are seeing Drupal switch out
something that's very Drupal-specific for something that's more widely adopted. Now,
the advantage to this specifically is that now that it's using a specific standard that's
supported by other libraries, we can use those other libraries to do things like parse the
data out of the YAML file.
Right now, this file is empty so let's fill it with some metadata and then we can take
a look at the format of a YAML file. So I'm opening it up in my editor.
Now, I'm using an editor called Komodo IDE but feel free to use whatever you are comfortable
with. I consistently use this editor throughout the videos on Build A Module so you get a
consistent experience. It's also a pretty powerful editor and it's available across
platforms.
Okay. So I'm going to jump back to my file explorer, and now let's open up the steps
folder and open up the first step which is called glue dot info dot yml initial file.
And we'll copy all of the code and paste it into our glue dot info dot yml file and save
it.
Now, the structure should look familiar. It has the name of the module, which is Glue,
the description which is a short description of the module, which core Drupal version it's
compatible with which is any version of Drupal 8 which package this belongs to which will
simply group it along with other modules on the modules listings page.
And finally, we have this new attribute called type which you haven't seen in previous versions
of Drupal. This may seem a little redundant at first because of course this is a module
that's in a module folder, but the idea is that in the future, modules may want to package
up other assets in Drupal such as themes or profiles. And right now, there's no way to
do that because Drupal assumes that everything that's in a module folder is a module.
But by specifying this type, hopefully in the future we'll be able to make modules more
full-featured. More like actual apps that can include those other assets. This might
not happen in Drupal 8 -- it could -- but it's definitely poised to happen in Drupal
9.
Now, if we compare this side to side with a Drupal 7 dot info file, you'd see that the
structure is almost identical except instead of using an equal sign, we are using a colon.
Now, you'd also see some differences in the structure when we looked at dependencies and
other types of arrays that end up getting added to a dot info or dot info yml file.
The YAML syntax also enables a whole slew of other features, including potentially processing
code which, while we don't want to do that in a dot info file, is still pretty powerful
and fits within the context of this syntax.