Skip to content

Commit e4bb071

Browse files
committed
OS2FORMS-358 CVR Datafordeler
1 parent e9337b0 commit e4bb071

File tree

6 files changed

+573
-4
lines changed

6 files changed

+573
-4
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,15 @@ See [OS2Web git name convention](https://github.com/OS2Web/docs#git-guideline)
3636
### Using services in other modules
3737

3838
```
39-
// CVR lookup.
40-
\Drupal::service('plugin.manager.os2web_datalookup')->createInstance('serviceplatformen_cvr')->getLegalUnit('[CVR number]')
39+
// CVR lookup
40+
/** @var \Drupal\os2web_datalookup\Plugin\DataLookupManager $pluginManager */
41+
$pluginManager = \Drupal::service('plugin.manager.os2web_datalookup');
42+
/** @var \Drupal\os2web_datalookup\Plugin\os2web\DataLookup\DataLookupInterfaceCvr $cvrPlugin */
43+
$cvrPlugin = $pluginManager->createDefaultInstanceByGroup('cvr_lookup');
44+
45+
if ($cvrPlugin->isReady()) {
46+
$cvrResult = $cvrPlugin->lookup(cvr);
47+
}
4148
4249
// CPR lookup.
4350
/** @var \Drupal\os2web_datalookup\Plugin\DataLookupManager $pluginManager */
@@ -49,6 +56,10 @@ if ($cprPlugin->isReady()) {
4956
$cprResult = $cprPlugin->lookup($cpr);
5057
}
5158
59+
// CVR lookup - DEPRECATED.
60+
\Drupal::service('plugin.manager.os2web_datalookup')->createInstance('serviceplatformen_cvr')->getLegalUnit('[CVR number]')
61+
62+
5263
// CPP lookup - DEPRECATED.
5364
\Drupal::service('plugin.manager.os2web_datalookup')->createInstance('serviceplatformen_cpr')->cprBasicInformation('[CPR number]'))
5465
```
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
<?php
2+
3+
namespace Drupal\os2web_datalookup\LookupResult;
4+
5+
class CvrLookupResult {
6+
7+
const CVR = 'cvr';
8+
const NAME = 'name';
9+
const STREET = 'street';
10+
const HOUSE_NR = 'houseNr';
11+
const FLOOR = 'floor';
12+
const APARTMENT_NR = 'apartmentNr';
13+
const POSTAL_CODE = 'postalCode';
14+
const CITY = 'city';
15+
const MUNICIPALITY_CODE = 'municipalityCode';
16+
const ADDRESS = 'address';
17+
18+
/**
19+
* Is request successful.
20+
*
21+
* @var bool
22+
*/
23+
protected $successful = FALSE;
24+
25+
/**
26+
* Status of the request.
27+
*
28+
* @var string
29+
*/
30+
protected $errorMessage;
31+
32+
/**
33+
* CVR
34+
*
35+
* @var string
36+
*/
37+
protected $cvr;
38+
39+
/**
40+
* Company name.
41+
*
42+
* @var string
43+
*/
44+
protected $name;
45+
46+
/**
47+
* Street of the person.
48+
*
49+
* @var string
50+
*/
51+
protected $street;
52+
53+
/**
54+
* Street house number of the person.
55+
*
56+
* @var string
57+
*/
58+
protected $houseNr;
59+
60+
/**
61+
* Floor number the person.
62+
*
63+
* @var string
64+
*/
65+
protected $floor;
66+
67+
/**
68+
* Apartment number of the person.
69+
*
70+
* @var string
71+
*/
72+
protected $apartmentNr;
73+
74+
/**
75+
* Postal code of the person.
76+
*
77+
* @var string
78+
*/
79+
protected $postalCode;
80+
81+
/**
82+
* City of the person.
83+
*
84+
* @var string
85+
*/
86+
protected $city;
87+
88+
/**
89+
* Municipality code of the person.
90+
*
91+
* @var string
92+
*/
93+
protected $municipalityCode;
94+
95+
/**
96+
* Address of the person.
97+
*
98+
* @var string
99+
*/
100+
protected $address;
101+
102+
/**
103+
* @return bool
104+
*/
105+
public function isSuccessful(): bool {
106+
return $this->successful;
107+
}
108+
109+
/**
110+
* @param bool $successful
111+
*/
112+
public function setSuccessful(bool $successful = TRUE): void {
113+
$this->successful = $successful;
114+
}
115+
116+
/**
117+
* @return string
118+
*/
119+
public function getErrorMessage(): string {
120+
return $this->errorMessage;
121+
}
122+
123+
/**
124+
* @param string $errorMessage
125+
*/
126+
public function setErrorMessage(string $errorMessage): void {
127+
$this->errorMessage = $errorMessage;
128+
}
129+
130+
/**
131+
* @return string
132+
*/
133+
public function getCvr(): string {
134+
return $this->cvr;
135+
}
136+
137+
/**
138+
* @param string $cpr
139+
*/
140+
public function setCvr(string $cpr): void {
141+
$this->cvr = $cpr;
142+
}
143+
144+
/**
145+
* @return string
146+
*/
147+
public function getName(): string {
148+
return $this->name;
149+
}
150+
151+
/**
152+
* @param string $name
153+
*/
154+
public function setName(string $name): void {
155+
$this->name = $name;
156+
}
157+
158+
/**
159+
* @return string
160+
*/
161+
public function getStreet(): string {
162+
return $this->street;
163+
}
164+
165+
/**
166+
* @param string $street
167+
*/
168+
public function setStreet(string $street): void {
169+
$this->street = $street;
170+
}
171+
172+
/**
173+
* @return string
174+
*/
175+
public function getHouseNr(): string {
176+
return $this->houseNr;
177+
}
178+
179+
/**
180+
* @param string $houseNr
181+
*/
182+
public function setHouseNr(string $houseNr): void {
183+
$this->houseNr = $houseNr;
184+
}
185+
186+
/**
187+
* @return string
188+
*/
189+
public function getFloor(): string {
190+
return $this->floor;
191+
}
192+
193+
/**
194+
* @param string $floor
195+
*/
196+
public function setFloor(string $floor): void {
197+
$this->floor = $floor;
198+
}
199+
200+
/**
201+
* @return string
202+
*/
203+
public function getApartmentNr(): string {
204+
return $this->apartmentNr;
205+
}
206+
207+
/**
208+
* @param string $apartmentNr
209+
*/
210+
public function setApartmentNr(string $apartmentNr): void {
211+
$this->apartmentNr = $apartmentNr;
212+
}
213+
214+
/**
215+
* @return string
216+
*/
217+
public function getPostalCode(): string {
218+
return $this->postalCode;
219+
}
220+
221+
/**
222+
* @param string $postalCode
223+
*/
224+
public function setPostalCode(string $postalCode): void {
225+
$this->postalCode = $postalCode;
226+
}
227+
228+
/**
229+
* @return string
230+
*/
231+
public function getCity(): string {
232+
return $this->city;
233+
}
234+
235+
/**
236+
* @param string $city
237+
*/
238+
public function setCity(string $city): void {
239+
$this->city = $city;
240+
}
241+
242+
/**
243+
* @return string
244+
*/
245+
public function getMunicipalityCode(): string {
246+
return $this->municipalityCode;
247+
}
248+
249+
/**
250+
* @param string $municipalityCode
251+
*/
252+
public function setMunicipalityCode(string $municipalityCode): void {
253+
$this->municipalityCode = $municipalityCode;
254+
}
255+
256+
/**
257+
* @return string
258+
*/
259+
public function getAddress(): string {
260+
return $this->address;
261+
}
262+
263+
/**
264+
* @param string $address
265+
*/
266+
public function setAddress(string $address): void {
267+
$this->address = $address;
268+
}
269+
270+
/**
271+
* Returns the value of the provided field.
272+
*
273+
* @param $field
274+
* Field name.
275+
*
276+
* @return mixed
277+
*/
278+
public function getFieldValue($field) {
279+
if (property_exists($this, $field)) {
280+
return $this->{$field};
281+
}
282+
283+
return '';
284+
}
285+
286+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup;
4+
5+
interface DataLookupInterfaceCvr extends DataLookupInterface {
6+
7+
/**
8+
* Performs lookup for the provided CVR.
9+
*
10+
* @param string $cvr
11+
* The CVR number to query for.
12+
*
13+
* @return \Drupal\os2web_datalookup\LookupResult\CvrLookupResult
14+
* The CVR lookup Result.
15+
*/
16+
public function lookup($cvr);
17+
18+
}

0 commit comments

Comments
 (0)