| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class BinaryIPExtension extends DataExtension |
||
| 17 | { |
||
| 18 | private static $db = [ |
||
|
|
|||
| 19 | "IP" => "BinaryIP" |
||
| 20 | ]; |
||
| 21 | |||
| 22 | public function onBeforeWrite() |
||
| 23 | { |
||
| 24 | $controller = Controller::curr(); |
||
| 25 | // This is best used when IP is set on creation |
||
| 26 | if (!$this->owner->IP) { |
||
| 27 | $ip = $controller->getRequest()->getIP(); |
||
| 28 | $this->owner->IP = $ip; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * This require geotools module |
||
| 34 | * |
||
| 35 | * @return \LeKoala\GeoTools\Models\Address|null |
||
| 36 | */ |
||
| 37 | public function getIpLocationDetails() |
||
| 44 | } |
||
| 45 | } |
||
| 46 |