Skip to end of metadata
Go to start of metadata

Zend Framework: Zend_Filter_StringAppend & Zend_Filter_StringPrepend Component Proposal

Proposed Component Name Zend_Filter_StringAppend & Zend_Filter_StringPrepend
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Filter_StringAppend & Zend_Filter_StringPrepend
Proposers Thomas Weidner
Zend Liaison TBD
Revision 1.0 - 14 May 2010: Initial (wiki revision: 2)

Table of Contents

1. Overview

Zend_Filter_StringAppend and Zend_Filter_StringPrepend are filters which allow to append or prepend a string with a certain content to a given string.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will append and prepend strings.
  • This component will not work on resources like files.

4. Dependencies on Other Framework Components

  • Zend_Filter

5. Theory of Operation

Zend_Filter_StringAppend can append a string to a string. It can be used to detect if the given string is already appended (per option). In this case, if set, no string will be appended. Zend_Filter_StringPrepend works reverse.

6. Milestones / Tasks

  • Milestone 1: [DONE] Proposal finished
  • Milestone 2: Proposal accepted
  • Milestone 3: Working implementation
  • Milestone 4: Unit tests
  • Milestone 5: Documentation
  • Milestone 6: Moved to core

7. Class Index

  • Zend_Filter_StringAppend
  • Zend_Filter_StringPrepend

8. Use Cases

UC-01

Prepend a string

INPUT: "www.example.com"
OUTPUT: "http://www.example.com"

UC-02

Prepend a string but only if it does not already exist

INPUT: "http://www.example.com"
OUTPUT: "http://www.example.com"

UC-03

Append a string but only if a collection of strings does not already exist

INPUT: "http://www.example.gov"
OUTPUT: "http://www.example.gov"

INPUT: "http://www.example"
OUTPUT: "http://www.example.com"

9. Class Skeletons

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jul 28, 2010

    Could you give some extra usecases aside from url's?

    1. Jul 30, 2010

      // My content

      Quoting a text:
      $filter = new Zend_Filter_StringPrepend('>');

      // makes ">My content"

      Making a XML from a userentry:
      $filter = new Zend_Filter_StringPrepend('<entry>');
      $filter = new Zend_Filter_StringAppend('</entry>');

      // makes "<entry>My content</entry>"

  2. Aug 03, 2010

    Community Review Team Recommendation

    The CR Team advises that this proposal be approved.

  3. Aug 20, 2010

    What is the output expected for an empty input?

    Take the example of a Zend_Form_Element_Text that will yield information url. We want to protect the input with this filter for users who do not follow the instructions to know if 'http://' must be filled in the field or not. This field is optional in this case. And, we also want to use Zend_Filter_Null. What will be the output? null or 'http://'?

    1. Aug 28, 2010

      You need to do a proper filter chaining or proper options on the form element.

      Using Zend_Filter_Append standalone the string will be appended using the examples from the usecase. Using isEmpty on the form field will stop any further processing.

      This is something which is done by Zend_Form_Element and not by this filter.