소스 검색

FD3-498 interface

Guillermo Espinoza 7 년 전
부모
커밋
8e443407aa
3개의 변경된 파일26개의 추가작업 그리고 8개의 파일을 삭제
  1. 13 0
      src/KeaBundle/Interfaces/KeaConfigInterface.php
  2. 2 1
      src/KeaBundle/Services/BaseKea.php
  3. 11 7
      src/KeaBundle/Services/KeaConfigService.php

+ 13 - 0
src/KeaBundle/Interfaces/KeaConfigInterface.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace KeaBundle\Interfaces;
+
+interface KeaConfigInterface
+{
+
+    /**
+     * @return string
+     */
+    public function getConfig();
+
+}

+ 2 - 1
src/KeaBundle/Services/BaseKea.php

@@ -3,8 +3,9 @@
 namespace KeaBundle\Services;
 
 use IPv4Bundle\Entity\Host;
+use KeaBundle\Interfaces\KeaConfigInterface;
 
-class BaseKea
+class BaseKea implements KeaConfigInterface
 {
 
     /**

+ 11 - 7
src/KeaBundle/Services/KeaConfigService.php

@@ -2,6 +2,8 @@
 
 namespace KeaBundle\Services;
 
+use KeaBundle\Interfaces\KeaConfigInterface;
+
 class KeaConfigService
 {
 
@@ -43,14 +45,16 @@ class KeaConfigService
         $config = '';
         $fullClass = 'KeaBundle\\Services\\' . $className;
         if (class_exists($fullClass)) {
-            $data = [
-                'dhcp' => $this->dhcpRepository->find($id),
-                'hosts' => $this->hostRepository->findAll(),
-                'subnets' => $this->subnetRepository->findAll(),
-                'library' => $library,
-            ];
             $keaConfig = new $fullClass;
-            $config = $keaConfig->getConfig($data);
+            if ($keaConfig instanceof KeaConfigInterface) {
+                $data = [
+                    'dhcp' => $this->dhcpRepository->find($id),
+                    'hosts' => $this->hostRepository->findAll(),
+                    'subnets' => $this->subnetRepository->findAll(),
+                    'library' => $library,
+                ];
+                $config = $keaConfig->getConfig($data);
+            }
         }
 
         return $config;