| @@ 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. |
|
| @@ 149-166 (lines=18) @@ | ||
| 146 | * |
|
| 147 | * @throws RecordNotPersistedException |
|
| 148 | */ |
|
| 149 | public function update(UserEntity $entity) |
|
| 150 | { |
|
| 151 | if ($entity->isNew()) { |
|
| 152 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
| 153 | } |
|
| 154 | ||
| 155 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
| 156 | ||
| 157 | $this->connection->update( |
|
| 158 | self::TABLE, |
|
| 159 | $databaseArray, |
|
| 160 | ['user_id' => $entity->id] |
|
| 161 | ); |
|
| 162 | ||
| 163 | $entity->id = (int) $this->connection->lastInsertId(); |
|
| 164 | ||
| 165 | return $entity; |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * Removes a user from the database. |
|
| @@ 177-194 (lines=18) @@ | ||
| 174 | * |
|
| 175 | * @throws RecordNotPersistedException |
|
| 176 | */ |
|
| 177 | public function remove(UserEntity $entity) |
|
| 178 | { |
|
| 179 | if ($entity->isNew()) { |
|
| 180 | throw new RecordNotPersistedException('The entity does not exist.'); |
|
| 181 | } |
|
| 182 | ||
| 183 | $databaseArray = $this->getDatabaseArrayFromEntity($entity); |
|
| 184 | ||
| 185 | $this->connection->delete( |
|
| 186 | self::TABLE, |
|
| 187 | $databaseArray, |
|
| 188 | ['user_id' => $entity->id] |
|
| 189 | ); |
|
| 190 | ||
| 191 | $entity->id = null; |
|
| 192 | ||
| 193 | return $entity; |
|
| 194 | } |
|
| 195 | ||
| 196 | /** |
|
| 197 | * Converts database array to entity array. |
|