スポンサーサイト
一定期間更新がないため広告を表示しています
- 2014.12.23 Tuesday
- -
- -
- -
- -
- -
- by スポンサードリンク
public function getMonthlyAmount($year, $month)支店一覧テンプレートの各行で下記のように呼び出せばいい。
{
return Doctrine::getTable('売上')->getMonthlyAmount($this->getId(), $year, $month);
}
<?php foreach ($pager->getResults() as $branch): ?>
<tr>
<td><?php echo $branch->getName(); ?></td>
//略…ここに支店の所在地とか電話番号とか
<td><?php echo $branch->getMonthlyAmount(); ?></td>
//略…ここに編集ボタンとか詳細ボタンとか削除ボタン辺り。
</tr>
<?php endforeach; ?>
namespace My¥CoolBundle¥Twig¥Extension;#My/CoolBundle/Resources/config/services.yml
class BadKnowHowExtension extends ¥Twig_Extension
{
private $em;
public function __construct($doctrine)
{
$this->em = $doctrine->getEntityManager();
}
public function getName()
{
//他と被らなければ何を入れてもOK
return 'bad_knowhow';
}
public function getFunctions()
{
return array(
'monthly_uriage' => new ¥Twig_Function_Method($this, 'calculateMonthlyAmount'),
);
}
public function calculateMonthlyAmount($branch, $year, $month)
{
return $em->getRepository('MyCoolBundle:売上')->calculateMonthlyAmountForBranch($branch->getId(), $year, $month);
}
}
services:
my.cool_bundle.twig.bad_knowhow_extension:
class: My¥CoolBundle¥Twig¥Extension¥BadKnowHowExtension
arguments:
- @doctrine
tags:
- { name: twig.extension }
{% for branch in list %}
<tr>
<td>{{ branch.name }}</td>
//略
<td>{{ monthly_uriage(branch, year, month) }}</td>
//略
</tr>
{% endfor %}
// Get the security firewall name, login
$providerKey = $this->container->getParameter('fos_user.firewall_name');
$token = new UsernamePasswordToken($user, $password, $providerKey, $user->getRoles());
$this->get("security.context")->setToken($token);
// Fire the login event
$event = new InteractiveLoginEvent($this->getRequest(), $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);