-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Raistlfiren-v3.0' into v3.x
- Loading branch information
Showing
6 changed files
with
155 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.