astina / social-links-bundle
Symfony bundle that is using SocialLinks to generate share links for social networks.
Installs: 47 064
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 21
Forks: 9
Type:symfony-bundle
Requires
- sensio/framework-extra-bundle: >=2.3
- social-links/social-links: ^1.13
- symfony/symfony: ~2.3
Requires (Dev)
- phpunit/phpunit: 4.2.*
This package is not auto-updated.
Last update: 2022-07-15 10:49:50 UTC
README
AstinaSocialLinksBundle is basically a wrapper around oscarotero/social-links. Its main purpose is to generate social links based on given provider.
Currently supported providers.
Install
Step 1: Add to composer.json
"require" : { // ... "astina/social-links-bundle":"dev-master", }
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Astina\Bundle\SocialLinksBundle\AstinaSocialLinksBundle(), ); }
Usage
Main functionality of this bundle is to generate a social link for given provider and url. It can be used as an twig extension, like in the example below.
Basic usage:
{{ social_link('facebook') }}
Extended usage:
{{ social_link('facebook', 'http://www.astina.ch', {'text': 'Custom text', attributes: {'class': 'custom-share', 'target': '_self'} }, 'Custom link text') }}
This example will return an HTML response which looks like.
<a href="https://www.facebook.com/sharer.php?s=100&p%5Burl%5D=http%3A%2F%2Fwww.astina.ch" class="custom-share" target="_self"></a>
Helper accepts three parameters - provider as string, url as string, options as multidimensional array and link text as string. There you can basically add as many custom attributes as you want.
Options and default values:
'title' => null 'text' => null 'options' => array('attributes' => array('target' => '_blank')) 'linkText => null
Template extending
It is also possible to extend a social link template, by simply adding a socialLink.html.twig template in app/Resources/AstinaSocialLinksBundle/views/SocialLinks
.
Run tests
bin/phpunit