浏览代码

[DomCrawler] tweaked public @api

Fabien Potencier 14 年之前
父节点
当前提交
54e054b2d1

+ 2 - 0
src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php

@@ -47,6 +47,8 @@ class ChoiceFormField extends FormField
      * @param string $value The value of the field
      *
      * @throws \InvalidArgumentException When value type provided is not correct
+     *
+     * @api
      */
     public function select($value)
     {

+ 2 - 0
src/Symfony/Component/DomCrawler/Field/FormField.php

@@ -68,6 +68,8 @@ abstract class FormField
      * Sets the value of the field.
      *
      * @param string $value The value of the field
+     *
+     * @api
      */
     public function setValue($value)
     {

+ 17 - 17
src/Symfony/Component/DomCrawler/Form.php

@@ -44,23 +44,6 @@ class Form extends Link implements \ArrayAccess
         $this->initialize();
     }
 
-    protected function setNode(\DOMNode $node)
-    {
-        $this->button = $node;
-        if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) {
-            do {
-                // use the ancestor form element
-                if (null === $node = $node->parentNode) {
-                    throw new \LogicException('The selected node does not have a form ancestor.');
-                }
-            } while ('form' != $node->nodeName);
-        } else {
-            throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
-        }
-
-        $this->node = $node;
-    }
-
     /**
      * Gets the form node associated with this form.
      *
@@ -380,4 +363,21 @@ class Form extends Link implements \ArrayAccess
     {
         $this->remove($name);
     }
+
+    protected function setNode(\DOMNode $node)
+    {
+        $this->button = $node;
+        if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) {
+            do {
+                // use the ancestor form element
+                if (null === $node = $node->parentNode) {
+                    throw new \LogicException('The selected node does not have a form ancestor.');
+                }
+            } while ('form' != $node->nodeName);
+        } else {
+            throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
+        }
+
+        $this->node = $node;
+    }
 }

+ 18 - 18
src/Symfony/Component/DomCrawler/Link.php

@@ -46,15 +46,6 @@ class Link
         $this->currentUri = $currentUri;
     }
 
-    protected function setNode(\DOMNode $node)
-    {
-        if ('a' != $node->nodeName) {
-            throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName));
-        }
-
-        $this->node = $node;
-    }
-
     /**
      * Gets the node associated with this link.
      *
@@ -65,6 +56,18 @@ class Link
         return $this->node;
     }
 
+    /**
+     * Gets the method associated with this link.
+     *
+     * @return string The method
+     *
+     * @api
+     */
+    public function getMethod()
+    {
+        return $this->method;
+    }
+
     /**
      * Gets the URI associated with this link.
      *
@@ -105,15 +108,12 @@ class Link
         return $this->node->getAttribute('href');
     }
 
-    /**
-     * Gets the method associated with this link.
-     *
-     * @return string The method
-     *
-     * @api
-     */
-    public function getMethod()
+    protected function setNode(\DOMNode $node)
     {
-        return $this->method;
+        if ('a' != $node->nodeName) {
+            throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName));
+        }
+
+        $this->node = $node;
     }
 }