@@ 102-119 (lines=18) @@ | ||
99 | * |
|
100 | * @throws RecordNotPersistedException |
|
101 | */ |
|
102 | public function update(CountryEntity $entity) |
|
103 | { |
|
104 | if ($entity->isNew()) { |
|
105 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
106 | } |
|
107 | ||
108 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
109 | ||
110 | $this->connection->update( |
|
111 | self::TABLE, |
|
112 | $databaseArray, |
|
113 | ['short' => $entity->short] |
|
114 | ); |
|
115 | ||
116 | $entity->short = $this->connection->lastInsertId(); |
|
117 | ||
118 | return $entity; |
|
119 | } |
|
120 | ||
121 | /** |
|
122 | * Removes a country from the database. |
|
@@ 130-147 (lines=18) @@ | ||
127 | * |
|
128 | * @throws RecordNotPersistedException |
|
129 | */ |
|
130 | public function remove(CountryEntity $entity) |
|
131 | { |
|
132 | if ($entity->isNew()) { |
|
133 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
134 | } |
|
135 | ||
136 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
137 | ||
138 | $this->connection->delete( |
|
139 | self::TABLE, |
|
140 | $databaseArray, |
|
141 | ['short' => $entity->short] |
|
142 | ); |
|
143 | ||
144 | $entity->short = null; |
|
145 | ||
146 | return $entity; |
|
147 | } |
|
148 | ||
149 | /** |
|
150 | * Maps the given entity to the database array. |
@@ 122-139 (lines=18) @@ | ||
119 | * |
|
120 | * @throws RecordNotPersistedException |
|
121 | */ |
|
122 | public function update(LanguageEntity $entity) |
|
123 | { |
|
124 | if ($entity->isNew()) { |
|
125 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
126 | } |
|
127 | ||
128 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
129 | ||
130 | $this->connection->update( |
|
131 | self::TABLE, |
|
132 | $databaseArray, |
|
133 | ['short' => $entity->short] |
|
134 | ); |
|
135 | ||
136 | $entity->short = $this->connection->lastInsertId(); |
|
137 | ||
138 | return $entity; |
|
139 | } |
|
140 | ||
141 | /** |
|
142 | * Removes a language from the database. |
|
@@ 150-167 (lines=18) @@ | ||
147 | * |
|
148 | * @throws RecordNotPersistedException |
|
149 | */ |
|
150 | public function remove(LanguageEntity $entity) |
|
151 | { |
|
152 | if ($entity->isNew()) { |
|
153 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
154 | } |
|
155 | ||
156 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
157 | ||
158 | $this->connection->delete( |
|
159 | self::TABLE, |
|
160 | $databaseArray, |
|
161 | ['short' => $entity->short] |
|
162 | ); |
|
163 | ||
164 | $entity->short = null; |
|
165 | ||
166 | return $entity; |
|
167 | } |
|
168 | ||
169 | /** |
|
170 | * Converts database array to entity array. |
@@ 112-129 (lines=18) @@ | ||
109 | * |
|
110 | * @throws RecordNotPersistedException |
|
111 | */ |
|
112 | public function update(BlockEntity $entity) |
|
113 | { |
|
114 | if ($entity->isNew()) { |
|
115 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
116 | } |
|
117 | ||
118 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
119 | ||
120 | $this->connection->update( |
|
121 | self::TABLE, |
|
122 | $databaseArray, |
|
123 | ['id' => $entity->id] |
|
124 | ); |
|
125 | ||
126 | $entity->id = (int) $this->connection->lastInsertId(); |
|
127 | ||
128 | return $entity; |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * Removes a page from the database. |
|
@@ 140-157 (lines=18) @@ | ||
137 | * |
|
138 | * @throws RecordNotPersistedException |
|
139 | */ |
|
140 | public function remove(BlockEntity $entity) |
|
141 | { |
|
142 | if ($entity->isNew()) { |
|
143 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
144 | } |
|
145 | ||
146 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
147 | ||
148 | $this->connection->delete( |
|
149 | self::TABLE, |
|
150 | $databaseArray, |
|
151 | ['id' => $entity->id] |
|
152 | ); |
|
153 | ||
154 | $entity->id = null; |
|
155 | ||
156 | return $entity; |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * Maps the given entity to the database array. |
@@ 110-127 (lines=18) @@ | ||
107 | * |
|
108 | * @throws RecordNotPersistedException |
|
109 | */ |
|
110 | public function update(PageEntity $entity) |
|
111 | { |
|
112 | if ($entity->isNew()) { |
|
113 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
114 | } |
|
115 | ||
116 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
117 | ||
118 | $this->connection->update( |
|
119 | self::TABLE, |
|
120 | $databaseArray, |
|
121 | ['id' => $entity->id] |
|
122 | ); |
|
123 | ||
124 | $entity->id = (int) $this->connection->lastInsertId(); |
|
125 | ||
126 | return $entity; |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * Removes a page from the database. |
|
@@ 138-155 (lines=18) @@ | ||
135 | * |
|
136 | * @throws RecordNotPersistedException |
|
137 | */ |
|
138 | public function remove(PageEntity $entity) |
|
139 | { |
|
140 | if ($entity->isNew()) { |
|
141 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
142 | } |
|
143 | ||
144 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
145 | ||
146 | $this->connection->delete( |
|
147 | self::TABLE, |
|
148 | $databaseArray, |
|
149 | ['id' => $entity->id] |
|
150 | ); |
|
151 | ||
152 | $entity->id = null; |
|
153 | ||
154 | return $entity; |
|
155 | } |
|
156 | ||
157 | /** |
|
158 | * Maps the given entity to the database array. |
@@ 129-146 (lines=18) @@ | ||
126 | * |
|
127 | * @throws RecordNotPersistedException |
|
128 | */ |
|
129 | public function update(UserEntity $entity) |
|
130 | { |
|
131 | if ($entity->isNew()) { |
|
132 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
133 | } |
|
134 | ||
135 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
136 | ||
137 | $this->connection->update( |
|
138 | self::TABLE, |
|
139 | $databaseArray, |
|
140 | ['id' => $entity->id] |
|
141 | ); |
|
142 | ||
143 | $entity->id = (int) $this->connection->lastInsertId(); |
|
144 | ||
145 | return $entity; |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Removes a user from the database. |
|
@@ 157-174 (lines=18) @@ | ||
154 | * |
|
155 | * @throws RecordNotPersistedException |
|
156 | */ |
|
157 | public function remove(UserEntity $entity) |
|
158 | { |
|
159 | if ($entity->isNew()) { |
|
160 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
161 | } |
|
162 | ||
163 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
164 | ||
165 | $this->connection->delete( |
|
166 | self::TABLE, |
|
167 | $databaseArray, |
|
168 | ['id' => $entity->id] |
|
169 | ); |
|
170 | ||
171 | $entity->id = null; |
|
172 | ||
173 | return $entity; |
|
174 | } |
|
175 | ||
176 | /** |
|
177 | * Converts database array to entity array. |