terranet / presentable
There is no license information available for the latest version (v1.0) of this package.
Simple Object Presenter
v1.0
2016-08-26 11:16 UTC
Requires
- php: >=5.6.0
This package is not auto-updated.
Last update: 2026-03-12 10:34:58 UTC
README
Move presentation logic out from the Object class.
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;