drago-ex / project-settings
Individual settings for the application.
Package info
github.com/drago-ex/project-settings
Type:drago-tools-resource
pkg:composer/drago-ex/project-settings
Requires
- php: >=8.3 <9
- drago-ex/application: ^4.0
- drago-ex/database: ^5.0
- drago-ex/form: ^3.0
- drago-ex/project-backend: ^1.0
- drago-ex/translator: ^4.0.1
- nette/application: ^3.0
- nette/di: ^3.0
- tracy/tracy: ^2.0
Requires (Dev)
- drago-ex/project-tools: ^1.0
- nette/tester: ^2.5
- phpstan/phpstan-nette: ^2.0
Suggests
- drago-ex/permission: Enables generation of the settings permission provider.
Provides
None
Conflicts
None
Replaces
None
README
Individual settings for the application.
Requirements
- PHP >= 8.3, < 9
- Drago Project
Installation
composer require drago-ex/project-settings
Files copied into the project
The files are copied into the project by drago-ex/project-tools,
as set in extra.drago-tools of this package's composer.json.
Administration
The settings page is available as:
{link :Backend:Settings:}
With drago-ex/project-backend-ui, add the links to its menu (see its README).
The form has a field for every row of the settings table, labelled by its name (website, description). The
labels are translated: when you add a setting to the database, add the translation of its name to
app/Presentation/Backend/Settings/Translate/cs.neon, otherwise the field shows the name itself.
Use in the presenter
Add the trait to a base presenter whose templates need application settings:
use App\Core\Settings\SettingsRequire; use Nette\Application\UI\Presenter; abstract class BasePresenter extends Presenter { use SettingsRequire; }
Use in Latte template
{varType App\Core\Settings\Settings $settings} {* website name *} {$settings->get('website')} {* website description *} {$settings->get('description')} {if $settings->has('website')} {$settings->get('website')} {/if}
Optional add-ons
The package works without them. Set them up by hand as described below when the project needs them.
Permission provider
With drago-ex/permission, the access rules from bin/create-settings-permission
are generated into the project by:
php vendor/bin/drago-commands