2015-05-02 11:32:45 +02:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
|
* PiggyBank.php
|
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
|
*
|
2016-10-05 06:52:15 +02:00
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
|
*
|
|
|
|
|
* See the LICENSE file for details.
|
2016-05-20 12:41:23 +02:00
|
|
|
*/
|
|
|
|
|
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2015-05-02 11:32:45 +02:00
|
|
|
|
|
|
|
|
namespace FireflyIII\Support\Twig;
|
|
|
|
|
|
2015-05-03 12:58:55 +02:00
|
|
|
use FireflyIII\Models\PiggyBank as PB;
|
2015-05-02 11:32:45 +02:00
|
|
|
use Twig_Extension;
|
|
|
|
|
use Twig_SimpleFunction;
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-29 09:23:39 +02:00
|
|
|
*
|
2015-05-02 11:32:45 +02:00
|
|
|
* Class PiggyBank
|
|
|
|
|
*
|
|
|
|
|
* @package FireflyIII\Support\Twig
|
|
|
|
|
*/
|
|
|
|
|
class PiggyBank extends Twig_Extension
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2016-04-05 22:00:03 +02:00
|
|
|
public function getFunctions(): array
|
2015-05-02 11:32:45 +02:00
|
|
|
{
|
|
|
|
|
$functions = [];
|
|
|
|
|
|
|
|
|
|
$functions[] = new Twig_SimpleFunction(
|
2015-06-06 23:09:12 +02:00
|
|
|
'currentRelevantRepAmount', function (PB $piggyBank) {
|
2015-05-02 11:32:45 +02:00
|
|
|
return $piggyBank->currentRelevantRep()->currentamount;
|
|
|
|
|
}
|
|
|
|
|
);
|
2015-05-03 12:58:55 +02:00
|
|
|
|
2017-02-24 22:00:49 +01:00
|
|
|
$functions[] = new Twig_SimpleFunction(
|
|
|
|
|
'suggestedMonthlyAmount', function (PB $piggyBank) {
|
2017-02-25 05:57:01 +01:00
|
|
|
return $piggyBank->getSuggestedMonthlyAmount();
|
2017-02-24 22:00:49 +01:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2015-05-02 11:32:45 +02:00
|
|
|
return $functions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the name of the extension.
|
|
|
|
|
*
|
|
|
|
|
* @return string The extension name
|
|
|
|
|
*/
|
2016-04-05 22:00:03 +02:00
|
|
|
public function getName(): string
|
2015-05-02 11:32:45 +02:00
|
|
|
{
|
|
|
|
|
return 'FireflyIII\Support\Twig\PiggyBank';
|
|
|
|
|
}
|
2015-05-05 12:51:57 +02:00
|
|
|
}
|