-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
6 changed files
with
149 additions
and
10 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,56 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\MemberBundle\Twig; | ||
|
||
use DMKClub\Bundle\MemberBundle\Provider\MemberStatusProvider; | ||
|
||
class MemberExtension extends \Twig_Extension | ||
{ | ||
/** | ||
* @var MemberStatusProvider | ||
*/ | ||
protected $statusProvider; | ||
|
||
/** | ||
* @param MemberStatusProvider $statusProvider | ||
*/ | ||
public function __construct(MemberStatusProvider $statusProvider) | ||
{ | ||
$this->statusProvider = $statusProvider; | ||
} | ||
|
||
/** | ||
* Returns a list of functions to add to the existing list. | ||
* | ||
* @return array An array of functions | ||
*/ | ||
public function getFunctions() | ||
{ | ||
return array( | ||
'dmkclub_memberstatus' => new \Twig_Function_Method($this, 'getMemberStatusLabel'), | ||
); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return string | ||
*/ | ||
public function getMemberStatusLabel($name) | ||
{ | ||
if (!$name) { | ||
return null; | ||
} | ||
|
||
return $this->statusProvider->getLabelByName($name); | ||
} | ||
|
||
/** | ||
* Returns the name of the extension. | ||
* | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return 'dmkclub_member'; | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
src/DMKClub/Bundle/PaymentBundle/Resources/config/services.yml
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
parameters: | ||
dmkclub.payment.options_provider.class: DMKClub\Bundle\PaymentBundle\Provider\PaymentOptionsProvider | ||
dmkclub.payment.options_provider.class: DMKClub\Bundle\PaymentBundle\Provider\PaymentOptionsProvider | ||
dmkclub.payment.twig.class: DMKClub\Bundle\PaymentBundle\Twig\PaymentExtension | ||
services: | ||
dmkclub.payment.options_provider: | ||
class: "%dmkclub.payment.options_provider.class%" | ||
arguments: | ||
- @translator | ||
- "@translator" | ||
dmkclub.payment.twig.extension: | ||
class: "%dmkclub.payment.twig.class%" | ||
arguments: ["@dmkclub.payment.options_provider"] | ||
tags: | ||
- { name: twig.extension } | ||
|
56 changes: 56 additions & 0 deletions
56
src/DMKClub/Bundle/PaymentBundle/Twig/PaymentExtension.php
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,56 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\PaymentBundle\Twig; | ||
|
||
use DMKClub\Bundle\PaymentBundle\Provider\PaymentOptionsProvider; | ||
|
||
class PaymentExtension extends \Twig_Extension | ||
{ | ||
/** | ||
* @var MemberStatusProvider | ||
*/ | ||
protected $paymentOptionProvider; | ||
|
||
/** | ||
* @param MemberStatusProvider $paymentOptionProvider | ||
*/ | ||
public function __construct(PaymentOptionsProvider $paymentOptionProvider) | ||
{ | ||
$this->paymentOptionProvider = $paymentOptionProvider; | ||
} | ||
|
||
/** | ||
* Returns a list of functions to add to the existing list. | ||
* | ||
* @return array An array of functions | ||
*/ | ||
public function getFunctions() | ||
{ | ||
return array( | ||
'dmkclub_paymentoption' => new \Twig_Function_Method($this, 'getPaymentOptionLabel'), | ||
); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return string | ||
*/ | ||
public function getPaymentOptionLabel($name) | ||
{ | ||
if (!$name) { | ||
return null; | ||
} | ||
|
||
return $this->paymentOptionProvider->getLabelByName($name); | ||
} | ||
|
||
/** | ||
* Returns the name of the extension. | ||
* | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return 'dmkclub_payment'; | ||
} | ||
} |
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