| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="zend.file.transfer.migration">
- <title>Migrating from previous versions</title>
- <para>
- The API of <classname>Zend_File_Transfer</classname> has changed from time to time.
- If you started to use <classname>Zend_File_Transfer</classname> and it's subcomponents
- in earlier versions follow the guidelines below to migrate your scripts to
- use the new API.
- </para>
- <sect2 id="zend.file.transfer.migration.fromonesixtooneseven">
- <title>Migrating from 1.6 to 1.7 or newer</title>
- <sect3 id="zend.file.transfer.migration.fromonesixtooneseven.validators">
- <title>Changes when using filters and validators</title>
- <para>
- As noted by users, the validators from <classname>Zend_File_Transfer</classname>
- do not work in conjunction with <classname>Zend_Config</classname> due to the fact
- that they have not used named arrays.
- </para>
- <para>
- Therefor, all filters and validators for <classname>Zend_File_Transfer</classname>
- have been reworked. While the old signatures continue to work,
- they have been marked as deprecated, and will emit a PHP notice
- asking you to fix them.
- </para>
- <para>
- The following list shows you the changes you will have to do for proper
- usage of the parameters.
- </para>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.rename">
- <title>Filter: Rename</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <classname>Zend_Filter_File_Rename($oldfile, $newfile,
- $overwrite)</classname>
- </para></listitem>
- <listitem><para>
- New method API: <methodname>Zend_Filter_File_Rename($options)</methodname>
- where $options accepts the following array keys:
- <emphasis>source</emphasis> equals to $oldfile,
- <emphasis>target</emphasis> equals to $newfile,
- <emphasis>overwrite</emphasis> equals to $overwrite
- </para></listitem>
- </itemizedlist>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.rename.example">
- <title>Changes for the rename filter from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addFilter('Rename',
- array('/path/to/oldfile', '/path/to/newfile', true));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addFilter('Rename',
- array('source' => '/path/to/oldfile',
- 'target' => '/path/to/newfile',
- 'overwrite' => true));
- ]]></programlisting>
- </example>
- </sect4>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.count">
- <title>Validator: Count</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <methodname>Zend_Validate_File_Count($min, $max)</methodname>
- </para></listitem>
- <listitem><para>
- New method API: <methodname>Zend_Validate_File_Count($options)</methodname>
- where $options accepts the following array keys:
- <emphasis>min</emphasis> equals to $min,
- <emphasis>max</emphasis> equals to $max,
- </para></listitem>
- </itemizedlist>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.count.example">
- <title>Changes for the count validator from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Count',
- array(2, 3));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Count',
- false,
- array('min' => 2,
- 'max' => 3));
- ]]></programlisting>
- </example>
- </sect4>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.extension">
- <title>Validator:Extension</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <classname>Zend_Validate_File_Extension($extension,
- $case)</classname>
- </para></listitem>
- <listitem><para>
- New method API:
- <methodname>Zend_Validate_File_Extension($options)</methodname> where $options
- accepts the following array keys:
- <emphasis>*</emphasis> equals to $extension and can have any other key,
- <emphasis>case</emphasis> equals to $case,
- </para></listitem>
- </itemizedlist>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.extension.example">
- <title>Changes for the extension validator from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Extension',
- array('jpg,gif,bmp', true));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Extension',
- false,
- array('extension1' => 'jpg,gif,bmp',
- 'case' => true));
- ]]></programlisting>
- </example>
- </sect4>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.filessize">
- <title>Validator: FilesSize</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <classname>Zend_Validate_File_FilesSize($min, $max,
- $bytestring)</classname>
- </para></listitem>
- <listitem><para>
- New method API:
- <methodname>Zend_Validate_File_FilesSize($options)</methodname> where $options
- accepts the following array keys:
- <emphasis>min</emphasis> equals to $min,
- <emphasis>max</emphasis> equals to $max,
- <emphasis>bytestring</emphasis> equals to $bytestring
- </para></listitem>
- </itemizedlist>
- <para>
- Additionally, the <methodname>useByteString()</methodname> method
- signature has changed. It can only be used to test if the
- validator is expecting to use byte strings in generated
- messages. To set the value of the flag, use the
- <methodname>setUseByteString()</methodname> method.
- </para>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.filessize.example">
- <title>Changes for the filessize validator from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('FilesSize',
- array(100, 10000, true));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('FilesSize',
- false,
- array('min' => 100,
- 'max' => 10000,
- 'bytestring' => true));
- // Example for 1.6
- $upload->useByteString(true); // set flag
- // Same example for 1.7
- $upload->setUseByteSting(true); // set flag
- ]]></programlisting>
- </example>
- </sect4>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.hash">
- <title>Validator: Hash</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <classname>Zend_Validate_File_Hash($hash,
- $algorithm)</classname>
- </para></listitem>
- <listitem><para>
- New method API: <methodname>Zend_Validate_File_Hash($options)</methodname>
- where $options accepts the following array keys:
- <emphasis>*</emphasis> equals to $hash and can have any other key,
- <emphasis>algorithm</emphasis> equals to $algorithm,
- </para></listitem>
- </itemizedlist>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.hash.example">
- <title>Changes for the hash validator from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Hash',
- array('12345', 'md5'));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Hash',
- false,
- array('hash1' => '12345',
- 'algorithm' => 'md5'));
- ]]></programlisting>
- </example>
- </sect4>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.imagesize">
- <title>Validator: ImageSize</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <classname>Zend_Validate_File_ImageSize($minwidth,
- $minheight, $maxwidth, $maxheight)</classname>
- </para></listitem>
- <listitem><para>
- New method API:
- <methodname>Zend_Validate_File_FilesSize($options)</methodname> where $options
- accepts the following array keys: <emphasis>minwidth</emphasis> equals to
- $minwidth, <emphasis>maxwidth</emphasis> equals to $maxwidth,
- <emphasis>minheight</emphasis> equals to $minheight,
- <emphasis>maxheight</emphasis> equals to $maxheight,
- </para></listitem>
- </itemizedlist>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.imagesize.example">
- <title>Changes for the imagesize validator from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('ImageSize',
- array(10, 10, 100, 100));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('ImageSize',
- false,
- array('minwidth' => 10,
- 'minheight' => 10,
- 'maxwidth' => 100,
- 'maxheight' => 100));
- ]]></programlisting>
- </example>
- </sect4>
- <sect4 id="zend.file.transfer.migration.fromonesixtooneseven.validators.size">
- <title>Validator: Size</title>
- <itemizedlist>
- <listitem><para>
- Old method API: <classname>Zend_Validate_File_Size($min, $max,
- $bytestring)</classname>
- </para></listitem>
- <listitem><para>
- New method API: <methodname>Zend_Validate_File_Size($options)</methodname>
- where $options accepts the following array keys:
- <emphasis>min</emphasis> equals to $min,
- <emphasis>max</emphasis> equals to $max,
- <emphasis>bytestring</emphasis> equals to $bytestring
- </para></listitem>
- </itemizedlist>
- <example id="zend.file.transfer.migration.fromonesixonetooneseven.validators.size.example">
- <title>Changes for the size validator from 1.6 to 1.7</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Size',
- array(100, 10000, true));
- // Same example for 1.7
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('Size',
- false,
- array('min' => 100,
- 'max' => 10000,
- 'bytestring' => true));
- ]]></programlisting>
- </example>
- </sect4>
- </sect3>
- </sect2>
- <sect2 id="zend.file.transfer.migration.fromonesixonetoonesixtwo">
- <title>Migrating from 1.6.1 to 1.6.2 or newer</title>
- <sect3 id="zend.file.transfer.migration.fromonesixonetoonesixtwo.validators">
- <title>Changes when using validators</title>
- <para>
- As noted by users, the validators from <classname>Zend_File_Transfer</classname>
- do not work the same way like the default ones from
- <classname>Zend_Form</classname>. <classname>Zend_Form</classname> allows the usage
- of a <code>breakChainOnFailure</code> parameter which breaks the validation for all
- further validators when an validation error has occurred.
- </para>
- <para>
- So we added this parameter also to all existing validators from
- <classname>Zend_File_Transfer</classname>.
- </para>
- <itemizedlist>
- <listitem><para>
- Old method API: <methodname>addValidator($validator, $options, $files)</methodname>.
- </para></listitem>
- <listitem><para>
- New method API: <code>addValidator($validator, $breakChainOnFailure, $options,
- $files)</code>.
- </para></listitem>
- </itemizedlist>
- <para>
- To migrate your scripts to the new API, simply add a <constant>FALSE</constant>
- after defining the wished validator.
- </para>
- <example id="zend.file.transfer.migration.fromonesixonetoonesixtwo.example">
- <title>How to change your file validators from 1.6.1 to 1.6.2</title>
- <programlisting language="php"><![CDATA[
- // Example for 1.6.1
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('FilesSize', array('1B', '100kB'));
- // Same example for 1.6.2 and newer
- // Note the added boolean false
- $upload = new Zend_File_Transfer_Adapter_Http();
- $upload->addValidator('FilesSize', false, array('1B', '100kB'));
- ]]></programlisting>
- </example>
- </sect3>
- </sect2>
- </sect1>
|