Skip to content

Commit

Permalink
Started work on extension for v3 update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raistlfiren committed May 24, 2016
1 parent f2439b6 commit 028f1ef
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions src/TaxonomyListExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,37 @@

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Silex\ControllerCollection;
use Bolt\Extension\SimpleExtension;
use Silex\Application;
use Bolt\Extensions\Snippets\Location as SnippetLocation;

class TaxonomyListExtension extends \Bolt\BaseExtension
class TaxonomyListExtension extends SimpleExtension
{
const NAME = 'TaxonomyList';
/**
* Provide default Extension Name
*/

public function getName()
protected function registerFrontendRoutes(ControllerCollection $collection)
{
return Extension::NAME;
$config = $this->getConfig();

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

/**
* Initialize TaxonomyList. Called during bootstrap phase.
*/
public function initialize()
protected function getDefaultConfig()
{
if ($this->app['config']->getWhichEnd() == 'frontend') {
// Add Twig functions
if (empty($this->config['default_taxonomy'])) {
$this->config['default_taxonomy'] = 'tags';
}

if (empty($this->config['route_path'])) {
$this->config['route_path'] = '/taxonomies';
}

// Set up the routes for the sitemap..
$this->app->match($this->config['route_path'], array($this, 'taxonomies'));

$this->addTwigFunction('taxonomylist', 'twigTaxonomyList');
}
return [
'template' => 'taxonomylist.twig',
'default_taxonomy' => 'tags',
'route_path' => '/taxonomies'
];
}

protected function registerTwigFunctions()
{
return [
'taxonomylist' => 'twigTaxonomyList'
];
}

public function taxonomies($xml = false)
public function taxonomies(Application $app, Request $request, $xml = false)
{
$taxonomy = $this->app['config']->get('taxonomy');
$taxonomies = array_keys($taxonomy);
Expand Down

0 comments on commit 028f1ef

Please sign in to comment.