WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.086 --> 00:00:05.336 align:middle
We now have a fully-functional
new class with a test!

00:00:05.886 --> 00:00:10.386 align:middle
But, we have not registered
this class as a service yet.

00:00:11.026 --> 00:00:11.636 align:middle
Which means...

00:00:11.636 --> 00:00:15.026 align:middle
the user would still need to do that manually.

00:00:15.556 --> 00:00:16.926 align:middle
That's a bummer!

00:00:18.066 --> 00:00:19.266 align:middle
Inside SecurityBundle,

00:00:19.516 --> 00:00:25.166 align:middle
look at DependencyInjection
and open SecurityExtension.php.

00:00:25.166 --> 00:00:31.096 align:middle
This class loads several XML files that
provide all of the services for this bundle.

00:00:32.646 --> 00:00:36.896 align:middle
Inside the Resources/config/
directory, open security.xml.

00:00:36.896 --> 00:00:41.286 align:middle
Around line 136...

00:00:41.516 --> 00:00:46.016 align:middle
yep! You'll see the services
that our new service depends on -

00:00:46.386 --> 00:00:50.686 align:middle
like FirewallMap and FirewallConfig.

00:00:51.936 --> 00:00:59.526 align:middle
To register our new TargetPathHelper as a
service, we could include some XML config in any

00:00:59.596 --> 00:01:03.386 align:middle
of these XML files: it doesn't
technically matter.

00:01:03.786 --> 00:01:05.866 align:middle
But, which file makes the most sense?

00:01:06.586 --> 00:01:09.456 align:middle
Well, 1 minute ago, I wasn't sure.

00:01:10.016 --> 00:01:13.466 align:middle
But now that I see all of
these related services,

00:01:13.976 --> 00:01:16.546 align:middle
I think we've already found the right place.

00:01:16.546 --> 00:01:21.866 align:middle
If we're wrong, someone will
tell us when we create the PR.

00:01:21.866 --> 00:01:23.266 align:middle
Add a new service tag.

00:01:24.626 --> 00:01:29.176 align:middle
For the id, how about,
security.target_path_helper.

00:01:29.176 --> 00:01:34.736 align:middle
I'm trying to follow the existing
naming conventions in this file.

00:01:34.736 --> 00:01:41.376 align:middle
For the class, it's Symfony, well,
let's cheat: copy the namespace

00:01:41.376 --> 00:01:46.426 align:middle
from the class above, paste,
then TargetPathHelper.

00:01:51.106 --> 00:01:58.066 align:middle
Inside, our service will need 3 arguments:
the session, firewall map &amp; request stack.

00:01:59.276 --> 00:02:04.176 align:middle
Add &lt;argument type="service" id="session" /&gt;.

00:02:07.846 --> 00:02:14.476 align:middle
Next, &lt;argument type="service" id="" The id

00:02:14.476 --> 00:02:19.836 align:middle
for the firewall map is up
here: security.firewall.map.

00:02:24.026 --> 00:02:29.566 align:middle
Finally, &lt;argument type="service"
id="request_stack" /&gt;.

00:02:30.906 --> 00:02:35.826 align:middle
Done! Our new class is now
registered as a service!

00:02:36.356 --> 00:02:40.706 align:middle
But... there's still one small
thing missing with this service.

00:02:41.886 --> 00:02:48.206 align:middle
To allow TargetPathHelper to be autowired,
like FirewallMap in the issue example,

00:02:48.506 --> 00:02:55.856 align:middle
we need to create an alias from that class to
the service id - just like in the comment below.

00:02:57.246 --> 00:03:05.876 align:middle
To do this, add &lt;service id="" /&gt;, go
copy the class name, and paste it here.

00:03:07.206 --> 00:03:13.206 align:middle
Then, alias="", copy the service
id this time, and paste again.

00:03:14.476 --> 00:03:15.066 align:middle
That's it!

00:03:15.546 --> 00:03:19.796 align:middle
The TargetPathHelper will now
be an autowireable service.

00:03:20.416 --> 00:03:21.846 align:middle
And... we're done!

00:03:22.646 --> 00:03:28.956 align:middle
The last thing I'd recommend is to create a
real project and test your new feature manually.

00:03:29.906 --> 00:03:32.596 align:middle
Sure, our class has a test...

00:03:32.956 --> 00:03:35.966 align:middle
but there is not a test for our service config:

00:03:35.966 --> 00:03:40.486 align:middle
if we have a typo on the
class name, we wouldn't know!

00:03:41.046 --> 00:03:44.786 align:middle
However, because we already
went through the process earlier

00:03:45.106 --> 00:03:47.496 align:middle
when testing Colin's PR, I'll skip it.

00:03:48.216 --> 00:03:53.836 align:middle
But, saying you tested your code in a real
app can definitely help push your PR forward.

00:03:54.976 --> 00:03:57.156 align:middle
Hey! We're done with all the hard work!

00:03:57.566 --> 00:03:59.146 align:middle
Let's push our code to GitHub!

00:04:00.116 --> 00:04:06.236 align:middle
Head over to the terminal that's in the symfony/
directory and run: git status No surprises!

00:04:06.866 --> 00:04:09.846 align:middle
Add everything and then commit
with a nice message

00:04:10.046 --> 00:04:15.936 align:middle
that briefly describes what we're doing: Cool!

00:04:16.926 --> 00:04:24.136 align:middle
Right now, we have two remotes: colinodell
&amp; origin, which is the main symfony/symfony.

00:04:24.616 --> 00:04:29.356 align:middle
But, of course, we don't have
access to push directly to origin.

00:04:30.266 --> 00:04:35.676 align:middle
Actually, that's great - that sounds
like way too much responsibility to me.

00:04:36.686 --> 00:04:40.906 align:middle
Instead of pushing directly to
Symfony, we need to fork the repository.

00:04:41.946 --> 00:04:45.856 align:middle
Click "Fork" and either create a new fork, or,

00:04:45.856 --> 00:04:49.236 align:middle
if you already have a fork
like me, click into it.

00:04:49.746 --> 00:04:52.136 align:middle
Here we are: weaverryan/symfony.

00:04:54.076 --> 00:05:00.836 align:middle
Next, click "Clone or download", copy the URL,
then move back over to the terminal to add this

00:05:00.836 --> 00:05:08.086 align:middle
as a new remote: git remote add
weaverryan and then paste: Awesome!

00:05:08.456 --> 00:05:09.966 align:middle
Now we can push.

00:05:10.876 --> 00:05:13.446 align:middle
The branch we created is
called target-path-helper.

00:05:14.246 --> 00:05:20.946 align:middle
So: git push weaverryan target-path-helper
Back to GitHub!

00:05:21.046 --> 00:05:26.586 align:middle
If you're lucky, you'll see a little
yellow banner about your new branch.

00:05:27.386 --> 00:05:32.066 align:middle
This banner doesn't always show up,
so if it doesn't, you can refresh,

00:05:33.706 --> 00:05:39.206 align:middle
find the target-path-helper branch
and click "New pull request".

00:05:41.276 --> 00:05:48.586 align:middle
Next, let's fill this in &amp; learn about Symfony's
continuous integration system and the famous...

00:05:48.836 --> 00:05:49.866 align:middle
fabbot!

