Skip to content

Commit 2e7b73e

Browse files
committed
Add constants for event's priorities
1 parent 6cddcd2 commit 2e7b73e

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

src/EventListener/EventPriorities.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace ApiPlatform\Core\EventListener;
13+
14+
/**
15+
* Constants for common priorities.
16+
*
17+
* @author Kévin Dunglas <dunglas@gmail.com>
18+
*/
19+
final class EventPriorities
20+
{
21+
const PRE_READ = 5;
22+
const POST_READ = 3;
23+
const PRE_DESERIALIZE = 3;
24+
const POST_DESERIALIZE = 1;
25+
const PRE_VALIDATE = 65;
26+
const POST_VALIDATE = 63;
27+
const PRE_WRITE = 33;
28+
const POST_WRITE = 31;
29+
const PRE_RESPOND = 9;
30+
const POST_RESPOND = 7;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace ApiPlatform\Core\Tests\EventListener;
13+
14+
use ApiPlatform\Core\EventListener\EventPriorities;
15+
16+
/**
17+
* @author Kévin Dunglas <dunglas@gmail.com>
18+
*/
19+
class EventPrioritiesTest extends \PHPUnit_Framework_TestCase
20+
{
21+
public function testConstants()
22+
{
23+
$this->assertEquals(5, EventPriorities::PRE_READ);
24+
$this->assertEquals(3, EventPriorities::POST_READ);
25+
$this->assertEquals(3, EventPriorities::PRE_DESERIALIZE);
26+
$this->assertEquals(1, EventPriorities::POST_DESERIALIZE);
27+
$this->assertEquals(65, EventPriorities::PRE_VALIDATE);
28+
$this->assertEquals(63, EventPriorities::POST_VALIDATE);
29+
$this->assertEquals(33, EventPriorities::PRE_WRITE);
30+
$this->assertEquals(31, EventPriorities::POST_WRITE);
31+
$this->assertEquals(9, EventPriorities::PRE_RESPOND);
32+
$this->assertEquals(7, EventPriorities::POST_RESPOND);
33+
}
34+
}

0 commit comments

Comments
 (0)