forked from lolautruche/FOSHttpCacheBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestMatcher.php
More file actions
44 lines (35 loc) · 1.04 KB
/
RequestMatcher.php
File metadata and controls
44 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
* This file is part of the FOSHttpCacheBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\HttpCacheBundle\UserContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
class RequestMatcher implements RequestMatcherInterface
{
private $method;
private $accept;
public function __construct($accept = 'application/vnd.fos.user-context-hash', $method = null)
{
$this->accept = $accept;
$this->method = $method;
}
/**
* {@inheritDoc}
*/
public function matches(Request $request)
{
if ($this->accept !== null && $this->accept != $request->headers->get('accept', null)) {
return false;
}
if ($this->method !== null && $this->method != $request->getMethod()) {
return false;
}
return true;
}
}