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-package (a country package adsum-country, a third-party extension adsum-extension). 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/"
        }
    }
}
Copied!

The Symfony bundles a package needs are listed in its config/bundles.php.

Conventions 

The core finds everything a package brings by its location:

  1. config/services.yaml holds the services of the package; config/services_<environment>.yaml adds those of one environment, config/packages/ the configuration of Symfony and other bundles.
  2. config/integrations/<vendor>/<name>.yaml 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).
  3. src/<Module>/Domain/Model/ or src/<Area>/<Module>/Domain/Model/ holds the Doctrine entities.
  4. migrations/ holds the Doctrine migrations in the namespace <package namespace>\Migrations.
  5. translations/ holds the XLIFF catalogues (see Translations and Icons).
  6. Routes are attributes on controllers below src/.
  7. openapi/openapi.yaml is the package's part of the API contract (see API), and asyncapi/asyncapi.yaml describes its messages (see Events and Messages).
  8. config/frontend.php and public/ hold the frontend (see Frontend).

The directory of the package is available as the container parameter <name>.path: the package name without vendor and adsum-, with underscores, for example %working_time.path%.

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/'
Copied!

Extension points 

The interfaces of the core are tagged automatically (autoconfigure); implementing one is enough.

Interface Purpose
Core\Shared\Navigation\NavigationEntries Pages in the navigation (see Navigation and Access)
Core\Shared\Navigation\TopBarItems Custom elements in the top bar
Core\Notification\Application\Type\NotificationType A type of notification (see Notifications and Live Updates)
Core\Notification\Application\Link\NotificationLink The page a notification subject links to
Core\Notification\Application\Channel\NotificationChannel A way a notification reaches its recipient
Core\Notification\Application\Digest\DigestSection One line of the daily digest
Core\Notification\Application\Realtime\RealtimeTopic A topic for live updates
Core\Approval\Application\Port\ApproverResolver One way of finding who decides an approval step; a step a package names in its submission may pass the subject as subjectId
Core\Approval\Application\Port\SubjectFilers Next to SubjectSummaryProvider: who filed a subject for its requester, so they never decide it
Core\Approval\Application\Port\SubjectSummaryProvider Registers an approval subject type and describes its subjects to approvers; with stepsFromSubmission every submission names its own steps
Core\Organisation\Application\Structure\StructureKind A kind of structure entry, such as a department
Core\Organisation\Application\Structure\StructureReferenceCheck References of a module to structure entries
Core\Organisation\Application\Port\SkillReferences References of a module to skills of the catalogue
Core\Shared\Infrastructure\Scheduler\RecurringJobs Recurring jobs run by the worker of the core
Core\Customisation\CompanyModule\Application\Port\CompanyModule The package as a module a company may switch off (see below)
Core\Customisation\SetupChecklist\Application\Port\SetupStep A step of the setup checklist, done by the records of one company only
Core\Integrations\Application\Port\IntegrationDescriptor An integration with an outside service (see below)
Core\RequestKind\Application\Port\RequestKindProvider A request employees file for themselves (see below)

All names start with WebVision\Adsum\. A package may use classes of another package only if it requires that package in its composer.json.

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']);
    }
}
Copied!

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-disabled. A scheduled job that runs for every company asks the contract Core\Customisation\Contract\CompanyModules and skips such a company. Name the module in the catalogue as companyModule.<key>.

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 CompanyFeature 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'],
        );
    }
}
Copied!

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-disabled), 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 companyFeature.<key> with a description as companyFeature.<key>.description. A package outside a request asks the contract Core\Customisation\Contract\CompanyFeatures.

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,
    ) {}
}
Copied!

Every setting is a nullable constructor parameter with a default; #[Secret] marks one that is stored encrypted and never shown again. Name the integration, its description and every setting in the catalogue as integration.<key>.name, integration.<key>.description and integration.<key>.setting.<setting>, and every value of a choice as integration.<key>.setting.<setting>.<value>. 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\Integrations\Contract\IntegrationGate with the company of the data it handles and does nothing while the answer is no. IntegrationEnabled and IntegrationDisabled announce a change.

A service that calls back implements Core\Integrations\Application\Port\IntegrationCallback. Its calls reach /integrations/callback/<key>/<callbackId>: the identifier of an account the package keeps, which accountOf() 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\Integrations\Contract\OAuthStates; 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\Integrations\Contract\IntegrationSettingsReader, 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\Integrations\Contract\OutboundAddressCheck, which applies the rules of the outbound client; the client still checks again on every call.

An integration calls its service only through Core\Integrations\Contract\OutboundHttpClient. It gives up after 5 seconds without connection or answer and after 30 seconds in total, follows no redirect, sends the User-Agent 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\Notification\Application\Port\MailTransport 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: senderAddress() 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 TemporaryDeliveryFailure (with the seconds the service asked to wait, if it did) for a failure that may pass, and PermanentDeliveryFailure 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\RequestKind\Application\Port\RequestKindProvider: a code, the operationId 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/request-kinds and file a kind only by calling its operation as the employee. isOfferedTo() 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 requestKind.<code>.label and requestKind.<code>.keywords (words separated by commas) and every field as requestKind.<code>.field.<name>, 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
Copied!

Migrations of all packages run in the order they were created. Run them with bin/console doctrine:migrations:migrate.