core23/shariff-bundle

This bundle provides a wrapper for using shariff inside the sonata-project.

2.0.0 2017-09-14 07:39 UTC

README

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Build Status Scrutinizer Code Quality Code Climate Coverage Status

Donate to this project using Flattr Donate to this project using PayPal

This bundle provides a wrapper for using shariff inside the symfony sonata-project.

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

composer require core23/shariff-bundle

Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in bundles.php file of your project:

// config/bundles.php

return [
    // ...
    Core23\ShariffBundle\Core23ShariffBundle::class => ['all' => true],
];

Configure the Bundle

Create a configuration file called core23_shariff.yaml:

# app/config/routes/core23_shariff.yaml

core23_shariff:
    resource: "@Core23ShariffBundle/Resources/config/routing/backend.yml"

Add the block to the sonata_block configuration if necessary:

# config/packages/sonata_block.yaml

sonata_block:
    blocks:
        core23_shariff.block.share: ~

Create a configuration file called doctrine_cache.yaml:

doctrine_cache:
    providers:
        core23_shariff:
            type: php_file
            namespace: core23_shariff

Usage

{# template.twig #}

{{ sonata_block_render({ 'type': 'core23_shariff.block.share' }, {
    'url': 'https://example.com/site.html'
}) }}

Configure the Bundle

You can globally configure the services that should count the likes or favorites for a page.

core23_shariff:
    options:
        domains: [ ] # Allow specific domains for shariff
        services: [ 'GooglePlus', 'Facebook', 'LinkedIn', 'Reddit', 'StumbleUpon', 'Flattr', 'Pinterest', 'Xing', 'AddThis' ]
    services:
        # Optional configuration when using facebook service
        facebook:
            app_id: "1234567890"
            secret: "GENERATEDSECRET"

See shariff-php for a list of all available services.

License

This bundle is under the MIT license.