terranet / presentable
Simple Object Presenter
Installs: 8 739
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
This package is not auto-updated.
Last update: 2024-12-05 04:30:14 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
;