Completed
Pull Request — 2.0 (#75)
by Julien
02:32
created

SendNotificationTrait::getSession()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
/*
3
 * This file is part of the Pomm's Foundation package.
4
 *
5
 * (c) 2014 - 2015 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\Foundation\Listener;
11
12
/**
13
 * SendNotificationTrait
14
 *
15
 * Trait to add sendNotification method to clients.
16
 *
17
 * @package     Foundation
18
 * @copyright   2014 - 2015 Grégoire HUBERT
19
 * @author      Grégoire HUBERT
20
 * @license     X11 {@link http://opensource.org/licenses/mit-license.php}
21
 */
22
trait SendNotificationTrait
23
{
24
    /**
25
     * getSession
26
     *
27
     * sendNotification needs to access the session.
28
     */
29
    abstract protected function getSession();
30
31
    /**
32
     * sendNotification
33
     *
34
     * Send notification to the listener pooler.
35
     *
36
     * @access protected
37
     * @param  string $name
38
     * @param  array $data
39
     * @return mixed $this
40
     */
41
    protected function sendNotification($name, array $data)
42
    {
43
        $this
44
            ->getSession()
45
            ->getPoolerForType('listener')
46
            ->notify($name, $data)
47
            ;
48
49
        return $this;
50
    }
51
}
52