geniv/nette-favorite

Favorite component for Nette Framework

v1.0.0 2018-04-26 08:58 UTC

This package is auto-updated.

Last update: 2020-09-13 20:00:23 UTC


README

Installation

$ composer require geniv/nette-favorite

or

"geniv/nette-favorite": ">=1.0.0"

require:

"php": ">=7.0.0",
"nette/nette": ">=2.4.0",
"geniv/nette-general-form": ">=1.0.0"

Include in application

neon configure services:

services:
    - Favorite

presenter usage:

protected function createComponentFavorite(Favorite $favorite): Favorite 
{
    //$otherComponent->addComponent($favorite, 'favorite');
    
    // $favorite->setTemplatePath(__DIR__ . '/templates/favorite.latte');
    $favorite->setSource($this->favoriteSource);
    $favorite->onSetFavorite[] = function (int $id) {
        $this->setFavorite($id);
    };
}

check status:

$favorite->isFavorite($id);

latte usage:

{control favorite $item['id']}