2017 © Pedro Peláez
 

library presentable

Simple Object Presenter

image

terranet/presentable

Simple Object Presenter

  • Friday, August 26, 2016
  • by endihunter
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,766 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 23 % Grown

The README.md

Presentable Pattern Implementation

Move presentation logic out from the Object class., (*1)

Installation

composer require terranet/presentable

Use Case

<?php

class Post implements PresentableInterfacee
{
    use PresentableTrait;

    protected $presenter = PostPresenter::class;
}
<?php

class PostPresenter extends Presenter
{
    public function title()
    {
        return '<a href="/posts/read/' . $this->presentable->url . '">' . $this->presentable->title . '</a>';
    }
}

In view, instead of calling $post->title, call Presenter's method $post->present()->title;, (*2)

Enjoy!

The Versions

26/08 2016

dev-master

9999999-dev

Simple Object Presenter

  Sources   Download

The Requires

  • php >=5.6.0

 

by endi

26/08 2016

v1.0

1.0.0.0

Simple Object Presenter

  Sources   Download

The Requires

  • php >=5.6.0

 

by endi