silverstripe/sapphire — pull request #198 by hafriedlander (2012-02-17 01:06:04+00:00)
Title: API CHANGE ViewableData / SSViewer namespacing cleanup

ViewableData contained several methods that were only there to either:

- Expose useful statics or other global variables in an always-available way to a template

- Expose additional properties around the state of iteration in a control loop

This polluted ViewableData's namespace, and the iteration methods caused problems with our new multiple-list-types approach.

This patch provides two interfaces that allow any class to expose global or iterator properties within a template.

This can break existing PHP code that accesses these properties, because they are now only exposed within a template.

Solutions:

For globals, use the actual static accessors that the global properties were aliases for. For example, $this->AbsoluteBaseURL() becomes Director::AbsoluteBaseURL().

For iterators there is no current solution. They only make sense when in a template <% loop %> block anyway, and they aren't used in core ATM. A future patch will expose the current template scope to PHP to handle this edge case.

As a side effect, this patch restores First, Last, etc functionality to ArrayLists