|
|
|
|
|
|
|
|
public function actionBookmarks(string $action) |
|
|
public function actionBookmarks(string $action) |
|
|
{ |
|
|
{ |
|
|
$producer = $this->getProducerCurrent(); |
|
|
$producer = $this->getProducerCurrent(); |
|
|
$userProducer = $this->getUserProducerModule() |
|
|
|
|
|
->createUserProducerIfNotExist(GlobalParam::getCurrentUser(), $producer); |
|
|
|
|
|
|
|
|
|
|
|
if ($action == 'add') { |
|
|
|
|
|
$userProducer->bookmark = 1; |
|
|
|
|
|
$this->setFlash( |
|
|
|
|
|
'success', |
|
|
|
|
|
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être ajouté à vos favoris.' |
|
|
|
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
$userProducer->bookmark = 0; |
|
|
|
|
|
$this->setFlash( |
|
|
|
|
|
'success', |
|
|
|
|
|
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être supprimé de vos favoris.' |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$userCurrent = $this->getUserCurrent(); |
|
|
|
|
|
if($userCurrent) { |
|
|
|
|
|
$userProducer = $this->getUserProducerModule() |
|
|
|
|
|
->createUserProducerIfNotExist($userCurrent, $producer); |
|
|
|
|
|
|
|
|
|
|
|
if ($action == 'add') { |
|
|
|
|
|
$userProducer->bookmark = 1; |
|
|
|
|
|
$this->setFlash( |
|
|
|
|
|
'success', |
|
|
|
|
|
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être ajouté à vos favoris.' |
|
|
|
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
$userProducer->bookmark = 0; |
|
|
|
|
|
$this->setFlash( |
|
|
|
|
|
'success', |
|
|
|
|
|
'Le producteur <strong>' . Html::encode($producer->name) . '</strong> vient d\'être supprimé de vos favoris.' |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
$userProducer->save(); |
|
|
} |
|
|
} |
|
|
$userProducer->save(); |
|
|
|
|
|
|
|
|
|
|
|
return $this->redirect(['site/index']); |
|
|
return $this->redirect(['site/index']); |
|
|
} |
|
|
} |