فهرست منبع

Split AdminInterface into two interfaces

Right now, the AdminInterface is way too big for anyone considering
implementing it. It should be split into smaller interfaces.
Grégoire Paris 8 سال پیش
والد
کامیت
89d9c40992
2فایلهای تغییر یافته به همراه123 افزوده شده و 103 حذف شده
  1. 1 103
      Admin/AdminInterface.php
  2. 122 0
      Admin/FieldDescriptionRegistryInterface.php

+ 1 - 103
Admin/AdminInterface.php

@@ -34,7 +34,7 @@ use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
 /**
  * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  */
-interface AdminInterface
+interface AdminInterface extends FieldDescriptionRegistryInterface
 {
     /**
      * @param FormContractorInterface $formContractor
@@ -188,22 +188,6 @@ interface AdminInterface
      */
     public function getFormBuilder();
 
-    /**
-     * Return FormFieldDescription.
-     *
-     * @param string $name
-     *
-     * @return FieldDescriptionInterface
-     */
-    public function getFormFieldDescription($name);
-
-    /**
-     * Build and return the collection of form FieldDescription.
-     *
-     * @return array collection of form FieldDescription
-     */
-    public function getFormFieldDescriptions();
-
     /**
      * Returns a form depend on the given $object.
      *
@@ -326,92 +310,6 @@ interface AdminInterface
      */
     // public function isCurrentRoute($name, $adminCode = null);
 
-    /**
-     * Returns true if the admin has a FieldDescription with the given $name.
-     *
-     * @param string $name
-     *
-     * @return bool
-     */
-    public function hasShowFieldDescription($name);
-
-    /**
-     * add a FieldDescription.
-     *
-     * @param string                    $name
-     * @param FieldDescriptionInterface $fieldDescription
-     */
-    public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);
-
-    /**
-     * Remove a ShowFieldDescription.
-     *
-     * @param string $name
-     */
-    public function removeShowFieldDescription($name);
-
-    /**
-     * add a list FieldDescription.
-     *
-     * @param string                    $name
-     * @param FieldDescriptionInterface $fieldDescription
-     */
-    public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);
-
-    /**
-     * Remove a list FieldDescription.
-     *
-     * @param string $name
-     */
-    public function removeListFieldDescription($name);
-
-    /**
-     * Returns true if the filter FieldDescription exists.
-     *
-     * @param string $name
-     *
-     * @return bool
-     */
-    public function hasFilterFieldDescription($name);
-
-    /**
-     * add a filter FieldDescription.
-     *
-     * @param string                    $name
-     * @param FieldDescriptionInterface $fieldDescription
-     */
-    public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription);
-
-    /**
-     * Remove a filter FieldDescription.
-     *
-     * @param string $name
-     */
-    public function removeFilterFieldDescription($name);
-
-    /**
-     * Returns the filter FieldDescription collection.
-     *
-     * @return FieldDescriptionInterface[]
-     */
-    public function getFilterFieldDescriptions();
-
-    /**
-     * Returns a filter FieldDescription.
-     *
-     * @param string $name
-     *
-     * @return FieldDescriptionInterface|null
-     */
-    public function getFilterFieldDescription($name);
-
-    /**
-     * Returns a list depend on the given $object.
-     *
-     * @return FieldDescriptionCollection
-     */
-    public function getList();
-
     /**
      * @param SecurityHandlerInterface $securityHandler
      */

+ 122 - 0
Admin/FieldDescriptionRegistryInterface.php

@@ -0,0 +1,122 @@
+<?php
+
+/*
+ * This file is part of the Sonata Project package.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\AdminBundle\Admin;
+
+/**
+ * Implementations should provide arrays of FieldDescriptionInterface instances.
+ *
+ * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ */
+interface FieldDescriptionRegistryInterface
+{
+    /**
+     * Return FormFieldDescription.
+     *
+     * @param string $name
+     *
+     * @return FieldDescriptionInterface
+     */
+    public function getFormFieldDescription($name);
+
+    /**
+     * Build and return the collection of form FieldDescription.
+     *
+     * @return FieldDescriptionInterface[] collection of form FieldDescription
+     */
+    public function getFormFieldDescriptions();
+
+    /**
+     * Returns true if the admin has a FieldDescription with the given $name.
+     *
+     * @param string $name
+     *
+     * @return bool
+     */
+    public function hasShowFieldDescription($name);
+
+    /**
+     * Adds a FieldDescription.
+     *
+     * @param string                    $name
+     * @param FieldDescriptionInterface $fieldDescription
+     */
+    public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);
+
+    /**
+     * Removes a ShowFieldDescription.
+     *
+     * @param string $name
+     */
+    public function removeShowFieldDescription($name);
+
+    /**
+     * Adds a list FieldDescription.
+     *
+     * @param string                    $name
+     * @param FieldDescriptionInterface $fieldDescription
+     */
+    public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);
+
+    /**
+     * Removes a list FieldDescription.
+     *
+     * @param string $name
+     */
+    public function removeListFieldDescription($name);
+
+    /**
+     * Returns a list depend on the given $object.
+     *
+     * @return FieldDescriptionCollection
+     */
+    public function getList();
+
+    /**
+     * Returns true if the filter FieldDescription exists.
+     *
+     * @param string $name
+     *
+     * @return bool
+     */
+    public function hasFilterFieldDescription($name);
+
+    /**
+     * Adds a filter FieldDescription.
+     *
+     * @param string                    $name
+     * @param FieldDescriptionInterface $fieldDescription
+     */
+    public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription);
+
+    /**
+     * Removes a filter FieldDescription.
+     *
+     * @param string $name
+     */
+    public function removeFilterFieldDescription($name);
+
+    /**
+     * Returns the filter FieldDescription collection.
+     *
+     * @return FieldDescriptionInterface[]
+     */
+    public function getFilterFieldDescriptions();
+
+    /**
+     * Returns a filter FieldDescription.
+     *
+     * @param string $name
+     *
+     * @return FieldDescriptionInterface|null
+     */
+    public function getFilterFieldDescription($name);
+}