15.2. Streams

15.2. Streams

Zym_View supports the use of stream wrappers to modify the template before it is to be processed by PHP. Zym handles streams through Zym_View_Stream_Wrapper which modifies the template using view filters. Because it uses view filters, you must remember that any view filter paths added will affect those loaded for the stream wrapper.

15.2.1. Disabling/Enabling stream functionality

While the stream functionality is useful, it is usually not needed 100 percent of the time. Streams can be disabled via the setStreamFlag(bool) method.

15.2.2. Changing the protocol

In the event that stream protocols collide, Zym_View_Abstract provides setStreamProtocol(string) to satisfy the need. Protocol identifiers should be lower cased alphanumeric strings.

15.2.3. Changing the wrapper

Zym_View_Abstract supports the use of custom wrappers that are childs of Zym_View_Stream_Wrapper. It provides setStreamWrapper(string $classname) to set the appropriate wrapper.

15.2.4. Adding stream filters

Adding filters for the stream wrapper is the same as adding view filters. Stream filters can be added through addStreamFilter(string) or setStreamFilter(array). Streams filters are processed in FIFO order.

15.2.5. Stream filters

Filters included in Zym that were designed to work with the stream wrapper.

15.2.5.1. ShortTags

PHP short tags (<?= ?> or <? ?>) can be very useful and aesthetially pleasing to use in view templates; however, due to the lack of support in some installations, its use can cause problems. With the use of this filter, you can use short tags in your view scripts without problems.

This filter parses <?= and <? in the script and replaces them with <?php or <?php echo in order to ensure that PHP will parse it. If it detects that short tags is enabled, it will not run.

15.2.5.2. AspTags

This filter works in exactly the same fashion that the ShortTags filter does. Enabling AspTags support will allow you to use <% and <%= in your view scripts.