Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3639 | Rev 5765 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3639 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Plugin;
6
 
7
use Laminas\Mvc\Controller\Plugin\AbstractPlugin;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Authentication\AuthenticationService;
10
use LeadersLinked\Model\Device;
11
use LeadersLinked\Mapper\DeviceMapper;
12
use LeadersLinked\Model\UserType;
13
use LeadersLinked\Mapper\NetworkMapper;
14
 
15
 
16
class CurrentNetworkPlugin extends AbstractPlugin
17
{
18
 
19
    /**
20
     *
21
     * @var boolean
22
     */
23
    protected $hasNetwork;
24
 
25
 
26
 
27
    /**
28
     *
29
     * @return \LeadersLinked\Model\Network
30
     */
31
    protected $network;
32
 
33
 
34
    /**
35
     *
36
     * @param AdapterInterface $adapter
37
     */
38
    public function __construct($adapter)
39
    {
40
 
41
        $this->hasNetwork = false;
42
        $hostname = empty($_SERVER['HTTP_HOST']) ?  '' : $_SERVER['HTTP_HOST'];
3831 efrain 43
        $hostname = str_replace('www.', '', $hostname);
3639 efrain 44
 
45
        $networkMapper = NetworkMapper::getInstance($adapter);
46
        $this->network = $networkMapper->fetchOneByHostnameForFrontend($hostname);
47
        if($this->network) {
48
            $this->hasNetwork = true;
49
        }
50
 
51
    }
52
 
53
 
54
    /**
55
     *
56
     * @return \LeadersLinked\Model\Network
57
     */
58
    public function getNetwork()
59
    {
60
 
61
        if($this->hasNetwork) {
62
            return $this->network;
63
        } else {
64
 
65
            return null;
66
        }
67
    }
68
 
69
 
70
    /**
71
     *
72
     * @return int
73
     */
74
    public function getNetworkId()
75
    {
76
        if($this->hasNetwork) {
77
           return $this->network->id;
78
 
79
        } else {
80
            return 0;
81
        }
82
    }
83
 
84
 
85
    /**
86
     *
87
     * @return boolean
88
     */
89
    public function hasNetwork()
90
    {
91
        return $this->hasNetwork;
92
    }
93
 
94
 
95
 
96
 
97
}