added appframework api files

This commit is contained in:
Bernhard Posselt
2013-01-26 16:31:08 +01:00
parent 47426f01b5
commit fe3a8d3910
32 changed files with 1196 additions and 6 deletions

View File

@@ -10,5 +10,4 @@ ownCloud API
filesystem
hooks
share-api
templates
vcategories

View File

@@ -3,7 +3,7 @@ API abstraction layer
.. sectionauthor:: Bernhard Posselt <nukeawhale@gmail.com>
Owncloud currently has a ton of static methods which is a very bad thing concerning testability. Therefore the appframework comes with an API abstraction layer (basically a `facade <http://en.wikipedia.org/wiki/Facade_pattern>`_) which is located in the appframework app at :file:`core/api.php`.
ownCloud currently has a ton of static methods which is a very bad thing concerning testability. Therefore the appframework comes with an :php:class:`OCA\\AppFramework\\Core\\API` abstraction layer (basically a `facade <http://en.wikipedia.org/wiki/Facade_pattern>`_) which is located in the appframework app at :file:`core/api.php`.
If you find yourself in need to use more ownCloud internal static methods, add them to the API class in the appframework directory, like:
@@ -36,4 +36,3 @@ You could of course also simply inherit from the API class and overwrite the API
This will allow you to easily mock the API in your unittests.
.. note:: This will eventually be replaced with an internal Owncloud API layer.

View File

@@ -3,7 +3,7 @@ Controllers
.. sectionauthor:: Bernhard Posselt <nukeawhale@gmail.com>
The appframework app provides a simple baseclass for adding controllers. Controllers connect your view (templates) with your database. Controllers themselves are connected to one or more routes. Controllers go into the :file:`controller` directory.
The appframework app provides a simple baseclass for adding controllers: :php:class:`OCA\\AppFramework\\Controller\\Controller`. Controllers connect your view (templates) with your database. Controllers themselves are connected to one or more routes. Controllers go into the :file:`controller` directory.
A controller should be created for each resource. Think of it as an URL scheme::

View File

@@ -25,6 +25,8 @@ A simple route would look like this:
);
:php:class:`OCA\\AppFramework\\App`
The first argument is the name of your route. This is used as an identifier to get the URL of the route and is a nice way to generate the URL in your templates or JavaScript for certain links since it does not force you to hardcode your URLs. To use it in OC templates, use:
.. code-block:: php

View File

@@ -0,0 +1,25 @@
App
===
Entry point for every request in your app.
You can consider this as your
public static void main() method
Handles all the dependency injection, controllers and output flow
.. php:namespace:: OCA\AppFramework
.. php:class:: App
.. php:staticmethod:: App::main($controllerName, $methodName, $urlParams, $container)
:param string $controllerName: the name of the controller under which it is stored in the DI container
:param string $methodName: the method that you want to call
:param array $urlParams: an array with variables extracted from the routes
:param \\Pimple $container: an instance of a pimple container. if not passed, a new one will be instantiated. This can be used to swap or overwrite objects in the container.
Shortcut for calling a controller method and printing the result

View File

@@ -0,0 +1,75 @@
Controller
==========
Baseclass to inherit your controllers from
.. php:namespace:: OCA\AppFramework\Controller
.. php:class:: Controller
* **Abstract**
.. php:attr:: $api
* **Protected**
None
.. php:method:: __construct($api, $request)
:param \\OCA\\AppFramework\\Core\\API $api: an api wrapper instance
:param \\OCA\\AppFramework\\Http\\Request $request: an instance of the request
.. php:method:: setURLParams($urlParams=array())
:param array $urlParams:
URL params are passed to this method from the routes dispatcher to be available via the $this->params
.. php:method:: params($key, $default=null)
:param string $key: the key which you want to access in the URL Parameter placeholder, $_POST or $_GET array. The priority how they're returned is the following: 1. URL parameters 2. POST parameters 3. GET parameters
:param mixed $default: If the key is not found, this value will be returned
:returns mixed: the content of the array
Lets you access post and get parameters by the index
.. php:method:: getUploadedFile($key)
:param string $key: the key that will be taken from the $_FILES array
:returns array: the file in the $_FILES element
Shortcut for accessing an uploaded file through the $_FILES array
.. php:method:: render($templateName, $params=array(), $renderAs='user', $headers=array())
:param string $templateName: the name of the template
:param array $params: the template parameters in key => value structure
:param string $renderAs: user renders a full page, blank only your template admin an entry in the admin settings
:param array $headers: set additional headers
:returns \\OCA\\AppFramework\\Http\\TemplateResponse: containing the page
Shortcut for rendering a template
.. php:method:: renderJSON($data, $errorMsg=null)
:param array $data: the PHP array that will be put into the JSON data index
:param string $errorMsg: If you want to return an error message, pass one
:returns \\OCA\\AppFramework\\Http\\JSONResponse: containing the values
Shortcut for rendering a JSON response

