| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Copyright 2014 SURFnet bv | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * you may not use this file except in compliance with the License. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * You may obtain a copy of the License at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * Unless required by applicable law or agreed to in writing, software | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * See the License for the specific language governing permissions and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * limitations under the License. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Doctrine\ORM\Mapping as ORM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use JsonSerializable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Surfnet\Stepup\Identity\Value\CommonName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Surfnet\Stepup\Identity\Value\Email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Surfnet\Stepup\Identity\Value\IdentityId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Surfnet\Stepup\Identity\Value\Institution; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Surfnet\Stepup\Identity\Value\NameId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * Be aware that this entity is used for the RA Candidate presentation only. This entity shouldn't be used to store any RA candidates. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository", readOnly=true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | class RaCandidate implements JsonSerializable | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @ORM\Column(length=36) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     public $identityId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @ORM\Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @ORM\Column(type="institution") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var Institution | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     public $raInstitution; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @ORM\Column(type="institution") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @var \Surfnet\Stepup\Identity\Value\Institution | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public $institution; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @ORM\Column(type="stepup_name_id") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @var \Surfnet\Stepup\Identity\Value\NameId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public $nameId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @ORM\Column(type="stepup_common_name") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @var \Surfnet\Stepup\Identity\Value\CommonName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     public $commonName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * @ORM\Column(type="stepup_email") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @var \Surfnet\Stepup\Identity\Value\Email | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public $email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     private function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     public static function nominate( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         IdentityId $identityId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         Institution $institution, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         NameId $nameId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         CommonName $commonName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         Email $email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         Institution $raInstitution | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $candidate                = new self(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $candidate->identityId    = (string) $identityId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $candidate->institution   = $institution; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $candidate->nameId        = $nameId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $candidate->commonName    = $commonName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $candidate->email         = $email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $candidate->raInstitution = $raInstitution; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         return $candidate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                        
            
                                                                    
                                                                                                        
            
            
                | 103 |  | View Code Duplication |     public function jsonSerialize() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 104 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 105 |  |  |         return [ | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |             'identity_id'    => $this->identityId, | 
            
                                                        
            
                                    
            
            
                | 107 |  |  |             'institution'    => $this->institution, | 
            
                                                        
            
                                    
            
            
                | 108 |  |  |             'common_name'    => $this->commonName, | 
            
                                                        
            
                                    
            
            
                | 109 |  |  |             'email'          => $this->email, | 
            
                                                        
            
                                    
            
            
                | 110 |  |  |             'name_id'        => $this->nameId, | 
            
                                                        
            
                                    
            
            
                | 111 |  |  |             'ra_institution' => $this->raInstitution, | 
            
                                                        
            
                                    
            
            
                | 112 |  |  |         ]; | 
            
                                                        
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 114 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 115 |  |  |  |