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