View File

@@ -0,0 +1,243 @@
API
===
This is used to wrap the owncloud static api calls into an object to make the
code better abstractable for use in the dependency injection container
Should you find yourself in need for more methods, simply inherit from this
class and add your methods
.. php:namespace:: OCA\AppFramework\Core
.. php:class:: API
.. php:method:: __construct($appName)
:param string $appName: the name of your application
constructor
.. php:method:: getAppName()
:returns string: the name of your application
used to return the appname of the set application
.. php:method:: getUserId()
:returns string: the user id of the current user
Gets the userid of the current user
.. php:method:: activateNavigationEntry()
Sets the current navigation entry to the currently running app
.. php:method:: addScript($scriptName)
:param string $scriptName: the name of the javascript in js/ without the suffix
Adds a new javascript file
.. php:method:: addStyle($styleName)
:param string $styleName: the name of the css file in css/without the suffix
Adds a new css file
.. php:method:: add3rdPartyScript($name)
:param string $name: the name of the file without the suffix
shorthand for addScript for files in the 3rdparty directory
.. php:method:: add3rdPartyStyle($name)
:param string $name: the name of the file without the suffix
shorthand for addStyle for files in the 3rdparty directory
.. php:method:: getSystemValue($key)
:param string $key: the key of the value, under which it was saved
:returns string: the saved value
Looks up a systemwide defined value
.. php:method:: setSystemValue($key, $value)
:param string $key: the key of the value, under which will be saved
:param string $value: the value that should be stored
Sets a new systemwide value
.. php:method:: setUserValue($key, $value, $userId=null)
:param string $key: the key under which the value is being stored
:param string $value: the value that you want to store
:param string $userId: the userId of the user that we want to store the value under, defaults to the current one
Shortcut for setting a user defined value
.. php:method:: getUserValue($key, $userId=null)
:param string $key: the key under which the value is being stored
:param string $userId: the userId of the user that we want to store the value under, defaults to the current one
Shortcut for getting a user defined value
.. php:method:: getTrans()
:returns \\OC_L10N: the translation object
Returns the translation object
.. php:method:: prepareQuery($sql, $limit=null, $offset=null)
:param string $sql: the sql query with ? placeholder for params
:param int $limit: the maximum number of rows
:param int $offset: from which row we want to start
:returns \\OCP\\DB: a query object
Used to abstract the owncloud database access away
.. php:method:: getInsertId($tableName)
:param string $tableName: the name of the table where we inserted the item
:returns int: the id of the inserted element
Used to get the id of the just inserted element
.. php:method:: linkToRoute($routeName, $arguments=array())
:param string $routeName: the name of the route
:param array $arguments: an array with arguments which will be filled into the url
:returns string: the url
Returns the URL for a route
.. php:method:: linkToAbsolute($file, $appName=null)
:param string $file: the name of the file
:param string $appName: the name of the app, defaults to the current one
:returns string: the url
.. warning:: **DEPRECATED**: replaced with linkToRoute()
links to a file
.. php:method:: isLoggedIn()
:returns bool: true if logged in
Checks if the current user is logged in
.. php:method:: isAdminUser($userId)
:param string $userId: the id of the user
:returns bool: true if admin
Checks if a user is an admin
.. php:method:: isSubAdminUser($userId)
:param string $userId: the id of the user
:returns bool: true if subadmin
Checks if a user is an subadmin
.. php:method:: passesCSRFCheck()
:returns bool: true if CSRF check passed
Checks if the CSRF check was correct
.. php:method:: isAppEnabled($appName)
:param string $appName: the name of an app
:returns bool: true if app is enabled
Checks if an app is enabled
.. php:method:: log($msg, $level=null)
:param string $msg: the error message to be logged
:param int $level: the error level
Writes a function into the error log
.. php:method:: getTemplate($templateName, $renderAs='user', $appName=null)
:param string $templateName: the name of the template
:param string $renderAs: how it should be rendered
:param string $appName: the name of the app
:returns \\OCP\\Template: a new template
Returns a template
.. php:method:: getLocalFilePath($path)
:param string $path: path the path to the file on the oc filesystem
:returns string: the filepath in the filesystem
turns an owncloud path into a path on the filesystem
.. php:method:: openEventSource()
:returns \\OC_EventSource: a new open EventSource class
used to return and open a new eventsource

