1818 * @license http://opensource.org/licenses/MIT The MIT License
1919 * @version 2.1
2020 */
21- class PicoTwigExtension extends Twig_Extension
21+ class PicoTwigExtension extends \ Twig \ Extension \AbstractExtension
2222{
2323 /**
2424 * Current instance of Pico
@@ -53,7 +53,7 @@ public function getPico()
5353 /**
5454 * Returns the name of the extension
5555 *
56- * @see Twig_ExtensionInterface ::getName()
56+ * @see \Twig\Extension\AbstractExtension ::getName()
5757 *
5858 * @return string the extension name
5959 */
@@ -65,38 +65,38 @@ public function getName()
6565 /**
6666 * Returns a list of Pico-specific Twig filters
6767 *
68- * @see Twig_ExtensionInterface ::getFilters()
68+ * @see \Twig\Extension\ExtensionInterface ::getFilters()
6969 *
70- * @return Twig_SimpleFilter [] array of Pico's Twig filters
70+ * @return \Twig\TwigFilter [] array of Pico's Twig filters
7171 */
7272 public function getFilters ()
7373 {
7474 return array (
75- 'markdown ' => new Twig_SimpleFilter (
75+ 'markdown ' => new \ Twig \ TwigFilter (
7676 'markdown ' ,
7777 array ($ this , 'markdownFilter ' ),
7878 array ('is_safe ' => array ('html ' ))
7979 ),
80- 'map ' => new Twig_SimpleFilter ('map ' , array ($ this , 'mapFilter ' )),
81- 'sort_by ' => new Twig_SimpleFilter ('sort_by ' , array ($ this , 'sortByFilter ' )),
82- 'link ' => new Twig_SimpleFilter ('link ' , array ($ this ->pico , 'getPageUrl ' )),
83- 'url ' => new Twig_SimpleFilter ('url ' , array ($ this ->pico , 'substituteUrl ' ))
80+ 'map ' => new \ Twig \ TwigFilter ('map ' , array ($ this , 'mapFilter ' )),
81+ 'sort_by ' => new \ Twig \ TwigFilter ('sort_by ' , array ($ this , 'sortByFilter ' )),
82+ 'link ' => new \ Twig \ TwigFilter ('link ' , array ($ this ->pico , 'getPageUrl ' )),
83+ 'url ' => new \ Twig \ TwigFilter ('url ' , array ($ this ->pico , 'substituteUrl ' ))
8484 );
8585 }
8686
8787 /**
8888 * Returns a list of Pico-specific Twig functions
8989 *
90- * @see Twig_ExtensionInterface ::getFunctions()
90+ * @see \Twig\Extension\ExtensionInterface ::getFunctions()
9191 *
92- * @return Twig_SimpleFunction [] array of Pico's Twig functions
92+ * @return \Twig\TwigFunction [] array of Pico's Twig functions
9393 */
9494 public function getFunctions ()
9595 {
9696 return array (
97- 'url_param ' => new Twig_SimpleFunction ('url_param ' , array ($ this , 'urlParamFunction ' )),
98- 'form_param ' => new Twig_SimpleFunction ('form_param ' , array ($ this , 'formParamFunction ' )),
99- 'pages ' => new Twig_SimpleFunction ('pages ' , array ($ this , 'pagesFunction ' ))
97+ 'url_param ' => new \ Twig \ TwigFunction ('url_param ' , array ($ this , 'urlParamFunction ' )),
98+ 'form_param ' => new \ Twig \ TwigFunction ('form_param ' , array ($ this , 'formParamFunction ' )),
99+ 'pages ' => new \ Twig \ TwigFunction ('pages ' , array ($ this , 'pagesFunction ' ))
100100 );
101101 }
102102
@@ -136,12 +136,12 @@ public function markdownFilter($markdown, array $meta = array(), $singleLine = f
136136 *
137137 * @return array mapped values
138138 *
139- * @throws Twig_Error_Runtime
139+ * @throws \Twig\Error\RuntimeError
140140 */
141141 public function mapFilter ($ var , $ mapKeyPath )
142142 {
143143 if (!is_array ($ var ) && (!is_object ($ var ) || !($ var instanceof Traversable))) {
144- throw new Twig_Error_Runtime (sprintf (
144+ throw new \ Twig \ Error \ RuntimeError (sprintf (
145145 'The map filter only works with arrays or "Traversable", got "%s" ' ,
146146 is_object ($ var ) ? get_class ($ var ) : gettype ($ var )
147147 ));
@@ -178,20 +178,20 @@ public function mapFilter($var, $mapKeyPath)
178178 *
179179 * @return array sorted array
180180 *
181- * @throws Twig_Error_Runtime
181+ * @throws \Twig\Error\RuntimeError
182182 */
183183 public function sortByFilter ($ var , $ sortKeyPath , $ fallback = 'bottom ' )
184184 {
185185 if (is_object ($ var ) && ($ var instanceof Traversable)) {
186186 $ var = iterator_to_array ($ var , true );
187187 } elseif (!is_array ($ var )) {
188- throw new Twig_Error_Runtime (sprintf (
188+ throw new \ Twig \ Error \ RuntimeError (sprintf (
189189 'The sort_by filter only works with arrays or "Traversable", got "%s" ' ,
190190 is_object ($ var ) ? get_class ($ var ) : gettype ($ var )
191191 ));
192192 }
193193 if (($ fallback !== 'top ' ) && ($ fallback !== 'bottom ' ) && ($ fallback !== 'keep ' ) && ($ fallback !== "remove " )) {
194- throw new Twig_Error_Runtime (
194+ throw new \ Twig \ Error \ RuntimeError (
195195 'The sort_by filter only supports the "top", "bottom", "keep" and "remove" fallbacks '
196196 );
197197 }
@@ -399,7 +399,7 @@ public function formParamFunction($name, $filter = '', $options = null, $flags =
399399 * returns Pico's full pages array.
400400 *
401401 * If `$depth` is negative after taking `$offset` into consideration, the
402- * function will throw a {@see Twig_Error_Runtime } exception, since this
402+ * function will throw a {@see \Twig\Error\RuntimeError } exception, since this
403403 * would simply make no sense and is likely an error. Passing a negative
404404 * `$depthOffset` is equivalent to passing `$depthOffset = 0`.
405405 *
@@ -421,7 +421,7 @@ public function formParamFunction($name, $filter = '', $options = null, $flags =
421421 *
422422 * @return array[] the data of the matched pages
423423 *
424- * @throws Twig_Error_Runtime
424+ * @throws \Twig\Error\RuntimeError
425425 */
426426 public function pagesFunction ($ start = '' , $ depth = 0 , $ depthOffset = 0 , $ offset = 1 )
427427 {
@@ -443,7 +443,7 @@ public function pagesFunction($start = '', $depth = 0, $depthOffset = 0, $offset
443443 $ depthOffset = $ depthOffset + $ offset ;
444444
445445 if (($ depth !== null ) && ($ depth < 0 )) {
446- throw new Twig_Error_Runtime ('The pages function doesn \'t support negative depths ' );
446+ throw new \ Twig \ Error \ RuntimeError ('The pages function doesn \'t support negative depths ' );
447447 }
448448
449449 $ pageTree = $ this ->getPico ()->getPageTree ();
0 commit comments