WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.046 --> 00:00:04.786 align:middle
I'm pretty sure that our new
item_view is configured correctly.

00:00:05.216 --> 00:00:10.536 align:middle
We have item\value_type:
contentful_entry, which I know is correct...

00:00:10.536 --> 00:00:18.196 align:middle
and then we're using contentful\content_type
set to skill so that this only affects skills.

00:00:18.876 --> 00:00:22.396 align:middle
But... it doesn't seem to
be working on the frontend.

00:00:23.266 --> 00:00:29.716 align:middle
Earlier, when we ran debug:config, we saw that
the problem lies with the order of the config.

00:00:30.476 --> 00:00:34.376 align:middle
Layouts reads from top to bottom
when deciding which "view" to use.

00:00:35.016 --> 00:00:40.486 align:middle
So it looks at this one first, sees that
the value_type is contentful_entry...

00:00:40.896 --> 00:00:42.486 align:middle
and just stops.

00:00:43.266 --> 00:00:46.746 align:middle
To fix this, we need to reverse our config.

00:00:47.686 --> 00:00:50.806 align:middle
Ok, so... why is it in this order to begin with?

00:00:51.306 --> 00:00:53.856 align:middle
Why does our config show up at the bottom?

00:00:54.746 --> 00:01:00.256 align:middle
This is due to how Symfony loads
config: it loads bundle config first -

00:01:00.546 --> 00:01:07.416 align:middle
like from the Contentful package or Layouts
- and then loads our configuration files.

00:01:08.116 --> 00:01:10.926 align:middle
And, that's usually the order we want!

00:01:11.576 --> 00:01:16.166 align:middle
It allows us to override
configuration that's set in bundles.

00:01:16.816 --> 00:01:19.926 align:middle
But in this case, we want the opposite.

00:01:20.676 --> 00:01:22.176 align:middle
How do we accomplish that?

00:01:22.666 --> 00:01:26.526 align:middle
By asking Symfony to prepend our configuration.

00:01:26.526 --> 00:01:31.436 align:middle
In the config/ directory, create
a new directory called prepends/

00:01:31.846 --> 00:01:34.826 align:middle
and move the Netgen Layouts
configuration into it.

00:01:35.416 --> 00:01:42.016 align:middle
This will stop Symfony from loading that file in
the normal way: we're going to load it manually.

00:01:42.946 --> 00:01:44.716 align:middle
The next step is a bit technical.

00:01:45.316 --> 00:01:50.266 align:middle
In src/, create an "extension" class
called, how about, AppExtension.

00:01:50.266 --> 00:01:55.436 align:middle
I'm going to paste in the code: you can
grab this from the code block on this page.

00:01:55.976 --> 00:01:59.006 align:middle
This loads our config file like normal...

00:01:59.346 --> 00:02:02.336 align:middle
except that it will be prepended.

00:02:03.246 --> 00:02:04.006 align:middle
Final step.

00:02:04.376 --> 00:02:08.166 align:middle
To get this method to be
called, open up the Kernel class.

00:02:09.056 --> 00:02:15.316 align:middle
After use MicroKernelTrait, add
configureContainer as baseConfigureContainer.

00:02:16.136 --> 00:02:20.066 align:middle
This adds the configureContainer
method from MicroKernelTrait

00:02:20.306 --> 00:02:23.216 align:middle
into this class like a trait normally would...

00:02:24.046 --> 00:02:28.516 align:middle
except that it renames it
to baseConfigureContainer.

00:02:29.176 --> 00:02:34.036 align:middle
We're doing this so that we can define
our own configureContainer() method.

00:02:34.886 --> 00:02:42.966 align:middle
Copy the configureContainer() signature from the
trait, paste, hit "OK" to add the use statements

00:02:43.816 --> 00:02:50.636 align:middle
and then call $this-&gt;baseConfigureContainer()
passing $container, $loader, and $builder.

00:02:51.576 --> 00:02:57.576 align:middle
The configureContainer() method in the trait is
responsible for loading services.yaml as well

00:02:57.576 --> 00:03:00.916 align:middle
as all of files inside config/packages/.

00:03:01.586 --> 00:03:05.316 align:middle
That's all good stuff that
we want to keep doing.

00:03:05.906 --> 00:03:13.986 align:middle
But after doing that, add one more thing:
$builder-&gt;registerExtension(new AppExtension()).

00:03:14.936 --> 00:03:18.386 align:middle
Again, yes, this is annoyingly technical.

00:03:18.876 --> 00:03:25.156 align:middle
But thanks to these two pieces, our
netgen_layouts.yaml config will be prepended.

00:03:26.046 --> 00:03:26.536 align:middle
Check it out!

00:03:26.886 --> 00:03:31.816 align:middle
Re-run the debug:config command
again scroll up and...

00:03:32.116 --> 00:03:35.426 align:middle
yes! Our configuration is now on top!

00:03:35.956 --> 00:03:37.676 align:middle
And when we refresh...

00:03:38.576 --> 00:03:40.976 align:middle
woohoo! We see the text!

00:03:41.816 --> 00:03:46.556 align:middle
Next: let's make this template render
exactly like the hardcoded skills.

00:03:46.976 --> 00:03:51.486 align:middle
Then we'll create a second item
template to customize how the Contentful

00:03:51.606 --> 00:03:54.036 align:middle
"Advertisement" content type renders.

