mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
228 lines
7 KiB
XML
228 lines
7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<phpdoc:classref xml:id="class.yaf-controller-abstract" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>The Yaf_Controller_Abstract class</title>
|
|
<titleabbrev>Yaf_Controller_Abstract</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ Yaf_Controller_Abstract intro -->
|
|
<section xml:id="yaf-controller-abstract.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
<classname>Yaf_Controller_Abstract</classname> is the heart of Yaf's
|
|
system. MVC stands for Model-View-Controller and is a design pattern
|
|
targeted at separating application logic from display logic.
|
|
</para>
|
|
<para>
|
|
Every custom controller shall inherit
|
|
<classname>Yaf_Controller_Abstract</classname>.
|
|
</para>
|
|
<para>
|
|
You will find that you can not define __construct function for your custom
|
|
controller, thus, <classname>Yaf_Controller_Abstract</classname> provides
|
|
a magic method: <methodname>Yaf_Controller_Abstract::init</methodname>.
|
|
</para>
|
|
<para>
|
|
If you have defined a init() method in your custom controller, it will be
|
|
called as long as the controller was instantiated.
|
|
</para>
|
|
<para>
|
|
Action may have arguments, when a request coming, if there are the same
|
|
name variable in the request parameters(see
|
|
<methodname>Yaf_Request_Abstract::getParam</methodname>) after routed,
|
|
Yaf will pass them to the action method
|
|
(see <methodname>Yaf_Action_Abstract::execute</methodname>).
|
|
<note>
|
|
<para>
|
|
These arguments are directly fetched without filtering, it should be
|
|
carefully processed before use them.
|
|
</para>
|
|
</note>
|
|
</para>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="yaf-controller-abstract.synopsis">
|
|
&reftitle.classsynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass><classname>Yaf_Controller_Abstract</classname></ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<modifier>abstract</modifier>
|
|
<classname>Yaf_Controller_Abstract</classname>
|
|
</ooclass>
|
|
</classsynopsisinfo>
|
|
<!-- }}} -->
|
|
<classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
|
|
<fieldsynopsis>
|
|
<modifier>public</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.actions">actions</varname>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>protected</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.module">_module</varname>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>protected</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.name">_name</varname>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>protected</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.request">_request</varname>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>protected</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.response">_response</varname>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>protected</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.invoke-args">_invoke_args</varname>
|
|
</fieldsynopsis>
|
|
<fieldsynopsis>
|
|
<modifier>protected</modifier>
|
|
<varname linkend="yaf-controller-abstract.props.view">_view</varname>
|
|
</fieldsynopsis>
|
|
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.yaf-controller-abstract')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])" />
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.yaf-controller-abstract')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
|
|
<!-- {{{ Yaf_Controller_Abstract properties -->
|
|
<section xml:id="yaf-controller-abstract.props">
|
|
&reftitle.properties;
|
|
<variablelist>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.actions">
|
|
<term><varname>actions</varname></term>
|
|
<listitem>
|
|
<para>
|
|
You can also define an action method in a separate PHP script by using
|
|
this property and <classname>Yaf_Action_Abstract</classname>.
|
|
<example>
|
|
<title>define action in a separate file</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class IndexController extends Yaf_Controller_Abstract {
|
|
protected $actions = array(
|
|
/** now dummyAction is defined in a separate file */
|
|
"dummy" => "actions/Dummy_action.php",
|
|
);
|
|
|
|
/* action method may have arguments */
|
|
public function indexAction($name, $id) {
|
|
/* $name and $id are unsafe raw data */
|
|
assert($name == $this->getRequest()->getParam("name"));
|
|
assert($id == $this->_request->getParam("id"));
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example>
|
|
<title>Dummy_action.php</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class DummyAction extends Yaf_Action_Abstract {
|
|
/* an action class shall define this method as the entry point */
|
|
public function execute() {
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.module">
|
|
<term><varname>_module</varname></term>
|
|
<listitem>
|
|
<para>
|
|
module name
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.name">
|
|
<term><varname>_name</varname></term>
|
|
<listitem>
|
|
<para>
|
|
controller name
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.request">
|
|
<term><varname>_request</varname></term>
|
|
<listitem>
|
|
<para>
|
|
current request object
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.response">
|
|
<term><varname>_response</varname></term>
|
|
<listitem>
|
|
<para>
|
|
current response object
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.invoke-args">
|
|
<term><varname>_invoke_args</varname></term>
|
|
<listitem>
|
|
<para></para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry xml:id="yaf-controller-abstract.props.view">
|
|
<term><varname>_view</varname></term>
|
|
<listitem>
|
|
<para>
|
|
view engine object
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
|
|
</partintro>
|
|
|
|
&reference.yaf.entities.yaf-controller-abstract;
|
|
|
|
</phpdoc:classref>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|