dwr/lottoclient-bundle

Symfony2 扩展包,帮助连接到波兰彩票服务器(Totalizator sportowy)。

1.0 2015-08-06 21:27 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:53:06 UTC


README

Build Status Scrutinizer Code Quality

DwrLottoClient

此扩展包帮助获取波兰国家彩票的结果

安装

安装是一个快速的三步过程

  1. 使用 composer 下载 DwrLottoClientBundle。
  2. 启用扩展包。
  3. 在控制器中使用扩展包。

步骤 1:使用 composer 下载 DwrAvatarBundle

在 composer.json 中添加 DwrGlobalWeatherBundle

{
    "require": {
        "dwr/lottoclient-bundle": "1.0"
    }
}

运行以下命令下载扩展包

$ php composer.phar require dwr/lottoclient-bundle

Composer 将将扩展包安装到项目的 vendor/dwr/lottoclient-bundle 目录。

步骤 2:启用扩展包

在 kernel 中启用扩展包

//app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Dwr\LottoClientBundle\DwrLottoClientBundle(),
    );
}

步骤 3:在控制器中使用扩展包

    
    use Dwr\LottoClientBundle\Service\LottoClient; //don't forget add this line above class declaration
   

    /**
     * @Route("/", name="homepage")
     */
    public function indexAction()
    {

        $lotto = $this->get('dwr_lotto_client');
        $resultsDL = $lotto->getRecentlyResults(LottoClient::DUZY_LOTEK, 1); //takes last result from Duży lotek
        $resultsK  = $lotto->getRecentlyResults(LottoClient::KASKADA, 5); //takes 5 recently results from Kaskada
        
        var_dump($resultsDL);
        var_dump($resultsK);

        $date = new \DateTime('2014-10-10');
        $resultMINI = $lotto->getResultsByDate($date, LottoClient::MINI_LOTEK, 2); //takes 2 recently results from giving date for Mini Lotek
        $resultMULTI = $lotto->getResultsByDate($date, LottoClient::MULTI_LOTEK, 3); //takes 3 recently results from giving date for Multi Lotek

        var_dump($resultMINI);
        var_dump($resultMULTI);

        return $this->render('default/index.html.twig');
    }

恭喜! 您现在可以将彩票结果嵌入到 symfony2 应用程序中。

用法

在控制器中添加以下代码

    use Dwr\LottoClientBundle\Service\LottoClient; //don't forget add this line above class declaration

    /**
     * @Route("/", name="homepage")
     */
    public function indexAction()
    {

        $lotto = $this->get('dwr_lotto_client');
        
        /**
         * In order to take last result from Duży lotek pass 1 as a second argument for getRecentlyResults method.
         * Maximum you can take 10 recently results.
         */
        $resultsDL = $lotto->getRecentlyResults(LottoClient::DUZY_LOTEK, 1);
        var_dump($resultsDL); 
        
        /**
         * In order to take archive results use getResultsByDate method.
         * Specify date (e.g. new \DateTime('2014-10-10')) and pass it as first argument.
         */
        $date = new \DateTime('2014-10-10');
        $resultMINI = $lotto->getResultsByDate($date, LottoClient::MINI_LOTEK, 2);
        var_dump($resultMINI);
    }

可用的彩票类型

LottoClient::DUZY_LOTEK
LottoClient::MINI_LOTEK
LottoClient::MULTI_LOTEK
LottoClient::JOKER
LottoClient::KASKADA