[Pkg-owncloud-commits] [owncloud-doc] 87/270: add hints about default parameters

David Prévot taffit at moszumanska.debian.org
Thu Jul 31 03:53:04 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud-doc.

commit 5bed7721319b9dc4b67229894207bcdd27da351b
Author: Bernhard Posselt <dev at bernhard-posselt.com>
Date:   Tue May 13 12:15:17 2014 +0200

    add hints about default parameters
---
 developer_manual/app/controllers.rst | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/developer_manual/app/controllers.rst b/developer_manual/app/controllers.rst
index f88877e..70d3e6c 100644
--- a/developer_manual/app/controllers.rst
+++ b/developer_manual/app/controllers.rst
@@ -110,6 +110,30 @@ All those parameters can easily be accessed by adding them to the controller met
 
     }
 
+It is also possible to set default parameter values by using PHP default method values so common values can be ommited:
+
+.. code-block:: php
+
+    <?php
+    namespace OCA\MyApp\Controller;
+
+    use \OCP\AppFramework\Controller;
+
+    class PageController extends Controller {
+
+        /**
+         * @param int $id
+         */
+        public function doSomething($id, $name='john', $job='author') {
+            // GET ?id=3&job=killer
+            // $id = 3
+            // $name = 'john'
+            // $job = 'killer'
+        }
+
+    }
+
+
 Casting parameters
 ------------------
 URL, GET and application/x-www-form-urlencoded have the problem that every parameter is a string, meaning that::

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-doc.git



More information about the Pkg-owncloud-commits mailing list