Packages
A package contributes entities, migrations, API operations, screens, navigation entries, translations and notifications. It plugs in through tagged interfaces, events, messages and conventions.
Declare the package
A package is a Composer package of the type adsum- (a country package adsum-, a third-party
extension adsum-). Every installed package of these types is active and is loaded after the packages it
requires.
{
"name": "web-vision/adsum-working-time",
"type": "adsum-package",
"require": {
"php": ">=8.5",
"web-vision/adsum-core": "*@dev"
},
"suggest": {
"web-vision/adsum-reporting": "Offers the working-time reports"
},
"autoload": {
"psr-4": {
"WebVision\\Adsum\\WorkingTime\\": "src/"
}
}
}
The Symfony bundles a package needs are listed in its config/.
Conventions
The core finds everything a package brings by its location:
config/holds the services of the package;services. yaml config/adds those of one environment,services_<environment>. yaml config/the configuration of Symfony and other bundles.packages/ config/holds the services that work with a package it suggests; the core loads the file only where that package is installed (see Contracts and Integrations).integrations/<vendor>/<name>. yaml src/<Module>/orDomain/ Model/ src/<Area>/<Module>/holds the Doctrine entities.Domain/ Model/ migrations/holds the Doctrine migrations in the namespace<package namespace>\.Migrations translations/holds the XLIFF catalogues (see Translations and Icons).- Routes are attributes on controllers below
src/. openapi/is the package's part of the API contract (see API), andopenapi. yaml asyncapi/describes its messages (see Events and Messages).asyncapi. yaml config/andfrontend. php public/hold the frontend (see Frontend).
The directory of the package is available as the container parameter <name>.: the package name without
vendor and adsum-, with underscores, for example %working_.
Services
Register all classes below src/ as services, except the classes built from data:
services:
_defaults:
autowire: true
autoconfigure: true
WebVision\Adsum\WorkingTime\:
resource: '../src/'
exclude:
- '../src/**/Exception/'
- '../src/**/Domain/Model/'
- '../src/**/Domain/ValueObject/'
- '../src/**/Contract/Message/'
- '../src/**/Contract/Dto/'
- '../src/**/Contract/Event/'
- '../src/**/Application/Message/'
- '../src/**/Application/Dto/'
- '../src/**/UI/Api/Input/'
- '../src/**/UI/Api/Resource/'
Extension points
The interfaces of the core are tagged automatically (autoconfigure); implementing one is enough.
| Interface | Purpose |
|---|---|
Core\ | Pages in the navigation (see Navigation and Access) |
Core\ | Custom elements in the top bar |
Core\ | A type of notification (see Notifications and Live Updates) |
Core\ | The page a notification subject links to |
Core\ | A way a notification reaches its recipient |
Core\ | One line of the daily digest |
Core\ | A topic for live updates |
Core\ | One way of finding who decides an approval step; a step a package names in its submission may pass the
subject as subject |
Core\ | Next to Subject: who filed a subject for its requester, so they never decide it |
Core\ | Registers an approval subject type and describes its subjects to approvers; with steps
every submission names its own steps |
Core\ | A kind of structure entry, such as a department |
Core\ | References of a module to structure entries |
Core\ | References of a module to skills of the catalogue |
Core\ | Recurring jobs run by the worker of the core |
Core\ | The package as a module a company may switch off (see below) |
Core\ | A step of the setup checklist, done by the records of one company only |
Core\ | An integration with an outside service (see below) |
Core\ | A request employees file for themselves (see below) |
All names start with Web. A package may use classes of another package only if it requires that
package in its composer..
Company modules
A package with screens registers itself as a module a company may switch off, with its key, its PHP namespace and the modules it requires:
final readonly class LeaveModule implements CompanyModule
{
public function definition(): CompanyModuleDefinition
{
return new CompanyModuleDefinition('leave', 'WebVision\Adsum\Leave', ['workingTime']);
}
}
For a company that switched the module off, the core hides everything a class of that namespace contributes
(navigation entries, top-bar items, dashboard widgets, setup steps, notifications); its operations and pages answer 404
with the problem type module-. A scheduled job that runs for every company asks the contract
Core\ and skips such a company. Name the module in the catalogue as
company.
Features of a module
A package can let a company switch off a single feature of its module and keep the rest. One class with the tag
interface Company names everything that belongs to the feature:
final readonly class WorkTypesFeature implements CompanyFeature
{
public function definition(): CompanyFeatureDefinition
{
return new CompanyFeatureDefinition(
'workTypes',
'workingTime',
routes: ['app_work_types', 'api_list_work_types'],
navigation: ['workTypes'],
tours: ['pageWorkTypes'],
requestKinds: ['workTypeRequest'],
reports: ['work-type-requests'],
hides: ['myDays:workType.name'],
);
}
}
For a company that switched the feature off, the routes answer like those of a switched-off module (an operation with
the problem type feature-), and the navigation entries, widgets, tours, request kinds and reports are not
offered. hides lists the columns, filters and fields of other screens, as <screen>:<key>, that show the
feature's data. The data of the feature stays. Name the feature in the catalogue as company with a
description as company. A package outside a request asks the contract
Core\.
Integrations
A package that connects adsum to an outside service registers one integration with its key, its features and its settings. The core lists it for the admins, enables it per company, stores the settings and runs the connection test:
final readonly class ExampleIntegration implements IntegrationDescriptor
{
public function key(): string { return 'example'; }
public function features(): array { return [self::FEATURE_NOTIFICATION_CHANNEL]; }
public function settingsClass(): string { return ExampleSettings::class; }
public function testConnection(object $settings): array { /* one CheckResult per check */ }
}
final readonly class ExampleSettings
{
public function __construct(
#[Assert\NotBlank] public ?string $accountId = null,
#[Secret] #[Assert\NotBlank] public ?string $clientSecret = null,
) {}
}
Every setting is a nullable constructor parameter with a default; # marks one that is stored encrypted and
never shown again. Name the integration, its description and every setting in the catalogue as
integration.<key>., integration.<key>. and integration.<key>., and every
value of a choice as integration.<key>.. No other package may require or name an
integration package.
Admins enable an integration per company. Before an integration sends, receives, schedules or offers anything, it asks
Core\ with the company of the data it handles and does nothing while the
answer is no. Integration and Integration announce a change.
A service that calls back implements Core\. Its calls reach
/integrations/: the identifier of an account the package keeps, which account
resolves, or the one of the company's settings for OAuth redirects, shown to the admins as the callback URL. The core
answers 404 for an unknown identifier and a disabled integration. A package starts an OAuth flow with
Core\; the redirect is refused unless it brings a state of the same session, at
most 10 minutes old and not used before.
An integration reads the settings a company saved for it, with the secrets in plain text, through
Core\, with its own key and the company of the data it handles.
An integration that lets admins type an address refuses a refused one when it is saved, asking
Core\, which applies the rules of the outbound client; the client still
checks again on every call.
An integration calls its service only through Core\. It gives up after
5 seconds without connection or answer and after 30 seconds in total, follows no redirect, sends the User-
adsum/<version> and refuses addresses outside the public internet, such as the server itself, private networks and
the metadata services of clouds. Send from a message handler, never while a user's request waits, except for
connection tests and test messages.
An integration that sends mail adds a mail transport: a class implementing
Core\ whose key is the key of the integration. A company chooses it
in its e-mail settings while the integration is enabled; with the integration disabled the company's mail goes out
through SMTP again. The transport only sends: sender names the mailbox every mail is sent from, and
send hands the composed mail to the service. Recording the delivery, its subject, retries and the log stay with
the core. Throw Temporary (with the seconds the service asked to wait, if it did) for a failure that
may pass, and Permanent for one that cannot; both carry a short error code, never the service's text.
Request kinds
A package whose employees file a request for themselves registers it as a request kind with a class implementing
Core\: a code, the operation that files it, its fields
(type, required, option source, accepted file types) and, for the choices of a field, the options the employee may
choose. Channels outside the web screens, such as a chat bot or an app, read the kinds through
/me/ and file a kind only by calling its operation as the employee. is says whether the
employee may file the kind, and options returns only active master data of the company that the package's rules
allow the employee. Name the kind in the catalogue as request and request
(words separated by commas) and every field as request, in English and German. A kind of a
package that is not installed does not exist; no package may name another package's kind.
Migrations
The database schema is changed only by migrations. Generate a migration with:
bin/console doctrine:migrations:generate
Migrations of all packages run in the order they were created. Run them with
bin/.