cvs: peardoc /en/guide/migrating customtasks.xml
| From: | Greg Beaver | Date: | Sun, 18 Sep 2005 06:28:20 +0000 |
| Subject: | cvs: peardoc /en/guide/migrating customtasks.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-6849@lists.php.net to get a copy of this message | ||
cellog Sun Sep 18 02:28:20 2005 EDT
Modified files:
/peardoc/en/guide/migrating customtasks.xml
Log:
finish custom tasks docs
http://cvs.php.net/diff.php/peardoc/en/guide/migrating/customtasks.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/en/guide/migrating/customtasks.xml diff -u peardoc/en/guide/migrating/customtasks.xml:1.2 peardoc/en/guide/migrating/customtasks.xml:1.3 --- peardoc/en/guide/migrating/customtasks.xml:1.2 Thu Apr 7 00:02:23 2005 +++ peardoc/en/guide/migrating/customtasks.xml Sun Sep 18 02:28:19 2005 @@ -1,20 +1,15 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <chapter id="guide.migrating.customtasks"> <chapterinfo> <author> <firstname>Gregory</firstname> <surname>Beaver</surname> </author> - <date>$Date: 2005/04/07 04:02:23 $</date> + <date>$Date: 2005/09/18 06:28:19 $</date> </chapterinfo> <title>Custom File Tasks</title> - <warning> - <title>Incomplete documentation</title> - <para>Documentation is not yet complete</para> - </warning> - <simpara> For many small library packages, very little customization is needed. Just install and go. package.xml 1.0 is very good at this task. As packages grow in size and @@ -122,7 +117,7 @@ <itemizedlist> <listitem> <para> - <link linkend="guide.migrating.customtasks.php.validxml"><function>validXml</function></link> + <link linkend="guide.migrating.customtasks.php.validatexml"><function>validateXml</function></link> </para> </listitem> <listitem> @@ -143,24 +138,229 @@ </listitem> </itemizedlist> </para> - <sect2 id="guide.migrating.customtasks.php.validxml"> - <title><function>validXml</function></title> + <sect2 id="guide.migrating.customtasks.php.validatexml"> + <title><function>validateXml</function></title> + <para> + <funcsynopsis> + <funcprototype> + <funcdef>true|array <function>validateXml</function></funcdef> + <paramdef>PEAR_PackageFile_v2 <parameter>$pkg</parameter></paramdef> + <paramdef>string|array <parameter>$xml</parameter></paramdef> + <paramdef>PEAR_Config <parameter>&$config</parameter></paramdef> + <paramdef>array <parameter>$fileXml</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> <para> </para> </sect2> <sect2 id="guide.migrating.customtasks.php.init"> <title><function>init</function></title> <para> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>init</function></funcdef> + <paramdef>string|array <parameter>$xml</parameter></paramdef> + <paramdef>array <parameter>$fileAttributes</parameter></paramdef> + <paramdef>string|null <parameter>$lastVersion</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + <para> + The <function>init</function> function is called immediately prior to the + <function>startSession</function> method, and should be used for initialization + that is not directly related to file modification. This method may move to another + location in the installation process at any time. The logical separation of + initialization from task action is important and the order of execution can be + depended upon. + </para> + <para> + <variablelist> + <varlistentry> + <term> + string|array <parameter>$xml</parameter> + </term> + <listitem> + <para> + The raw parsed content of the task's xml as parsed from package.xml. Tags + like <tasks:windowseol> that have no attributes or child elements will + be passed an empty string <literal>''</literal>. Otherwise, simple text content + will be a string, and nested tags/attributes will be passed in as an array. Here + is a list of sample xml and their parsed values: + </para> + <para> + <itemizedlist> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[<tasks:blah/>]]> + </programlisting> + </para> + <para> + <literal>string("");</literal> + </para> + </listitem> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[ +<tasks:blah>hello +</tasks:blah>]]> + </programlisting> + </para> + <para> + <literal>string("hello");</literal> + </para> + </listitem> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[ +<tasks:blah>hello + <tasks:boo/> +</tasks:blah>]]> + </programlisting> + </para> + <para> + <literal><![CDATA[array('_content' => 'hello', 'tasks:boo' => string(''))]]></literal> + </para> + </listitem> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[ +<tasks:blah foo="one"> + <tasks:boo/> +</tasks:blah>]]> + </programlisting> + </para> + <para> + <literal><![CDATA[ +array('attribs' => array('foo' => 'one'), + 'tasks:boo' => string(''))]]></literal> + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + array <parameter>$fileAttributes</parameter> + </term> + <listitem> + <para> + The parsed attributes of the <file> tag that encloses this tag. This + is guaranteed to contain indices <literal>name</literal>, specifying the file name, + and <literal>role</literal>, specifying the file role. Other attributes like + <literal>baseinstalldir</literal> may be present but are not required, and so will + not be guaranteed to be present for every file. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + string|null <parameter>$lastVersion</parameter> + </term> + <listitem> + <para> + This will be set to the string representing the version of the last installed + version of this package. This is useful for determining whether the package + is being upgraded or is a fresh installation. If the package is being installed + for the first time, &null; will be passed in. + </para> + </listitem> + </varlistentry> + </variablelist> </para> </sect2> <sect2 id="guide.migrating.customtasks.php.startsession"> <title><function>startSession</function></title> <para> + <funcsynopsis> + <funcprototype> + <funcdef>string|false|PEAR_Error <function>startSession</function></funcdef> + <paramdef>string <parameter>$contents</parameter></paramdef> + <paramdef>string <parameter>$dest</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + <para> + For non-script tasks, <function>startSession</function> is called to actually + execute a task. The task should perform all needed operations on the file contents, + and on success return the file contents regardless of any modification. These contents + will be written to disk, so it is imperative that they be the full, original file + contents if no modification is made to them. + </para> + <para> + For script tasks, <function>startSession</function> is called + to determine whether the script can be safely executed. For both task types, + script and non-script, a return value of &false; will cause the task to be silently + skipped. A return value of a PEAR_Error will cause processing of all operations + to stop, and an error message to be displayed by the installer prior to exiting. + Any other return value will cause the script to be processed normally by the frontend + as a post-installation script. + </para> + <para> + <variablelist> + <varlistentry> + <term> + string <parameter>$contents</parameter> + </term> + <listitem> + <para> + The original contents of the file whose <file> tag in package.xml + contains the task tag. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + string <parameter>$dest</parameter> + </term> + <listitem> + <para> + The full path to the final installed file location. This is strictly + informational, as the file does not yet exist, and should only be used + for error messages or other processing that does not attempt to modify + the file. + </para> + </listitem> + </varlistentry> + </variablelist> </para> </sect2> <sect2 id="guide.migrating.customtasks.php.run"> <title><function>run</function></title> <para> + <funcsynopsis> + <funcprototype> + <funcdef>false|string <function>run</function></funcdef> + <paramdef>array <parameter>$tasks</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + <para> + The <function>run</function> method should return &false; on success, and an + error message if there is a problem. This method is called only for tasks + that define <varname>$this->type</varname> as <literal>multiple</literal>. + For each task within package.xml that has this task, the <function>run</function> + method will be called with an array containing all of the task objects from + the package.xml. + </para> + <para> + <variablelist> + <varlistentry> + <term> + array <parameter>$tasks</parameter> + </term> + <listitem> + <para> + An array of task objects. + </para> + </listitem> + </varlistentry> + </variablelist> </para> </sect2> </sect1>
http://cvs.php.net/diff.php/peardoc/en/guide/migrating/customtasks.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/en/guide/migrating/customtasks.xml diff -u peardoc/en/guide/migrating/customtasks.xml:1.2 peardoc/en/guide/migrating/customtasks.xml:1.3 --- peardoc/en/guide/migrating/customtasks.xml:1.2 Thu Apr 7 00:02:23 2005 +++ peardoc/en/guide/migrating/customtasks.xml Sun Sep 18 02:28:19 2005 @@ -1,20 +1,15 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <chapter id="guide.migrating.customtasks"> <chapterinfo> <author> <firstname>Gregory</firstname> <surname>Beaver</surname> </author> - <date>$Date: 2005/04/07 04:02:23 $</date> + <date>$Date: 2005/09/18 06:28:19 $</date> </chapterinfo> <title>Custom File Tasks</title> - <warning> - <title>Incomplete documentation</title> - <para>Documentation is not yet complete</para> - </warning> - <simpara> For many small library packages, very little customization is needed. Just install and go. package.xml 1.0 is very good at this task. As packages grow in size and @@ -122,7 +117,7 @@ <itemizedlist> <listitem> <para> - <link linkend="guide.migrating.customtasks.php.validxml"><function>validXml</function></link> + <link linkend="guide.migrating.customtasks.php.validatexml"><function>validateXml</function></link> </para> </listitem> <listitem> @@ -143,24 +138,229 @@ </listitem> </itemizedlist> </para> - <sect2 id="guide.migrating.customtasks.php.validxml"> - <title><function>validXml</function></title> + <sect2 id="guide.migrating.customtasks.php.validatexml"> + <title><function>validateXml</function></title> + <para> + <funcsynopsis> + <funcprototype> + <funcdef>true|array <function>validateXml</function></funcdef> + <paramdef>PEAR_PackageFile_v2 <parameter>$pkg</parameter></paramdef> + <paramdef>string|array <parameter>$xml</parameter></paramdef> + <paramdef>PEAR_Config <parameter>&$config</parameter></paramdef> + <paramdef>array <parameter>$fileXml</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> <para> </para> </sect2> <sect2 id="guide.migrating.customtasks.php.init"> <title><function>init</function></title> <para> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>init</function></funcdef> + <paramdef>string|array <parameter>$xml</parameter></paramdef> + <paramdef>array <parameter>$fileAttributes</parameter></paramdef> + <paramdef>string|null <parameter>$lastVersion</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + <para> + The <function>init</function> function is called immediately prior to the + <function>startSession</function> method, and should be used for initialization + that is not directly related to file modification. This method may move to another + location in the installation process at any time. The logical separation of + initialization from task action is important and the order of execution can be + depended upon. + </para> + <para> + <variablelist> + <varlistentry> + <term> + string|array <parameter>$xml</parameter> + </term> + <listitem> + <para> + The raw parsed content of the task's xml as parsed from package.xml. Tags + like <tasks:windowseol> that have no attributes or child elements will + be passed an empty string <literal>''</literal>. Otherwise, simple text content + will be a string, and nested tags/attributes will be passed in as an array. Here + is a list of sample xml and their parsed values: + </para> + <para> + <itemizedlist> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[<tasks:blah/>]]> + </programlisting> + </para> + <para> + <literal>string("");</literal> + </para> + </listitem> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[ +<tasks:blah>hello +</tasks:blah>]]> + </programlisting> + </para> + <para> + <literal>string("hello");</literal> + </para> + </listitem> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[ +<tasks:blah>hello + <tasks:boo/> +</tasks:blah>]]> + </programlisting> + </para> + <para> + <literal><![CDATA[array('_content' => 'hello', 'tasks:boo' => string(''))]]></literal> + </para> + </listitem> + <listitem> + <para> + <programlisting role="xml"> +<![CDATA[ +<tasks:blah foo="one"> + <tasks:boo/> +</tasks:blah>]]> + </programlisting> + </para> + <para> + <literal><![CDATA[ +array('attribs' => array('foo' => 'one'), + 'tasks:boo' => string(''))]]></literal> + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + array <parameter>$fileAttributes</parameter> + </term> + <listitem> + <para> + The parsed attributes of the <file> tag that encloses this tag. This + is guaranteed to contain indices <literal>name</literal>, specifying the file name, + and <literal>role</literal>, specifying the file role. Other attributes like + <literal>baseinstalldir</literal> may be present but are not required, and so will + not be guaranteed to be present for every file. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + string|null <parameter>$lastVersion</parameter> + </term> + <listitem> + <para> + This will be set to the string representing the version of the last installed + version of this package. This is useful for determining whether the package + is being upgraded or is a fresh installation. If the package is being installed + for the first time, &null; will be passed in. + </para> + </listitem> + </varlistentry> + </variablelist> </para> </sect2> <sect2 id="guide.migrating.customtasks.php.startsession"> <title><function>startSession</function></title> <para> + <funcsynopsis> + <funcprototype> + <funcdef>string|false|PEAR_Error <function>startSession</function></funcdef> + <paramdef>string <parameter>$contents</parameter></paramdef> + <paramdef>string <parameter>$dest</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + <para> + For non-script tasks, <function>startSession</function> is called to actually + execute a task. The task should perform all needed operations on the file contents, + and on success return the file contents regardless of any modification. These contents + will be written to disk, so it is imperative that they be the full, original file + contents if no modification is made to them. + </para> + <para> + For script tasks, <function>startSession</function> is called + to determine whether the script can be safely executed. For both task types, + script and non-script, a return value of &false; will cause the task to be silently + skipped. A return value of a PEAR_Error will cause processing of all operations + to stop, and an error message to be displayed by the installer prior to exiting. + Any other return value will cause the script to be processed normally by the frontend + as a post-installation script. + </para> + <para> + <variablelist> + <varlistentry> + <term> + string <parameter>$contents</parameter> + </term> + <listitem> + <para> + The original contents of the file whose <file> tag in package.xml + contains the task tag. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + string <parameter>$dest</parameter> + </term> + <listitem> + <para> + The full path to the final installed file location. This is strictly + informational, as the file does not yet exist, and should only be used + for error messages or other processing that does not attempt to modify + the file. + </para> + </listitem> + </varlistentry> + </variablelist> </para> </sect2> <sect2 id="guide.migrating.customtasks.php.run"> <title><function>run</function></title> <para> + <funcsynopsis> + <funcprototype> + <funcdef>false|string <function>run</function></funcdef> + <paramdef>array <parameter>$tasks</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + <para> + The <function>run</function> method should return &false; on success, and an + error message if there is a problem. This method is called only for tasks + that define <varname>$this->type</varname> as <literal>multiple</literal>. + For each task within package.xml that has this task, the <function>run</function> + method will be called with an array containing all of the task objects from + the package.xml. + </para> + <para> + <variablelist> + <varlistentry> + <term> + array <parameter>$tasks</parameter> + </term> + <listitem> + <para> + An array of task objects. + </para> + </listitem> + </varlistentry> + </variablelist> </para> </sect2> </sect1>