FriendsOfSymfony/FOSHttpCacheBundle — pull request #178 by lolautruche (2014-12-02 14:51:05+00:00)
Title: Added subscriber options to HttpCache

Based on #177, ref #170

This PR adds 2 options that one can add in their `getOptions()`:

* `fos_native_subscribers`: bit options to activate/deactivate subscribers provided by FOSHttpCacheBundle
* `fos_subscribers`: Array of custom subscribers to add to the event dispatcher

> By default **all native subscribers are activated** (`HttpCache::SUBSCRIBER_ALL`).

**ALL native subscribers EXCEPT the user context one**
```php
public function getOptions()
{
return [
'fos_native_subscribers' => self::SUBSCRIBER_ALL | ~self::SUBSCRIBER_USER_CONTEXT
]
}
```

**NO native subscribers**
```php
public function getOptions()
{
return [
'fos_native_subscribers' => self::SUBSCRIBER_NONE
]
}
```

**ONLY user context subscribers**
```php
public function getOptions()
{
return [
'fos_native_subscribers' => self::SUBSCRIBER_USER_CONTEXT
]
}
```

**User context subscriber AND Foo subscriber**
```php
public function getOptions()
{
return [
'fos_native_subscribers' => self::SUBSCRIBER_USER_CONTEXT | self::SUBSCRIBER_FOO
]
}
```

**NO native subscribers + custom subscriber **
```php
public function getOptions()
{
return [
'fos_native_subscribers' => self::SUBSCRIBER_NONE,
'fos_subscribers' => [new MySubscriber()]
]
}
```

**ALL native subscribers (default) + custom subscriber **
```php
public function getOptions()
{
return [
'fos_subscribers' => [new MySubscriber()]
]
}
```