Skip to content

Commit

Permalink
Merge branch 'Raistlfiren-v3.0' into v3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jadwigo committed May 25, 2016
2 parents 4c3da52 + 9e1d4e4 commit 140e87d
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 120 deletions.
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"tagclouds"
],
"require": {
"bolt/bolt": ">=2.0.0,<3.0.0"
"bolt/bolt": "^3.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Lodewijk Evers",
Expand All @@ -22,16 +24,11 @@
}
],
"autoload": {
"files": [
"init.php"
],
"psr-4" : {
"Bolt\\Extension\\Jadwigo\\TaxonomyList\\" : ""
"Bolt\\Extension\\Jadwigo\\TaxonomyList\\" : "src"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0.*"
}
"bolt-class": "Bolt\\Extension\\Jadwigo\\TaxonomyList\\TaxonomyListExtension"
}
}
2 changes: 1 addition & 1 deletion config.yml.dist → config/config.yml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# taxonomylist settings

template: assets/taxonomylist.twig
template: taxonomylist.twig

default_taxonomy: tags
route_path: /taxonomies
5 changes: 0 additions & 5 deletions init.php

This file was deleted.

86 changes: 86 additions & 0 deletions src/TaxonomyListExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
// Taxonomy listing Extension for Bolt, by Lodewijk Evers

namespace Bolt\Extension\Jadwigo\TaxonomyList;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Silex\ControllerCollection;
use Bolt\Extension\SimpleExtension;
use Silex\Application;

class TaxonomyListExtension extends SimpleExtension
{

/**
* @param ControllerCollection $collection
*/
protected function registerFrontendRoutes(ControllerCollection $collection)
{
$config = $this->getConfig();

$collection->match($config['route_path'], [$this, 'taxonomies']);
}

/**
* @return array
*/
protected function getDefaultConfig()
{
return [
'template' => 'taxonomylist.twig',
'default_taxonomy' => 'tags',
'route_path' => '/taxonomies'
];
}

/**
* @return array
*/
protected function registerTwigFunctions()
{
$app = $this->getContainer();

return [
'taxonomylist' => [
[$app['taxonomylist.twig'], 'twigTaxonomyList'],

]
];
}

/**
* @param Application $app
*/
protected function registerServices(Application $app)
{
$app['taxonomylist.twig'] = $app->share(
function ($app) {
$config = $app['extensions']->get('Jadwigo/TaxonomyList')->getConfig();

return new \Bolt\Extension\Jadwigo\TaxonomyList\Twig\TaxonomyListExtension($config, $app);
}
);
}

/**
* @param Application $app
* @param Request $request
* @return Response
*/
public function taxonomies(Application $app, Request $request)
{
$config = $this->getConfig();

$taxonomy = $app['config']->get('taxonomy');
$taxonomies = array_keys($taxonomy);

$template = $config['template'];

$body = $this->renderTemplate($template, [
'taxonomies' => $taxonomies
]);

return new Response($body);
}
}
Loading

0 comments on commit 140e87d

Please sign in to comment.