2017 © Pedro Peláez
 

symfony-bundle yahoo-weather-bundle

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

image

th3mouk/yahoo-weather-bundle

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

  • Thursday, April 21, 2016
  • by Th3Mouk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 153 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yahoo Weather Bundle

This Symfony bundle providing communication and historian of Yahoo Weather API., (*1)

SensioLabsInsight Latest Stable Version Total Downloads Build Status Latest Unstable Version License, (*2)

Installation

composer require th3mouk/yahoo-weather-bundle ^1.0@dev, (*3)

Add to the appKernel.php:, (*4)

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

Full configuration of config.yml, (*5)

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., (*6)

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., (*7)

Extends them or feel free to hack it !, (*8)

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 !, (*9)

{{ 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., (*10)

{{ code|weather_pictogram }}

This is an exemple of PictogramHelper :, (*11)

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., (*12)

The service is named th3mouk_yahoo_weather.admin.city., (*13)

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:, (*14)

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:, (*15)

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

You're done! :+1:, (*16)

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., (*17)

The Versions

21/04 2016

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony yahoo weather forecasts

21/04 2016

0.9

0.9.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony yahoo weather forecasts