LinkifyBundle
Adds Linkify to your Symfony2 application, which converts URLs and email addresses in HTML (or plain text) to HTML links.
Authors
- Chris Wilkinson chris.wilkinson@admin.cam.ac.uk
Installation
Add LinkifyBundle to your dependencies:
// composer.json { // ... "require": { // ... "misd/linkify-bundle": "~1.0" } }Use Composer to download and install LinkifyBundle:
$ php composer.phar update misd/linkify-bundleRegister the bundle in your application:
// app/AppKernel.php class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ... new Misd\LinkifyBundle\MisdLinkifyBundle(), // ... ); } // ... }
Usage
Use the service:
$text = $this->container->get('misd.linkify')->process('This is my text containing a link to www.example.com.');
In a Twig template:
{{ "This is my text containing a link to www.example.com."|linkify }}
In a PHP template:
<?php echo $view['linkify']->process('This is my text containing a link to www.example.com.') ?>
Options
Requires Linkify v1.1.1 or newer.
An array of options can be passed (see the Linkify docs for futher details). So to add the link class to created links:
Using the service:
$text = $this->container->get('misd.linkify')->process('This is my text containing a link to www.example.com.', array('attr' => array('class' => 'link')));
In a Twig template:
{{ "This is my text containing a link to www.example.com."|linkify({'attr': {'class': 'link'}}) }}
In a PHP template:
<?php echo $view['linkify']->process('This is my text containing a link to www.example.com.', array('attr' => array('class' => 'link'))) ?>
Copyright (c) 2012 University of Cambridge
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

