Propozycja: behavior `PdfController` – przycisk „Pobierz PDF” przy rekordzie w backendzie
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start by reading README.md lines 618–646 for the PDF API and traits/ManagesViewRecords.php lines 136–141 for the current preview behavior; the issue also points to formFindModelObject as a model lookup reference. The proposal spans a controller behavior, YAML configuration, toolbar/list buttons, permissions, filename and language handling, tests, and README documentation. Done means meeting all four acceptance criteria, including a 403 for direct URL access without permission.
Written by the indexing model from the issue text.
Description
Problem
Najczęstsza integracja w projektach to „Pobierz fakturę/umowę jako PDF” przy rekordzie w backendzie (zamówienie, faktura, zgłoszenie). Każdy projekt pisze to samo:
- akcję kontrolera,
- przycisk w toolbarze formularza,
- sprawdzenie uprawnień,
- nazwę pliku,
- przekazanie rekordu do szablonu,
- język dokumentu.
Stare issues pokazują, że pytania o pobieranie PDF-ów z komponentów i AJAX-a wracają: #14, #29, #39, #57, #69, #90.
Dowód
- Plugin daje tylko API (
PDF::loadTemplate(),README.md:618-646). Nie ma behavioru ani komponentu do powiązania szablonu z modelem. - Podgląd w panelu korzysta wyłącznie z Sample data (
traits/ManagesViewRecords.php:136-141), więc nie da się podejrzeć szablonu z danymi prawdziwego rekordu.
Skutek
Powtarzany kod i powtarzane błędy w projektach: brak kontroli uprawnień do pobrania, PDF w złym języku, kłopoty z pobieraniem przez AJAX (#39, #69, #90).
Proponowane rozwiązanie
Renatio\DynamicPDF\Behaviors\PdfControllerzconfig_pdf.yaml: kod szablonu, nazwa zmiennej z rekordem (domyślnierecord), wzorzec nazwy pliku (np.faktura-:number.pdf), trybdownload/stream, wymagane uprawnienie i opcjonalnie pole rekordu z językiem.- Behavior dodaje akcję
pdf($recordId)(znajdowanie rekordu jakformFindModelObject, sprawdzenie uprawnienia) i helperpdfRenderButton()do toolbaru formularza lub kolumny listy. - Zdarzenie albo metoda kontrolera
pdfExtendData($record)do dopisania danych.
Kryteria akceptacji
- Dodanie behavioru i pliku YAML do kontrolera daje działający przycisk pobierania PDF dla rekordu.
- Brak wymaganego uprawnienia daje 403, także przy bezpośrednim wejściu na URL.
- Nazwa pliku i język dokumentu biorą się z konfiguracji i rekordu.
- Opis i przykład w README.
- Dominant language
- PHP
- Stars
- 30
- Forks
- 22
- Avg merge
- 2h 23m
- Merged PRs (30d)
- 77
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mplodowski/dynamicpdf-plugin
-
code-review documentation low-priority
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
mplodowski/dynamicpdf-plugin#295 · 1 comment ·
Maintainers usually reply within 1 day
-
code-review enhancement low-priority
Difficulty 5/5 Over a week Newbie friendliness 25/100
mplodowski/dynamicpdf-plugin#300 · 1 comment ·
Maintainers usually reply within 1 day
-
code-review enhancement low-priority
Difficulty 5/5 Over a week Newbie friendliness 38/100
mplodowski/dynamicpdf-plugin#299 · 1 comment ·
Maintainers usually reply within 1 day
-
code-review enhancement low-priority
Difficulty 5/5 Over a week Newbie friendliness 35/100
mplodowski/dynamicpdf-plugin#298 · 1 comment ·
Maintainers usually reply within 1 day
-
code-review documentation good first issue low-priority
Difficulty 4/5 3-5 days Newbie friendliness 45/100
mplodowski/dynamicpdf-plugin#294 · 1 comment ·
Maintainers usually reply within 1 day
All issues in mplodowski/dynamicpdf-plugin
Similar issues
-
Messenger
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
symfony/symfony-docs#23237 ·
Maintainers usually reply within 3 days
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 4 days
-
Documentation Feature: Financial
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
coollabsio/coolify#12127 ·
Maintainers usually reply within 1 day