Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
LogoutWorkstations
n/a
0 / 0
n/a
0 / 0
4
n/a
0 / 0
 init
n/a
0 / 0
n/a
0 / 0
4
1<?php
2
3namespace BO\Zmsdb\Helper;
4
5/**
6 * @codeCoverageIgnore
7 */
8class LogoutWorkstations
9{
10    /**
11     * logout all workstations
12     *
13     * @return void
14     */
15
16    public static function init($verbose)
17    {
18        $query = new \BO\Zmsdb\Query\Workstation(\BO\Zmsdb\Query\Base::SELECT);
19        $query
20            ->addEntityMapping()
21            ->addResolvedReferences(1);
22        $parameters = $query->getParameters();
23        $connection = \BO\Zmsdb\Connection\Select::getWriteConnection();
24        $statement = $connection->prepare("$query");
25        $statement->execute($parameters);
26        while ($data = $statement->fetch(\PDO::FETCH_ASSOC)) {
27            $dataEntity = new \BO\Zmsentities\Workstation();
28            $dataEntity->exchangeArray($query->postProcessJoins($data));
29            $dataEntity->setResolveLevel($query->getResolveLevel());
30            if ($dataEntity->useraccount->lastLogin) {
31                if ($verbose) {
32                    \App::$log->info('Workstation logout', [
33                        'workstationId' => $dataEntity->id,
34                        'useraccountId' => $dataEntity->useraccount->id,
35                    ]);
36                }
37                (new \BO\Zmsdb\Workstation())->writeEntityLogoutByName($dataEntity->useraccount->id);
38            }
39        }
40        \BO\Zmsdb\Connection\Select::writeCommit();
41    }
42}