Code Duplication    Length = 192-192 lines in 9 locations

local/devel/Repositories/CacheCountriesRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class CacheCountriesRepository
10
{
11
    const TABLE = 'cache_countries';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return GeoCacheCountriesEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return GeoCacheCountriesEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return GeoCacheCountriesEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param GeoCacheCountriesEntity $entity
109
     * @return GeoCacheCountriesEntity
110
     */
111
    public function create(GeoCacheCountriesEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param GeoCacheCountriesEntity $entity
131
     * @return GeoCacheCountriesEntity
132
     */
133
    public function update(GeoCacheCountriesEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param GeoCacheCountriesEntity $entity
152
     * @return GeoCacheCountriesEntity
153
     */
154
    public function remove(GeoCacheCountriesEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param GeoCacheCountriesEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(GeoCacheCountriesEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'date_created' => $entity->dateCreated,
179
        'cache_id' => $entity->cacheId,
180
        'country' => $entity->country,
181
        'restored_by' => $entity->restoredBy,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return GeoCacheCountriesEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new GeoCacheCountriesEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->dateCreated =  new DateTime($data['date_created']);
194
        $entity->cacheId = (int) $data['cache_id'];
195
        $entity->country = (string) $data['country'];
196
        $entity->restoredBy = (int) $data['restored_by'];
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/GeodbChangelogRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class GeodbChangelogRepository
10
{
11
    const TABLE = 'geodb_changelog';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return GeodbChangelogEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return GeodbChangelogEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return GeodbChangelogEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param GeodbChangelogEntity $entity
109
     * @return GeodbChangelogEntity
110
     */
111
    public function create(GeodbChangelogEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param GeodbChangelogEntity $entity
131
     * @return GeodbChangelogEntity
132
     */
133
    public function update(GeodbChangelogEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param GeodbChangelogEntity $entity
152
     * @return GeodbChangelogEntity
153
     */
154
    public function remove(GeodbChangelogEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param GeodbChangelogEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(GeodbChangelogEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'datum' => $entity->datum,
179
        'beschreibung' => $entity->beschreibung,
180
        'autor' => $entity->autor,
181
        'version' => $entity->version,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return GeodbChangelogEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new GeodbChangelogEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->datum =  new DateTime($data['datum']);
194
        $entity->beschreibung = (string) $data['beschreibung'];
195
        $entity->autor = (string) $data['autor'];
196
        $entity->version = (string) $data['version'];
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/GeodbSearchRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class GeodbSearchRepository
10
{
11
    const TABLE = 'geodb_search';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return GeodbSearchEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return GeodbSearchEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return GeodbSearchEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param GeodbSearchEntity $entity
109
     * @return GeodbSearchEntity
110
     */
111
    public function create(GeodbSearchEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param GeodbSearchEntity $entity
131
     * @return GeodbSearchEntity
132
     */
133
    public function update(GeodbSearchEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param GeodbSearchEntity $entity
152
     * @return GeodbSearchEntity
153
     */
154
    public function remove(GeodbSearchEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param GeodbSearchEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(GeodbSearchEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'loc_id' => $entity->locId,
179
        'sort' => $entity->sort,
180
        'simple' => $entity->simple,
181
        'simplehash' => $entity->simplehash,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return GeodbSearchEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new GeodbSearchEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->locId = (int) $data['loc_id'];
194
        $entity->sort = (string) $data['sort'];
195
        $entity->simple = (string) $data['simple'];
196
        $entity->simplehash = (int) $data['simplehash'];
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/LoginsRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class LoginsRepository
10
{
11
    const TABLE = 'logins';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return LoginsEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return LoginsEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return LoginsEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param LoginsEntity $entity
109
     * @return LoginsEntity
110
     */
111
    public function create(LoginsEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param LoginsEntity $entity
131
     * @return LoginsEntity
132
     */
133
    public function update(LoginsEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param LoginsEntity $entity
152
     * @return LoginsEntity
153
     */
154
    public function remove(LoginsEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param LoginsEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(LoginsEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'user_id' => $entity->userId,
179
        'remote_addr' => $entity->remoteAddr,
180
        'success' => $entity->success,
181
        'timestamp' => $entity->timestamp,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return LoginsEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new LoginsEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->userId = (int) $data['user_id'];
194
        $entity->remoteAddr = (string) $data['remote_addr'];
195
        $entity->success = (int) $data['success'];
196
        $entity->timestamp =  new DateTime($data['timestamp']);
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/LogTypesTextRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class LogTypesTextRepository
10
{
11
    const TABLE = 'log_types_text';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return LogTypesTextEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return LogTypesTextEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return LogTypesTextEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param LogTypesTextEntity $entity
109
     * @return LogTypesTextEntity
110
     */
111
    public function create(LogTypesTextEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param LogTypesTextEntity $entity
131
     * @return LogTypesTextEntity
132
     */
133
    public function update(LogTypesTextEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param LogTypesTextEntity $entity
152
     * @return LogTypesTextEntity
153
     */
154
    public function remove(LogTypesTextEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param LogTypesTextEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(LogTypesTextEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'log_types_id' => $entity->logTypesId,
179
        'lang' => $entity->lang,
180
        'text_combo' => $entity->textCombo,
181
        'text_listing' => $entity->textListing,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return LogTypesTextEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new LogTypesTextEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->logTypesId = (int) $data['log_types_id'];
194
        $entity->lang = (string) $data['lang'];
195
        $entity->textCombo = (string) $data['text_combo'];
196
        $entity->textListing = (string) $data['text_listing'];
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/NpaAreasRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class NpaAreasRepository
10
{
11
    const TABLE = 'npa_areas';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return NpaAreasEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return NpaAreasEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return NpaAreasEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param NpaAreasEntity $entity
109
     * @return NpaAreasEntity
110
     */
111
    public function create(NpaAreasEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param NpaAreasEntity $entity
131
     * @return NpaAreasEntity
132
     */
133
    public function update(NpaAreasEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param NpaAreasEntity $entity
152
     * @return NpaAreasEntity
153
     */
154
    public function remove(NpaAreasEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param NpaAreasEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(NpaAreasEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'type_id' => $entity->typeId,
179
        'exclude' => $entity->exclude,
180
        'name' => $entity->name,
181
        'shape' => $entity->shape,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return NpaAreasEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new NpaAreasEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->typeId = (string) $data['type_id'];
194
        $entity->exclude = (int) $data['exclude'];
195
        $entity->name = (string) $data['name'];
196
        $entity->shape = $data['shape'];
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/QueriesRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class QueriesRepository
10
{
11
    const TABLE = 'queries';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return QueriesEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return QueriesEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return QueriesEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param QueriesEntity $entity
109
     * @return QueriesEntity
110
     */
111
    public function create(QueriesEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param QueriesEntity $entity
131
     * @return QueriesEntity
132
     */
133
    public function update(QueriesEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param QueriesEntity $entity
152
     * @return QueriesEntity
153
     */
154
    public function remove(QueriesEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param QueriesEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(QueriesEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'user_id' => $entity->userId,
179
        'name' => $entity->name,
180
        'options' => $entity->options,
181
        'last_queried' => $entity->lastQueried,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return QueriesEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new QueriesEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->userId = (int) $data['user_id'];
194
        $entity->name = (string) $data['name'];
195
        $entity->options = (string) $data['options'];
196
        $entity->lastQueried =  new DateTime($data['last_queried']);
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/ReplicationOverwritetypesRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class ReplicationOverwritetypesRepository
10
{
11
    const TABLE = 'replication_overwritetypes';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return ReplicationOverwritetypesEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return ReplicationOverwritetypesEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return ReplicationOverwritetypesEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param ReplicationOverwritetypesEntity $entity
109
     * @return ReplicationOverwritetypesEntity
110
     */
111
    public function create(ReplicationOverwritetypesEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param ReplicationOverwritetypesEntity $entity
131
     * @return ReplicationOverwritetypesEntity
132
     */
133
    public function update(ReplicationOverwritetypesEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param ReplicationOverwritetypesEntity $entity
152
     * @return ReplicationOverwritetypesEntity
153
     */
154
    public function remove(ReplicationOverwritetypesEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param ReplicationOverwritetypesEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(ReplicationOverwritetypesEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'table' => $entity->table,
179
        'field' => $entity->field,
180
        'uuid_fieldname' => $entity->uuidFieldname,
181
        'backupfirst' => $entity->backupfirst,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return ReplicationOverwritetypesEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new ReplicationOverwritetypesEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->table = (string) $data['table'];
194
        $entity->field = (string) $data['field'];
195
        $entity->uuidFieldname = (string) $data['uuid_fieldname'];
196
        $entity->backupfirst = (int) $data['backupfirst'];
197
198
        return $entity;
199
    }
200
}
201

local/devel/Repositories/ReplicationRepository.php 1 location

@@ 9-200 (lines=192) @@
6
use Oc\Repository\Exception\RecordNotPersistedException;
7
use Oc\Repository\Exception\RecordsNotFoundException;
8
9
class ReplicationRepository
10
{
11
    const TABLE = 'replication';
12
13
    /** @var Connection */
14
    private $connection;
15
16
    public function __construct(Connection $connection)
17
    {
18
        $this->connection = $connection;
19
    }
20
21
    /**
22
     * @return ReplicationEntity[]
23
     */
24
    public function fetchAll()
25
    {
26
        $statement = $this->connection->createQueryBuilder()
27
                    ->select('*')
28
                    ->from(self::TABLE)
29
                    ->execute();
30
31
        $result = $statement->fetchAll();
32
33
        if ($statement->rowCount() === 0) {
34
            throw new RecordsNotFoundException('No records found');
35
        }
36
37
        $records = [];
38
39
        foreach ($result as $item) {
40
            $records[] = $this->getEntityFromDatabaseArray($item);
41
        }
42
43
        return $records;
44
    }
45
46
    /**
47
     * @param array $where
48
     * @return ReplicationEntity
49
     */
50
    public function fetchOneBy(array $where = [])
51
    {
52
        $queryBuilder = $this->connection->createQueryBuilder()
53
                     ->select('*')
54
                     ->from(self::TABLE)
55
                     ->setMaxResults(1);
56
57
        if (count($where) > 0) {
58
            foreach ($where as $column => $value) {
59
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
60
            }
61
        }
62
63
        $statement = $queryBuilder->execute();
64
65
        $result = $statement->fetch();
66
67
        if ($statement->rowCount() === 0) {
68
            throw new RecordNotFoundException('Record with given where clause not found');
69
        }
70
71
        return $this->getEntityFromDatabaseArray($result);
72
    }
73
74
    /**
75
     * @param array $where
76
     * @return ReplicationEntity[]
77
     */
78
    public function fetchBy(array $where = [])
79
    {
80
        $queryBuilder = $this->connection->createQueryBuilder()
81
                     ->select('*')
82
                     ->from(self::TABLE);
83
84
        if (count($where) > 0) {
85
            foreach ($where as $column => $value) {
86
                $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value));
87
            }
88
        }
89
90
        $statement = $queryBuilder->execute();
91
92
        $result = $statement->fetchAll();
93
94
        if ($statement->rowCount() === 0) {
95
            throw new RecordsNotFoundException('No records with given where clause found');
96
        }
97
98
        $entities = [];
99
100
        foreach ($result as $item) {
101
            $entities[] = $this->getEntityFromDatabaseArray($item);
102
        }
103
104
        return $entities;
105
    }
106
107
    /**
108
     * @param ReplicationEntity $entity
109
     * @return ReplicationEntity
110
     */
111
    public function create(ReplicationEntity $entity)
112
    {
113
        if (!$entity->isNew()) {
114
            throw new RecordAlreadyExistsException('The entity does already exist.');
115
        }
116
117
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
118
119
        $this->connection->insert(
120
                    self::TABLE,
121
                    $databaseArray
122
                );
123
124
        $entity->id = (int) $this->connection->lastInsertId();
125
126
        return $entity;
127
    }
128
129
    /**
130
     * @param ReplicationEntity $entity
131
     * @return ReplicationEntity
132
     */
133
    public function update(ReplicationEntity $entity)
134
    {
135
        if ($entity->isNew()) {
136
            throw new RecordNotPersistedException('The entity does not exist.');
137
        }
138
139
        $databaseArray = $this->getDatabaseArrayFromEntity($entity);
140
141
        $this->connection->update(
142
                    self::TABLE,
143
                    $databaseArray,
144
                    ['id' => $entity->id]
145
                );
146
147
        return $entity;
148
    }
149
150
    /**
151
     * @param ReplicationEntity $entity
152
     * @return ReplicationEntity
153
     */
154
    public function remove(ReplicationEntity $entity)
155
    {
156
        if ($entity->isNew()) {
157
            throw new RecordNotPersistedException('The entity does not exist.');
158
        }
159
160
        $this->connection->delete(
161
                    self::TABLE,
162
                    ['id' => $entity->id]
163
                );
164
165
        $entity->cacheId = null;
166
167
        return $entity;
168
    }
169
170
    /**
171
     * @param ReplicationEntity $entity
172
     * @return []
173
     */
174
    public function getDatabaseArrayFromEntity(ReplicationEntity $entity)
175
    {
176
        return [
177
        'id' => $entity->id,
178
        'module' => $entity->module,
179
        'last_run' => $entity->lastRun,
180
        'use' => $entity->use,
181
        'prio' => $entity->prio,
182
        ];
183
    }
184
185
    /**
186
     * @param array $data
187
     * @return ReplicationEntity
188
     */
189
    public function getEntityFromDatabaseArray(array $data)
190
    {
191
        $entity = new ReplicationEntity();
192
        $entity->id = (int) $data['id'];
193
        $entity->module = (string) $data['module'];
194
        $entity->lastRun =  new DateTime($data['last_run']);
195
        $entity->use = (int) $data['use'];
196
        $entity->prio = (int) $data['prio'];
197
198
        return $entity;
199
    }
200
}
201