FDuhPokerBundle
Installation
Add the dependency:, (*1)
$ composer require fduh/poker-bundle dev-master
Add the bundle:, (*2)
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Fduh\PokerBundle\FduhPokerBundle(),
// Optional, for Google Chart
new SaadTazi\GChartBundle\SaadTaziGChartBundle(),
);
}
}
How to use
Results Handler
After you created some seasons, events and results, you now want to manage players, rankings and scores. Here's how to
use the bundle:, (*3)
$resultsHandler = $this->get('poker.results_handler');
// Add events
$resultsHandler->addEvents($yourEvents);
// Or a season
$resultsHandler->addSeason($yourSeason);
Of course, you can retrieve events by using:, (*4)
// Reduces requests count
$events = $this->get('poker.repository.hydrated.event')->findAllViewableEventsByDateAsc();
Now there's how you should use the results handler in your template:, (*5)
{% for eventData in resultsHandler.eventManager.eventsData %}
{{ eventData.event }} // Access to the Event entity
{# And other functions... #}
{% endfor %}
{% for playerData in resultsHandler.playerManager.playersData %}
{{ playerData.player }} // Access to the Player entity
{{ playerData.score }}
{{ playerData.rank }}
{{ playerData.wonEvents }}
{# And a lot of functions... #}
{% endfor %}
Open PlayerDataInterface.php and EventDataInterface.php to read more about provided properties., (*6)
Watch a practical example at standrewspokerclub.fr., (*7)
Chart
If you want to display score evolution (in controller):, (*8)
$chartMaker = $this->get('poker.chart_maker');
$chartMaker->setSeason($season);
$chart = $chartMaker->getChart();
return array(
'chart' => $chart->toArray(),
'width' => $chartMaker->getWidth(),
'height' => $chartMaker->getHeight()
// ...
}
And in the template (mine for the example):, (*9)
<script>
$(function() {
{{ gchart_line_chart(chart, 'chart', width, height, null,
{ // your options }
)
}}
});
</script>
Watch a practical example at standrewspokerclub.fr., (*10)
Configuration
Reference dump:, (*11)
fduh_poker:
calculation_class: ~
If you want the bundle to calculate scores differently, override the calculation_class with a class implementing
Fduh\PokerBundle\Calculator\CalculationStrategyInterface., (*12)
Run this command to recalculate every score:, (*13)
$ php app/console poker:update-scores
To do
- TwigExtensions
- a lot of things.....
Feel free to contribute this project., (*14)