View File

@@ -0,0 +1,18 @@
DoesNotExistException
=====================
This is returned or should be returned when a find request does not find an
entry in the database
.. php:namespace:: OCA\AppFramework\Db
.. php:class:: DoesNotExistException
.. php:method:: __construct($msg)
:param mixed $msg:

View File

@@ -0,0 +1,69 @@
Mapper
======
Simple parent class for inheriting your data access layer from.
This class
may be subject to change in the future
.. php:namespace:: OCA\AppFramework\Db
.. php:class:: Mapper
* **Abstract**
.. php:method:: __construct($api)
:param \\OCA\\AppFramework\\Core\\API $api: Instance of the API abstraction layer
.. php:method:: findQuery($tableName, $id)
:param string $tableName: the name of the table to query
:param int $id: the id of the item
:throws \\OCA\\AppFramework\\Db\\DoesNotExistException: if the item does not exist
:returns array: the result as row
* **Protected**
Returns an db result by id
.. php:method:: findAllQuery($tableName)
:param string $tableName: the name of the table to query
:returns \\PDOStatement: the result
* **Protected**
Returns all entries of a table
.. php:method:: deleteQuery($tableName, $id)
:param string $tableName: the name of the table to query
:param int $id: the id of the item
* **Protected**
Deletes a row in a table by id
.. php:method:: execute($sql, $params=array(), $limit=null, $offset=null)
:param string $sql: the prepare string
:param array $params: the params which should replace the ? in the sql query
:param int $limit: the maximum number of rows
:param int $offset: from which row we want to start
:returns \\PDOStatement: the database query result
* **Protected**
Runs an sql query

View File

