@@ 129-143 (lines=15) @@ | ||
126 | * @AclAncestor("orocrm_contact_view") |
|
127 | * @return Response |
|
128 | */ |
|
129 | public function getByTypeAction($contactId, $typeName) |
|
130 | { |
|
131 | /** @var Contact $contact */ |
|
132 | $contact = $this->getContactManager()->find($contactId); |
|
133 | ||
134 | if ($contact) { |
|
135 | $address = $contact->getAddressByTypeName($typeName); |
|
136 | } else { |
|
137 | $address = null; |
|
138 | } |
|
139 | ||
140 | $responseData = $address ? json_encode($this->getPreparedItem($address)) : ''; |
|
141 | ||
142 | return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND); |
|
143 | } |
|
144 | ||
145 | /** |
|
146 | * REST GET primary address |
|
@@ 157-171 (lines=15) @@ | ||
154 | * @AclAncestor("orocrm_contact_view") |
|
155 | * @return Response |
|
156 | */ |
|
157 | public function getPrimaryAction($contactId) |
|
158 | { |
|
159 | /** @var Contact $contact */ |
|
160 | $contact = $this->getContactManager()->find($contactId); |
|
161 | ||
162 | if ($contact) { |
|
163 | $address = $contact->getPrimaryAddress(); |
|
164 | } else { |
|
165 | $address = null; |
|
166 | } |
|
167 | ||
168 | $responseData = $address ? json_encode($this->getPreparedItem($address)) : ''; |
|
169 | ||
170 | return new Response($responseData, $address ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND); |
|
171 | } |
|
172 | ||
173 | protected function getContactManager() |
|
174 | { |
@@ 70-84 (lines=15) @@ | ||
67 | * @AclAncestor("orocrm_contact_view") |
|
68 | * @return Response |
|
69 | */ |
|
70 | public function getPrimaryAction($contactId) |
|
71 | { |
|
72 | /** @var Contact $contact */ |
|
73 | $contact = $this->getContactManager()->find($contactId); |
|
74 | ||
75 | if ($contact) { |
|
76 | $phone = $contact->getPrimaryPhone(); |
|
77 | } else { |
|
78 | $phone = null; |
|
79 | } |
|
80 | ||
81 | $responseData = $phone ? json_encode($this->getPreparedItem($phone)) : ''; |
|
82 | ||
83 | return new Response($responseData, $phone ? Codes::HTTP_OK : Codes::HTTP_NOT_FOUND); |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * Create entity ContactPhone |