2017 © Pedro Peláez
 

library indigo-view

Zend View extension

image

hipnaba/indigo-view

Zend View extension

  • Sunday, February 4, 2018
  • by hipnaba
  • Repository
  • 1 Watchers
  • 0 Stars
  • 227 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

Indigo View

Indigo View extends Zend View. It simplifies integrations with non ZF projects and provides a set of generally useful view helpers., (*1)

View helpers

Indent

Indents multiline strings. Helps in generating pretty output., (*2)

<?php
$content = <<< EOS
Line 1
EOS;

$content1 = <<< EOS
Line 1.1
Line 1.2
EOS;

echo '

' . PHP_EOL . ($this->indent($content)) . PHP_EOL . ($this->indent($content1, 2)) . PHP_EOL . '
';

The above example will output..., (*3)

<div>
    Line 1
        Line 1.1
        Line 1.2
</div>

RenderObject

Tries to render an object. This is used mainly for rendering objects implementing HelperPluginAwareInterface., (*4)

If the passed object doesn't implement HelperPluginAwareInterface the helper will try to call the object's __toString() method. If that doesn't exist it will just return the object's class., (*5)

Implementing HelperPluginAwareInterface is simple. Just have the implementing object return the wanted helper plugin. The helper plugin can be any callable., (*6)

<?php
class RenderableObject implements \Indigo\View\HelperPluginAwareInterface
{
    public function getHelperPlugin()
     {
        return function ($object) {
            return '

' . get_class($object) . '

'; }; } } $object = new RenderableObject(); echo $this->renderObject($object);

The above example will output, (*7)

<h1>RenderableObject</h1>

Or we can use the plugin name registered with the plugin manager., (*8)

<?php
class RenderableObject implements \Indigo\View\HelperPluginAwareInterface
{
    public function getHelperPlugin() 
    {
        return 'pluginName';
    }
}

The Versions