mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Create events for transaction links.
This commit is contained in:
parent
52ce873aac
commit
6b79f1abdb
48
app/Events/DestroyedTransactionLink.php
Normal file
48
app/Events/DestroyedTransactionLink.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* DestroyedTransactionLink.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class DestroyedTransactionLink
|
||||
*/
|
||||
class DestroyedTransactionLink extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
private TransactionJournalLink $link;
|
||||
|
||||
/**
|
||||
* DestroyedTransactionLink constructor.
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*/
|
||||
public function __construct(TransactionJournalLink $link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
}
|
47
app/Events/StoredTransactionLink.php
Normal file
47
app/Events/StoredTransactionLink.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* StoredTransactionLink.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class StoredTransactionLink
|
||||
*/
|
||||
class StoredTransactionLink extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
private TransactionJournalLink $link;
|
||||
|
||||
/**
|
||||
* DestroyedTransactionLink constructor.
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*/
|
||||
public function __construct(TransactionJournalLink $link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
}
|
47
app/Events/UpdatedTransactionLink.php
Normal file
47
app/Events/UpdatedTransactionLink.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* UpdatedTransactionLink.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UpdatedTransactionLink
|
||||
*/
|
||||
class UpdatedTransactionLink extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
private TransactionJournalLink $link;
|
||||
|
||||
/**
|
||||
* DestroyedTransactionLink constructor.
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*/
|
||||
public function __construct(TransactionJournalLink $link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
}
|
@ -40,10 +40,8 @@ use URL;
|
||||
*/
|
||||
class LinkController extends Controller
|
||||
{
|
||||
/** @var JournalRepositoryInterface Journals and transactions overview */
|
||||
private $journalRepository;
|
||||
/** @var LinkTypeRepositoryInterface Link repository. */
|
||||
private $repository;
|
||||
private JournalRepositoryInterface $journalRepository;
|
||||
private LinkTypeRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* LinkController constructor.
|
||||
|
@ -23,6 +23,10 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\LinkType;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Events\DestroyedTransactionLink;
|
||||
use FireflyIII\Events\RemovedTransactionLink;
|
||||
use FireflyIII\Events\StoredTransactionLink;
|
||||
use FireflyIII\Events\UpdatedTransactionLink;
|
||||
use FireflyIII\Models\LinkType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -75,6 +79,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function destroyLink(TransactionJournalLink $link): bool
|
||||
{
|
||||
event(new DestroyedTransactionLink($link));
|
||||
$link->delete();
|
||||
|
||||
return true;
|
||||
@ -277,6 +282,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
// make note in noteable:
|
||||
$this->setNoteText($link, (string)$information['notes']);
|
||||
|
||||
event(new StoredTransactionLink($link));
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
@ -327,6 +334,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
$journalLink->save();
|
||||
$this->setNoteText($journalLink, $data['notes']);
|
||||
|
||||
event(new UpdatedTransactionLink($journalLink));
|
||||
|
||||
return $journalLink;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user