Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 1.53 KB

File metadata and controls

60 lines (39 loc) · 1.53 KB

Open Graph Bundle

This bundle integrates the OpenGraph library into Symfony.

## Installation

Simply run assuming you have installed composer :

$ php composer.phar require novaway/open-graph-bundle "^1.0"

## Configuration

Register the bundle in app/AppKernel.php :

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new \Novaway\Bundle\OpenGraphBundle\NovawayOpenGraphBundle(),
    );
}

See all available configuration options.

Graph configuration

Annotation

Just use annotation like it is explain in OpenGraph library documentation.

YAML

To use YAML graph configuration. You need to register your YAML file configuration in the Resources/config/open-graph directory of your bundle.

After that, you can use YAML configuration like it is explain in OpenGraph library documentation.

See example.

Usage

The OpenGraphGenerator is available as novaway.open_graph.generator service :

// $myObject = ...
$graphGenerator = $this->get('novaway.open_graph.generator')->generate($myObject);

## Render OpenGraph in templates

The bundle comes with some Twig functions to render the graph into you templates.

  • renderNamespace : Render graph prefix attributes (namespaces)
  • renderGraph : Render tags for the graph
  • renderTag : Render a specific tag of the graph