2017 © Pedro Peláez
 

symfony-bundle extra-bundle

Dacorp Extra Bundle

image

dacorp/extra-bundle

Dacorp Extra Bundle

  • Tuesday, July 14, 2015
  • by pmartelletti
  • Repository
  • 2 Watchers
  • 3 Stars
  • 286 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Dacorp Extra Bundle

Collection of services, helper, and standard view for standard services you want to use in any kind of website., (*1)

It's a Work in Progress mainly used for other project. You can browse the repository, but I would not recommend you to use it unless you know what you want ;), (*2)

This branch (master) supports PUGXMultuUserBundle master, FOSUserBundle master and Symfony master., (*3)

The branch (1.0) supports PUGXMultuUserBundle 2.0, FOSUserBundle 2.0 and Symfony >=2.1, <2.4., (*4)

Some of the feature included :, (*5)

  • Image Uploader Service : Integration of Punkave Image Uploader as a service tight to a generic Media Model (plan to update to https://github.com/1up-lab/OneupUploaderBundle)
  • Simple README functionality included by default on demand (usually dev environment only is fine) : give you a page with a html rendered version of the README.md Markdown file located in the root of your Project
  • Manage metas for twitter cards and open graph
  • Provide switch lang feature (routes, knpmenu action, and Handler)

Using the ImageUploader Service:

include the default uploader {% include "DacorpExtraBundle:Common:file-upload-control.html.twig" %}, (*6)

Twig extension to manage metas

Support Twitter Card and Facebook Open graph Meta in a simple way with Twig extension., (*7)

Add global twig variables for specific data

Define specific account data in parameters.yml.dist

parameters:
    facebook_app_id: XXX
    twitter_widget_id: XXX
    twitter_default_account: XXX

Update globals

twig:
    globals:
        facebook_app_id: %facebook_app_id%
        twitter_default_account: %twitter_default_account%

Call twig extension within twig template

partner is an entity which has all needed informations to generate basic open graph meta and basic twitter card (only restaurant.restaurant supported for now)., (*8)

{% block head_meta %}
    {{ allMetas({'title': partner.title, 'description':partner.description,
    'url': path('get_partner', { 'alias': partner.alias }) , 'object':partner, 'images': partner.partnerMedias}) }}
{% endblock %}

Using the switch lang feature

Add the route

Using some extended mopa forms

We extends the mopa form widget with some updated widgets. Have a look to Resources/views/Form/fields.html.twig, (*9)

And setup mopa to use that form field definition file, (*10)


mopa_bootstrap: form: templating: DacorpExtraBundle:Form:fields.html.twig

Some useful services

ymlFileManager: service for loading ymlFile as array

namespace YourCorp\CoreBundle\Services\Manager;

use Dacorp\ExtraBundle\Services\YmlFileManager;

class YmlRankedListManager
{
    /**
     * @var YmlFileManager
     */
    private $ymlFileManager;


    public function __construct(YmlFileManager $ymlFileManager)
    {
        $this->ymlFileManager = $ymlFileManager;
    }
    # inject the serice "dacorp.manager.yml_file" in your service and use it like this
    public function loadYmlRankedList($fileName='default_ranked_list.yml')
    {
        $dataArray = $this->ymlFileManager->loadYmlFile($fileName);
        $dataArray = $this->ymlFileManager->loadYmlFile($fileName);
        foreach ($dataArray as $key => $data) {
            // do stuff with data
        }
    }
}

The Versions