@@ -0,0 +1,22 @@
DIContainer
===========
This class extends Pimple (http://pimple.sensiolabs.org/) for reusability
To use this class, extend your own container from this.
Should you require it
you can overwrite the dependencies with your own classes by simply redefining
a dependency
.. php:namespace:: OCA\AppFramework\DependencyInjection
.. php:class:: DIContainer
.. php:method:: __construct($appName)
:param string $appName: the name of the app
Put your class dependencies in here

View File

@@ -0,0 +1,22 @@
DownloadResponse
================
Prompts the user to download the a textfile
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: DownloadResponse
* **Abstract**
.. php:method:: __construct($filename, $contentType)
:param string $filename: the name that the downloaded file should have
:param string $contentType: the mimetype that the downloaded file should have
Creates a response that prompts the user to download the file

View File

@@ -0,0 +1,48 @@
JSONResponse
============
A renderer for JSON calls
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: JSONResponse
.. php:method:: __construct()
.. php:method:: setParams($params)
:param array $params: an array with key => value structure which will be transformed to JSON
Sets values in the data json array
.. php:method:: getParams()
:returns array: the params
Used to get the set parameters
.. php:method:: setErrorMessage($msg)
:param mixed $msg:
in case we want to render an error message, also logs into the owncloud log
.. php:method:: render()
:returns string: the rendered json
Returns the rendered json

View File

@@ -0,0 +1,25 @@
RedirectResponse
================
Prompts the user to download the a textfile
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: RedirectResponse
.. php:method:: __construct($redirectURL)
:param string $redirectURL: the url to redirect to
Creates a response that redirects to a url
.. php:method:: getRedirectURL()
:returns string: the url to redirect

View File

@@ -0,0 +1,48 @@
Request
=======
Encapsulates $_GET, $_FILES and $_POST arrays for better testability
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: Request
.. php:method:: __construct($get=array(), $post=array(), $files=array())
:param array $get: the $_GET array
:param array $post: the $_POST array
:param array $files: the $_FILES array
.. php:method:: getGET($key, $default=null)
:param string $key: the array key that should be looked up
:param string $default: if the key is not found, return this value
:returns mixed: the value of the stored array or the default
Returns the get value or the default if not found
.. php:method:: getPOST($key, $default=null)
:param string $key: the array key that should be looked up
:param string $default: if the key is not found, return this value
:returns mixed: the value of the stored array or the default
Returns the get value or the default if not found
.. php:method:: getFILES($key)
:param string $key: the array key that should be looked up
:returns mixed: the value of the stored array or the default
Returns the get value of the files array

View File

@@ -0,0 +1,40 @@
Response
========
Baseclass for responses.
Also used to just send headers
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: Response
.. php:method:: __construct()
.. php:method:: addHeader($header)
:param string $header: header the string that will be used in the header() function
Adds a new header to the response that will be called before the renderfunction
.. php:method:: render()
:returns null:
By default renders no output
.. php:method:: getHeaders()
:returns array: the headers
Returns the set headers

View File

@@ -0,0 +1,97 @@
TemplateResponse
================
Response for a normal template
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: TemplateResponse
.. php:attr:: $templateName
* **Protected**
.. php:attr:: $params
* **Protected**
.. php:attr:: $api
* **Protected**
.. php:attr:: $renderAs
* **Protected**
.. php:attr:: $appName
* **Protected**
.. php:method:: __construct($api, $templateName, $appName=null)
:param \\OCA\\AppFramework\\Core\\API $api: an API instance
:param string $templateName: the name of the template
:param string $appName: optional if you want to include a template from a different app
.. php:method:: setParams($params)
:param array $params: an array with key => value structure which sets template variables
Sets template parameters
.. php:method:: getParams()
:returns array: the params
Used for accessing the set parameters
.. php:method:: getTemplateName()
:returns string: the name of the used template
Used for accessing the name of the set template
.. php:method:: renderAs($renderAs)
:param string $renderAs: admin, user or blank. Admin also prints the admin settings header and footer, user renders the normal normal page including footer and header and blank just renders the plain template
Sets the template page
.. php:method:: getRenderAs()
:returns string: the renderAs value
Returns the set renderAs
.. php:method:: render()
:returns string: the rendered html
Returns the rendered html

View File

@@ -0,0 +1,29 @@
TextDownloadResponse
====================
Prompts the user to download the a textfile
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: TextDownloadResponse
.. php:method:: __construct($content, $filename, $contentType)
:param string $content: the content that should be written into the file
:param string $filename: the name that the downloaded file should have
:param string $contentType: the mimetype that the downloaded file should have
Creates a response that prompts the user to download a file whichcontains the passed string
.. php:method:: render()
:returns string: the file contents
Simply sets the headers and returns the file contents

View File

@@ -0,0 +1,27 @@
TextResponse
============
Prompts the user to download the a textfile
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: TextResponse
.. php:method:: __construct($content)
:param string $content: the content that should be written into the file
Creates a response that just outputs text
.. php:method:: render()
:returns string: the file contents
Simply sets the headers and returns the file contents

View File

@@ -0,0 +1,31 @@
TwigResponse
============
Response for twig templates.
Do not use this directly to render your
templates, unless you want a blank page because the owncloud header and
footer won't be included
.. php:namespace:: OCA\AppFramework\Http
.. php:class:: TwigResponse
.. php:method:: __construct($api, $templateName, $twig)
:param \\OCA\\AppFramework\\Core\\API $api: an api instance
:param string $templateName: the name of the twig template
:param \\OCA\\AppFramework\\Http\\Twig_Environment $twig: an instance of the twig environment for rendering
Instantiates the Twig Template
.. php:method:: render()
:returns string: rendered output
Returns the rendered result

View File

@@ -0,0 +1,30 @@
================
AppFramework API
================
.. toctree::
:maxdepth: 1
app
controller_controller
core_api
db_doesnotexistexception
db_mapper
dependencyinjection_dicontainer
http_response
http_downloadresponse
http_jsonresponse
http_redirectresponse
http_templateresponse
http_textresponse
http_textdownloadresponse
http_twigresponse
http_request
middleware_middleware
middleware_middlewaredispatcher
middleware_security_securitymiddleware
middleware_security_securityexception
middleware_twig_twigmiddleware
utility_controllertestutility
utility_methodannotationreader

View File

@@ -0,0 +1,60 @@
Middleware
==========
Middleware is used to provide hooks before or after controller methods and
deal with possible exceptions raised in the controller methods.
They're modeled after Django's middleware system:
https://docs.djangoproject.com/en/dev/topics/http/middleware/
.. php:namespace:: OCA\AppFramework\Middleware
.. php:class:: Middleware
* **Abstract**
.. php:method:: beforeController($controller, $methodName)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
This is being run in normal order before the controller is beingcalled which allows several modifications and checks
.. php:method:: afterException($controller, $methodName, $exception)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param \\Exception $exception: the thrown exception
:returns \\OCA\\AppFramework\\Http\\Response: a Response object or null in case that the exception could not be handled
This is being run when either the beforeController method or thecontroller method itself is throwing an exception.
The middleware isasked in reverse order to handle the exception and to return a response.If the response is null, it is assumed that the exception could not behandled and the error will be thrown again
.. php:method:: afterController($controller, $methodName, $response)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param \\OCA\\AppFramework\\Http\\Response $response: the generated response from the controller
:returns \\OCA\\AppFramework\\Http\\Response: a Response object
This is being run after a successful controllermethod call and allowsthe manipulation of a Response object.
The middleware is run in reverse order
.. php:method:: beforeOutput($controller, $methodName, $output)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param string $output: the generated output from a response
:returns string: the output that should be printed
This is being run after the response object has been rendered andallows the manipulation of the output.
The middleware is run in reverse order

View File

@@ -0,0 +1,79 @@
MiddlewareDispatcher
====================
This class is used to store and run all the middleware in correct order
.. php:namespace:: OCA\AppFramework\Middleware
.. php:class:: MiddlewareDispatcher
.. php:method:: __construct()
Constructor
.. php:method:: registerMiddleware($middleware)
:param \\OCA\\AppFramework\\Middleware\\Middleware $middleware: the middleware which will be added
Adds a new middleware
.. php:method:: getMiddlewares()
:returns array: the middlewares
returns an array with all middleware elements
.. php:method:: beforeController($controller, $methodName)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
This is being run in normal order before the controller is beingcalled which allows several modifications and checks
.. php:method:: afterException($controller, $methodName, $exception)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param \\Exception $exception: the thrown exception
:returns \\OCA\\AppFramework\\Http\\Response: a Response object or null in case that the exception could not behandled
This is being run when either the beforeController method or thecontroller method itself is throwing an exception.
The middleware is askedin reverse order to handle the exception and to return a response.If the response is null, it is assumed that the exception could not behandled and the error will be thrown again
.. php:method:: afterController($controller, $methodName, $response)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param \\OCA\\AppFramework\\Http\\Response $response: the generated response from the controller
:returns \\OCA\\AppFramework\\Http\\Response: a Response object
This is being run after a successful controllermethod call and allowsthe manipulation of a Response object.
The middleware is run in reverse order
.. php:method:: beforeOutput($controller, $methodName, $output)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param string $output: the generated output from a response
:returns string: the output that should be printed
This is being run after the response object has been rendered andallows the manipulation of the output.
The middleware is run in reverse order

View File

@@ -0,0 +1,26 @@
SecurityException
=================
Thrown when the security middleware encounters a security problem
.. php:namespace:: OCA\AppFramework\Middleware\Security
.. php:class:: SecurityException
.. php:method:: __construct($msg, $ajax)
:param string $msg: the security error message
:param bool $ajax: true if it resulted because of an ajax request
.. php:method:: isAjax()
:returns bool: true if exception resulted because of an ajax request
Used to check if a security exception occured in an ajax request

View File

@@ -0,0 +1,42 @@
SecurityMiddleware
==================
Used to do all the authentication and checking stuff for a controller method
It reads out the annotations of a controller method and checks which if
security things should be checked and also handles errors in case a security
check fails
.. php:namespace:: OCA\AppFramework\Middleware\Security
.. php:class:: SecurityMiddleware
.. php:method:: __construct($api)
:param \\OCA\\AppFramework\\Core\\API $api: an instance of the api
.. php:method:: beforeController($controller, $methodName)
:param \\OCA\\AppFramework\\Middleware\\Security\\string/Controller $controller: the controllername or string
:param string $methodName: the name of the method
:throws \\OCA\\AppFramework\\Middleware\\Security\\SecurityException: when a security check fails
This runs all the security checks before a method call.
Thesecurity checks are determined by inspecting the controller methodannotations
.. php:method:: afterException($controller, $methodName, $exception)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param \\Exception $exception: the thrown exception
:returns \\OCA\\AppFramework\\Http\\Response: a Response object or null in case that the exception could not be handled
If an SecurityException is being caught, ajax requests return a JSON errorresponse and non ajax requests redirect to the index

View File

@@ -0,0 +1,43 @@
TwigMiddleware
==============
This template is used to add the possibility to add twig templates
By default it is only loaded when the templatepath is set
.. php:namespace:: OCA\AppFramework\Middleware\Twig
.. php:class:: TwigMiddleware
.. php:method:: __construct($api, $twig)
:param \\OCA\\AppFramework\\Core\\API $api: an instance of the api
:param \\OCA\\AppFramework\\Middleware\\Twig\\Twig_Environment $twig: an instance of the twig environment
Sets the twig loader instance
.. php:method:: afterController($controller, $methodName, $response)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param \\OCA\\AppFramework\\Http\\Response $response: the generated response from the controller
:returns \\OCA\\AppFramework\\Http\\Response: a Response object
Swaps the template response with the twig response and stores if atemplate needs to be printed for the user or admin page
.. php:method:: beforeOutput($controller, $methodName, $output)
:param \\OCA\\AppFramework\\Controller\\Controller $controller: the controller that is being called
:param string $methodName: the name of the method that will be called on the controller
:param string $output: the generated output from a response
:returns string: the output that should be printed
In case the output is not rendered as blank page, we need to include theowncloud header and output

View File

@@ -0,0 +1,48 @@
ControllerTestUtility
=====================
Simple utility class for testing controllers
.. php:namespace:: OCA\AppFramework\Utility
.. php:class:: ControllerTestUtility
* **Abstract**
.. php:method:: getAPIMock($apiClass='OCA\AppFramework\Core\API', $constructor=array('appname'))
:param string $apiClass: the class inclusive namespace of the api that we want to use
:param array $constructor: constructor parameters of the api class
* **Protected**
Boilerplate function for getting an API Mock class
.. php:method:: assertAnnotations($controller, $method, $expected, $valid=array())
:param \\OCA\\AppFramework\\Utility\\Controller/string $controller: name or instance of the controller
:param mixed $method:
:param array $expected: an array containing the expected annotations
:param array $valid: if you define your own annotations, pass them here
* **Protected**
Checks if a controllermethod has the expected annotations
.. php:method:: assertHeaders($expected=array(), $response)
:param array $expected: an array with the expected headers
:param \\OCA\\AppFramework\\Http\\Response $response: the response which we want to test for headers
* **Protected**
Shortcut for testing expected headers of a response

View File

@@ -0,0 +1,27 @@
MethodAnnotationReader
======================
Reads and parses annotations from doc comments
.. php:namespace:: OCA\AppFramework\Utility
.. php:class:: MethodAnnotationReader
.. php:method:: __construct($object, $method)
:param object $object: an object or classname
:param string $method: the method which we want to inspect for annotations
.. php:method:: hasAnnotation($name)
:param string $name: the name of the annotation
:returns bool: true if the annotation is found
Check if a method contains an annotation

View File

@@ -0,0 +1,8 @@
==========================
ownCloud API Documentation
==========================
.. toctree::
:maxdepth: 1
templates

View File

@@ -0,0 +1,9 @@
=================
API Documentation
=================
.. toctree::
:maxdepth: 1
appframework/index
core/index

View File

@@ -16,6 +16,7 @@ ownCloud documentation contents
app/index
api/index
core/index
classes/index
Indices, glossary and tables
============================

View File

@@ -62,7 +62,6 @@ Templates
---------
* :doc:`app/templates`
* `Twig Templates`_
* :doc:`api/templates`
JavaScript & CSS
@@ -87,7 +86,6 @@ ownCloud APIs
* :doc:`api/filesystem`
* :doc:`api/hooks`
* :doc:`api/share-api`
* :doc:`api/templates`
* :doc:`api/vcategories`