Skip to content

Commit

Permalink
Fixed a minor taxonomy issue and added comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raistlfiren committed May 25, 2016
1 parent 6664033 commit 9e1d4e4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/TaxonomyListExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@

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 [
Expand All @@ -27,6 +34,9 @@ protected function getDefaultConfig()
];
}

/**
* @return array
*/
protected function registerTwigFunctions()
{
$app = $this->getContainer();
Expand All @@ -39,7 +49,9 @@ protected function registerTwigFunctions()
];
}


/**
* @param Application $app
*/
protected function registerServices(Application $app)
{
$app['taxonomylist.twig'] = $app->share(
Expand All @@ -51,6 +63,11 @@ function ($app) {
);
}

/**
* @param Application $app
* @param Request $request
* @return Response
*/
public function taxonomies(Application $app, Request $request)
{
$config = $this->getConfig();
Expand Down
18 changes: 17 additions & 1 deletion src/Twig/TaxonomyListExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ public function __construct(array $config, Application $app)

/**
* Return an array with items in a taxonomy
*
* @param bool $name
* @param bool $params
* @return null
*/
public function twigTaxonomyList($name = false, $params = false)
{
// if $name isn't set, use the one from the config.yml. Unless that's empty too, then use "tags".
$name = $this->config['default_taxonomy'];
if (empty($name)) {
if (!empty($this->config['default_taxonomy'])) {
$name = $this->config['default_taxonomy'];
} else {
$name = "tags";
}
}

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

Expand Down Expand Up @@ -70,6 +80,12 @@ public function twigTaxonomyList($name = false, $params = false)

/**
* Get the full taxonomy data from the database, count all occurences of a certain taxonomy name
*
* @param null $name
* @param null $taxonomy
* @param null $params
* @return null
* @throws \Doctrine\DBAL\DBALException
*/
protected function getFullTaxonomy($name = null, $taxonomy = null, $params = null)
{
Expand Down

0 comments on commit 9e1d4e4

Please sign in to comment.