定制 th3mouk/yahoo-weather-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

th3mouk/yahoo-weather-bundle

Composer 安装命令:

composer require th3mouk/yahoo-weather-bundle

包简介

Symfony bundle that include Yahoo Weather API and archive datas in database.

README 文档

README

This Symfony bundle providing communication and historian of Yahoo Weather API.

SensioLabsInsight Latest Stable Version Total Downloads Build Status Latest Unstable Version License

Installation

composer require th3mouk/yahoo-weather-bundle ^1.0@dev

Add to the appKernel.php:

// Weather Bundle
new Th3Mouk\YahooWeatherBundle\Th3MoukYahooWeatherBundle(),

Full configuration of config.yml

th3mouk_yahoo_weather:
    templates:
        today:     Th3MoukYahooWeatherBundle:Default:today.html.twig
        forecast:  Th3MoukYahooWeatherBundle:Default:forecast.html.twig
            
    pictograms:
        helper: ImplementsYourOwn
        extension: Th3Mouk\YahooWeatherBundle\Twig\PictoExtension

Usage

This bundle provides two entities: Th3Mouk\YahooWeatherBundle\Entity\City and Th3Mouk\YahooWeatherBundle\Entity\Forecast.

The first one is relative to communication with the API, city object must have the name of the city like in the Yahoo Weather Documentation, or a WOEID code. The second is for data persistence and history retrieve.

Extends them or feel free to hack it !

Twig Extensions

Weather

You have two extensions to draw the forecasts, they use templates defined in configuration. Feel free to to implements or add your own !

{{ weather_forecast(city, unit = 'c') }}
{{ weather_today(city, unit = 'c') }}

Icons

You can add a pictogram helper in the configuration that activate this extension, that must implement Th3Mouk\YahooWeatherBundle\Helper\PictogramInterface.

{{ code|weather_pictogram }}

This is an exemple of PictogramHelper :

namespace AppBundle\Helper;

use Th3Mouk\YahooWeatherBundle\Helper\PictogramInterface;

class WeatherPictogramHelper implements PictogramInterface
{
    /**
     * Function that retrieve the html string corresponding to a weather code.
     *
     * @param $code
     *
     * @return string|null
     */
    public function getPictogram($code)
    {
        return "<img src='favicon.ico'/>";
    }
}

Sonata Integration Exemple

This bundle automatically provide an administration for cities.

The service is named th3mouk_yahoo_weather.admin.city.

th3mouk_yahoo_weather.admin.city:
    class: Th3Mouk\YahooWeatherBundle\Admin\CityAdmin
    arguments: [~, Th3Mouk\YahooWeatherBundle\Entity\City, SonataAdminBundle:CRUD]
    tags:
        - {name: sonata.admin, manager_type: orm, group: weather, label: city}

Add the admin group on the dashboard:

sonata.admin.group.weather:
    label:           weather
    label_catalogue: messages
    icon:            '<i class="fa fa-sun-o"></i>'
    items:
        - th3mouk_yahoo_weather.admin.city
    roles: [ ROLE_ADMIN ]

Don't forget to add this group on a block:

sonata_admin:
    dashboard:
        blocks:
            - { position: left, type: sonata.admin.block.admin_list, settings: { groups: [...sonata.admin.group.weather...] }}

You're done! 👍

TODO

  • Add template option on weather twig extension
  • Add today forecast without city object
  • Remove sonata configuration in the bundle
  • Add weather extension configuration
  • Add twig extension of history
  • Add twig extension for comparison of weather (today and Y-1)
  • Add twig extension for comparison of weather (forecast and Y-1)

Please

Feel free to improve this bundle.

统计信息

  • 总下载量: 224
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固