| @@ 186-203 (lines=18) @@ | ||
| 183 | * |
|
| 184 | * @return \eZ\Publish\SPI\Persistence\User\RoleCreateStruct |
|
| 185 | */ |
|
| 186 | public function buildPersistenceRoleCreateStruct(APIRoleCreateStruct $roleCreateStruct) |
|
| 187 | { |
|
| 188 | $policiesToCreate = []; |
|
| 189 | foreach ($roleCreateStruct->getPolicies() as $policyCreateStruct) { |
|
| 190 | $policiesToCreate[] = $this->buildPersistencePolicyObject( |
|
| 191 | $policyCreateStruct->module, |
|
| 192 | $policyCreateStruct->function, |
|
| 193 | $policyCreateStruct->getLimitations() |
|
| 194 | ); |
|
| 195 | } |
|
| 196 | ||
| 197 | return new SPIRoleCreateStruct( |
|
| 198 | [ |
|
| 199 | 'identifier' => $roleCreateStruct->identifier, |
|
| 200 | 'policies' => $policiesToCreate, |
|
| 201 | ] |
|
| 202 | ); |
|
| 203 | } |
|
| 204 | ||
| 205 | /** |
|
| 206 | * Creates SPI Role copy struct from provided API role copy struct. |
|
| @@ 213-231 (lines=19) @@ | ||
| 210 | * |
|
| 211 | * @return \eZ\Publish\SPI\Persistence\User\RoleCopyStruct |
|
| 212 | */ |
|
| 213 | public function buildPersistenceRoleCopyStruct(APIRoleCopyStruct $roleCopyStruct, $clonedId) |
|
| 214 | { |
|
| 215 | $policiesToCopy = []; |
|
| 216 | foreach ($roleCopyStruct->getPolicies() as $policyCopyStruct) { |
|
| 217 | $policiesToCopy[] = $this->buildPersistencePolicyObject( |
|
| 218 | $policyCopyStruct->module, |
|
| 219 | $policyCopyStruct->function, |
|
| 220 | $policyCopyStruct->getLimitations() |
|
| 221 | ); |
|
| 222 | } |
|
| 223 | ||
| 224 | return new SPIRoleCopyStruct( |
|
| 225 | [ |
|
| 226 | 'clonedId' => $clonedId, |
|
| 227 | 'newIdentifier' => $roleCopyStruct->newIdentifier, |
|
| 228 | 'policies' => $policiesToCopy, |
|
| 229 | ] |
|
| 230 | ); |
|
| 231 | } |
|
| 232 | ||
| 233 | /** |
|
| 234 | * Creates SPI Policy value object from provided module, function and limitations. |
|