From 3cb4e74448996484a9eb28bd5308a618998decc4 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 28 Mar 2016 19:11:12 +0100 Subject: [PATCH] Add AppBundle and the YouTube and Vimeo Twig functions --- app/SculpinKernel.php | 3 +- composer.json | 5 +++ .../2012-09-05-what-is-this-drupal-thing.md | 2 +- source/_talks/2014-03-01-git-flow.md | 2 +- source/_talks/2015-04-08-drupal-8.md | 2 +- source/_talks/2015-10-14-sculpin.md | 2 +- src/AppBundle/AppBundle.php | 9 ++++ .../DependencyInjection/AppExtension.php | 20 +++++++++ src/AppBundle/Twig/VimeoExtension.php | 41 +++++++++++++++++ src/AppBundle/Twig/YouTubeExtension.php | 44 +++++++++++++++++++ src/AppBundle/config/services.yml | 9 ++++ 11 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 src/AppBundle/AppBundle.php create mode 100644 src/AppBundle/DependencyInjection/AppExtension.php create mode 100644 src/AppBundle/Twig/VimeoExtension.php create mode 100644 src/AppBundle/Twig/YouTubeExtension.php create mode 100644 src/AppBundle/config/services.yml diff --git a/app/SculpinKernel.php b/app/SculpinKernel.php index 1780f6ee..7c58c926 100644 --- a/app/SculpinKernel.php +++ b/app/SculpinKernel.php @@ -14,7 +14,8 @@ class SculpinKernel extends AbstractKernel { return [ 'Tsphethean\Sculpin\Bundle\RelatedPostsBundle\SculpinRelatedPostsBundle', - 'Opdavies\Sculpin\Bundle\ContentGeneratorBundle\SculpinContentGeneratorBundle' + 'Opdavies\Sculpin\Bundle\ContentGeneratorBundle\SculpinContentGeneratorBundle', + 'AppBundle\AppBundle' ]; } } diff --git a/composer.json b/composer.json index f68a3342..f89fb927 100644 --- a/composer.json +++ b/composer.json @@ -19,5 +19,10 @@ "behat/mink-extension": "*", "behat/mink-goutte-driver": "*", "opdavies/sculpin-content-generator-bundle": "@stable" + }, + "autoload": { + "psr-4": { + "AppBundle\\": "src/AppBundle" + } } } diff --git a/source/_talks/2012-09-05-what-is-this-drupal-thing.md b/source/_talks/2012-09-05-what-is-this-drupal-thing.md index e311bbce..f32f5b97 100644 --- a/source/_talks/2012-09-05-what-is-this-drupal-thing.md +++ b/source/_talks/2012-09-05-what-is-this-drupal-thing.md @@ -14,5 +14,5 @@ tags: - unified-diff --- {% block video %} - +{{ vimeo('49827006')|raw }} {% endblock %} diff --git a/source/_talks/2014-03-01-git-flow.md b/source/_talks/2014-03-01-git-flow.md index 7137ea19..664925cb 100644 --- a/source/_talks/2014-03-01-git-flow.md +++ b/source/_talks/2014-03-01-git-flow.md @@ -22,7 +22,7 @@ tweets: yes {% endblock %} {% block video %} - +{{ youtube('T-miCpHxfds')|raw }} {% endblock %} {% block feedback %} diff --git a/source/_talks/2015-04-08-drupal-8.md b/source/_talks/2015-04-08-drupal-8.md index c4d93ec2..a2e7cb86 100644 --- a/source/_talks/2015-04-08-drupal-8.md +++ b/source/_talks/2015-04-08-drupal-8.md @@ -27,7 +27,7 @@ I categorised the technical changes into groups for site builders, developers an {% endblock %} {% block video %} - +{{ youtube('36zCxPrOOzM')|raw }} {% endblock %} {% block feedback %} diff --git a/source/_talks/2015-10-14-sculpin.md b/source/_talks/2015-10-14-sculpin.md index a6be312a..f85609e9 100644 --- a/source/_talks/2015-10-14-sculpin.md +++ b/source/_talks/2015-10-14-sculpin.md @@ -28,7 +28,7 @@ You can [view the full slides](/slides/phpsw/building-static-websites-with-sculp {% endblock %} {% block video %} - +{{ youtube('aN53arCKZAU')|raw }} {% endblock %} {% block feedback %} diff --git a/src/AppBundle/AppBundle.php b/src/AppBundle/AppBundle.php new file mode 100644 index 00000000..05123b67 --- /dev/null +++ b/src/AppBundle/AppBundle.php @@ -0,0 +1,9 @@ +load('services.yml'); + } +} diff --git a/src/AppBundle/Twig/VimeoExtension.php b/src/AppBundle/Twig/VimeoExtension.php new file mode 100644 index 00000000..6791988e --- /dev/null +++ b/src/AppBundle/Twig/VimeoExtension.php @@ -0,0 +1,41 @@ +', + $videoId + ); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'vimeo'; + } + +} diff --git a/src/AppBundle/Twig/YouTubeExtension.php b/src/AppBundle/Twig/YouTubeExtension.php new file mode 100644 index 00000000..80bba926 --- /dev/null +++ b/src/AppBundle/Twig/YouTubeExtension.php @@ -0,0 +1,44 @@ +', + $videoId + ); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'youtube'; + } + +} diff --git a/src/AppBundle/config/services.yml b/src/AppBundle/config/services.yml new file mode 100644 index 00000000..d3ea9bff --- /dev/null +++ b/src/AppBundle/config/services.yml @@ -0,0 +1,9 @@ +services: + app.twig.vimeo: + class: AppBundle\Twig\VimeoExtension + tags: + - { name: twig.extension } + app.twig.youtube: + class: AppBundle\Twig\YouTubeExtension + tags: + - { name: twig.extension }