-
Notifications
You must be signed in to change notification settings - Fork 863
Expand file tree
/
Copy pathregisterlocalnamespace.xml
More file actions
113 lines (101 loc) · 3.6 KB
/
registerlocalnamespace.xml
File metadata and controls
113 lines (101 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="yaf-loader.registerlocalnamespace" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Yaf_Loader::registerLocalNamespace</refname>
<refpurpose>Register local class prefix</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type class="union"><type>Yaf_Loader</type><type>false</type></type><methodname>Yaf_Loader::registerLocalNamespace</methodname>
<methodparam><type>mixed</type><parameter>prefix</parameter></methodparam>
</methodsynopsis>
<para>
Register local class prefix name, <classname>Yaf_Loader</classname> searches
classes in two library directories, the one is configured via <link
linkend="configuration.yaf.library">application.library.directory</link> (in
application.ini) which is called local library directory; the other is
configured via <link linkend="ini.yaf.library">yaf.library</link> (in
php.ini) which is called global library directory, since it can be shared
by many applications in the same server.
</para>
<para>
When an autoloading is triggered, <classname>Yaf_Loader</classname> will
determine which library directory should be searched in by examining the prefix
name of the missed classname.
If the prefix name is registered as a local namespace then look for it in
local library directory, otherwise look for it in global library directory.
<note>
<simpara>
If <literal>yaf.library</literal> is not configured, then the global library directory is
assumed to be the local library directory. In that case, all autoloading
will look for local library directory.
</simpara>
<simpara>
But if you want your Yaf application be strong, then always register your
own classes as local classes.
</simpara>
</note>
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>prefix</parameter></term>
<listitem>
<para>
A &string; or an &array; of class name prefix.
All class prefix with these prefix will be loaded in local library path.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the <classname>Yaf_Loader</classname> instance on success,&return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>Yaf_Loader::registerLocalNamespace</function>example</title>
<programlisting role="php">
<![CDATA[
<?php
$loader = Yaf_Loader::getInstance('/local/library/', '/global/library');
$loader->registerLocalNamespace("Baidu");
$loader->registerLocalNamespace(array("Sina", "Weibo"));
$loader->autoload("Baidu_Name"); // search in '/local/library/'
$loader->autoload("Sina"); // search '/local/library/'
$loader->autoload("Global_Name");// search in '/global/library/'
$loader->autoload("Foo_Bar"); // search in '/global/library/'
?>
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<!-- 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
-->