Patch files: community-*-patches.md and hubleto-framework-patches.md
A custom app lives in your project, but sometimes it needs something that only the maintainers of Hubleto can add: a new column in a community app, an extendible that another app should collect, a hook in the core, a fix in the framework. Do not edit the packages in vendor/hubleto/. The next composer update would delete your change, and your app would silently break.
Instead, describe the change in a markdown file in the root of your app. The file is a proposal for a pull request that you or the maintainers can apply later.
| File | Package it is about | Typical content |
|---|---|---|
community-apps-patches.md |
hubleto/erp, folder apps/ (e.g. Deals) |
A new extendible, a column, a route, a hook in a community app |
community-core-patches.md |
hubleto/erp, folder src/ (Hubleto\Erp) |
A change in Model, RecordManager, Controller, Loader |
hubleto-framework-patches.md |
hubleto/framework (Hubleto\Framework) |
A change in the framework classes or the description API |
Patch files.
Create only the files that you need. If your app needs no change, create none.
Template
Use the same structure for every item, so that it can be copied into an issue:
# Patches for community apps
Needed by app: `Hubleto\App\Custom\CarRental`
## 1. Deals: let other apps add a button to the deal toolbar
**File:** `apps/Deals/Components/FC/FormDeal.tsx`
**Problem:** `CarRental` has to offer "Rent a car" next to the deal buttons. There is no extension point.
**Proposed change:** collect the extendible `DealToolbarButtons` from all enabled apps.
```php
$buttons = $this->collectExtendibles('DealToolbarButtons');
```
**Workaround in this app:** `FormCustomizer.addFormHeaderExtraButton('FormDeal', ...)` in `Loader.tsx`.
**Impact:** none for existing apps. The extendible is optional.
What makes a good item
- Exact location. Name the package, the file and, when possible, the method.
- The problem first. Say what the app cannot do, not only what the code should look like.
- A snippet. Write the proposed code. Use the real names from the community apps, and copy the style of the surrounding code.
- A workaround. Say how the app behaves until the patch is released, so that the app works without it.
- Impact. State whether existing apps are affected.
Examples of real findings
The items below are the kind of finding that belongs into these files. They were found while writing this documentation.
hubleto-framework-patches.md
## 1. `Description\Table::setPermissions()` ignores `$canRead`
**File:** `src/Description/Table.php`
```php
if ($canCreate !== null) $this->permissions['canCreate'] = $canCreate;
if ($canCreate !== null) $this->permissions['canRead'] = $canRead; // should test $canRead
```
**Proposed change:** test `$canRead !== null` in the second line.
## 2. `Column::fromArray()` reads misspelled keys
**File:** `src/Column.php`
The key `description` is tested but `hint` is read, and `yesText` and `noText` are read from `yestText` and `notText`. Custom columns defined in the configuration cannot set these properties.
community-apps-patches.md
## 1. `Notifications\Sender::send()` cannot be used from crons
**File:** `apps/Notifications/Sender.php`
`send()` reads the sender with `$this->authProvider()->getUserId()`. A cron has no session, so the method returns `false`. `PriceLists\Crons\WarnAboutExpiry` is affected.
**Proposed change:** accept an optional `$idFrom` parameter and allow `0` (system) as the sender.
## 2. `Mail\Loader->send()` does not queue the message for delivery
**File:** `apps/Mail/Loader.php`
`send()` creates the mail record but sets neither `datetime_scheduled_to_send` nor `id_account`, so the `SendMails` cron never picks it up. It also writes a `sent` key, but the `mails` table has `datetime_sent`.
**Proposed change:** set `datetime_scheduled_to_send` (and the account of the sender) when the message is meant to be delivered by SMTP.
community-core-patches.md
## 1. `collectExtendibles()` renumbers integer keys
**File:** `framework/src/App.php` (used by `Hubleto\Erp\App`)
`array_merge()` renumbers integer keys, so `Deals\Extendibles\ProductTypes` (`10 => ..., 11 => ...`) loses its keys.
**Proposed change:** merge with the `+` operator or `array_replace()` when the keys matter.
