Issue #2222817 by dasjo, rv0: Rename alter hook for external coders.
[project/facetapi_pretty_paths.git] / plugins / coders / facetapi_pretty_paths_coder_taxonomy.inc
1 <?php
2
3 /**
4 * @file
5 * A taxonomy specific coder for pretty paths.
6 */
7
8 /**
9 * Taxonomy specific implementation of FacetApiPrettyPathsCoder.
10 */
11 class FacetApiPrettyPathsCoderTaxonomy extends FacetApiPrettyPathsCoderDefault {
12
13 /**
14 * Taxonomy special case: <alias>/<term-name>-<term-id>
15 *
16 * @see FacetApiPrettyPathsCoderDefault::encodePathSegment()
17 */
18 public function encodePathSegment(array $args) {
19 if ($term = taxonomy_term_load($args['segment']['value'])) {
20 $args['segment']['value'] = $this->prettyPath($term->name) . '-' . $term->tid;
21 }
22 return parent::encodePathSegment($args);
23 }
24
25 /**
26 * Taxonomy special case: <alias>/<term-name>-<term-id>
27 *
28 * @see FacetApiPrettyPathsCoderDefault::decodePathSegmentValue()
29 */
30 public function decodePathSegmentValue(array $args) {
31 $exploded = explode('-', $args['value']);
32 $args['value'] = array_pop($exploded);
33 return parent::decodePathSegmentValue($args);
34 }
35 }