-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Vandemaele
committed
Apr 3, 2018
1 parent
3dd599b
commit 6fe1701
Showing
3 changed files
with
85 additions
and
6 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
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,46 @@ | ||
<?php | ||
/** | ||
* Additional functions and filters for Twig | ||
* | ||
* @author David Vandemaele <[email protected]> | ||
*/ | ||
|
||
namespace Skeleton\Vat\Check\Twig\Extension\Vat; | ||
|
||
class Check extends \Twig_Extension { | ||
|
||
/** | ||
* Returns a list of functions | ||
* | ||
* @return array | ||
*/ | ||
public function getFunctions() { | ||
return array( | ||
new \Twig_SimpleFunction('example_vat', array($this, 'get_example_vat'), array('is_safe' => array('html'))) | ||
); | ||
} | ||
|
||
/** | ||
* Function get example vat | ||
* | ||
* @param string $vat_code | ||
* @return string $output | ||
*/ | ||
public function get_example_vat($vat_code) { | ||
$vat_code = strtoupper($vat_code); | ||
if (!isset(\Skeleton\Vat\Check\Config::$example_vat[$vat_code])) { | ||
return 'unknown'; | ||
} | ||
|
||
return \Skeleton\Vat\Check\Config::$example_vat[$vat_code]; | ||
} | ||
|
||
/** | ||
* Name of this extension | ||
* | ||
* @return string | ||
*/ | ||
public function getName() { | ||
return 'Twig_Extension_Vat_Check'; | ||
} | ||
} |