mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Create events for transaction links.
This commit is contained in:
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
|
class LinkController extends Controller
|
||||||
{
|
{
|
||||||
/** @var JournalRepositoryInterface Journals and transactions overview */
|
private JournalRepositoryInterface $journalRepository;
|
||||||
private $journalRepository;
|
private LinkTypeRepositoryInterface $repository;
|
||||||
/** @var LinkTypeRepositoryInterface Link repository. */
|
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LinkController constructor.
|
* LinkController constructor.
|
||||||
|
@@ -23,6 +23,10 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Repositories\LinkType;
|
namespace FireflyIII\Repositories\LinkType;
|
||||||
|
|
||||||
use Exception;
|
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\LinkType;
|
||||||
use FireflyIII\Models\Note;
|
use FireflyIII\Models\Note;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
@@ -75,6 +79,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function destroyLink(TransactionJournalLink $link): bool
|
public function destroyLink(TransactionJournalLink $link): bool
|
||||||
{
|
{
|
||||||
|
event(new DestroyedTransactionLink($link));
|
||||||
$link->delete();
|
$link->delete();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -277,6 +282,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
|||||||
// make note in noteable:
|
// make note in noteable:
|
||||||
$this->setNoteText($link, (string)$information['notes']);
|
$this->setNoteText($link, (string)$information['notes']);
|
||||||
|
|
||||||
|
event(new StoredTransactionLink($link));
|
||||||
|
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +334,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
|||||||
$journalLink->save();
|
$journalLink->save();
|
||||||
$this->setNoteText($journalLink, $data['notes']);
|
$this->setNoteText($journalLink, $data['notes']);
|
||||||
|
|
||||||
|
event(new UpdatedTransactionLink($journalLink));
|
||||||
|
|
||||||
return $journalLink;
|
return $journalLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user