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