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: ^5.0
- drago-ex/database: ^5.0
- drago-ex/form: ^4.0
- drago-ex/permission: ^2.0
- drago-ex/project-backend: ^1.0
- drago-ex/project-backend-ui: ^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
None
Provides
None
Conflicts
None
Replaces
None
README
Settings of the application stored in the database, such as the website name and description, edited in the administration and available in every template.
Requirements
- PHP >= 8.3, < 9
- Drago Project
Installation
composer require drago-ex/project-settings
Project Tools copies the files of the package into the project,
where you adapt them. It also replaces Accessory/Widget/@brand.latte of the layouts once with one that shows
the website setting.
Database
The migration creates the table settings (name and value). bin/project-setup of Drago Project runs it and asks
for the website name and description; or run php vendor/bin/migration db:migrate --packages and add the rows
yourself.
Administration
{link :Backend:Settings:}
The menu item comes from Backend/Settings/2.menu.neon with
Backend UI. The form has a field for every row of settings,
labelled by its name. When you add a setting, add the translation of its name to
Backend/Settings/Translate/cs.neon.
Use in Presenters and Templates
Add the trait to a base presenter whose templates need the settings:
use App\Core\Settings\SettingsRequire; use Nette\Application\UI\Presenter; abstract class BasePresenter extends Presenter { use SettingsRequire; }
{varType App\Core\Settings\Settings $settings} {$settings->get('website')} {$settings->get('description')} {if $settings->has('website')} {$settings->get('website')} {/if}
Permissions
The rules are in Backend/Settings/acl.neon: the resource Backend:Settings, for the administrator only.
Project Permission can give the page to other roles.
The same file describes the privileges (permissionLabels) for the permissions page of Project Permission.