Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
# Keep GitHub Actions up-to-date
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups: #all in one PR
github-actions-all:
patterns:
- "*"

# Keep Composer dependencies up-to-date
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
61 changes: 20 additions & 41 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches:
- master
- develop
- 'feature/*'
- 'hotfix/*'
- 'release/*'
tags:
- '*'
pull_request:
Expand All @@ -25,7 +22,7 @@ jobs:

strategy:
matrix:
php-versions: [ '8.2', '8.5' ]
php-versions: [ '8.3', '8.5' ]
coverage: [none]
fail-fast: false

Expand Down Expand Up @@ -100,21 +97,23 @@ jobs:
matrix:
include:
#always tests higher stable php version with lower db version
#enable coverage on higher stable php version with higher postrgesql version
#lower php version
- { php-version: "8.2", db-image: "mysql:5.7", coverage: none, always: false }
- { php-version: "8.2", db-image: "mysql:8.1", coverage: none, always: false }
- { php-version: "8.2", db-image: "mariadb:10.4", coverage: none, always: false }
- { php-version: "8.2", db-image: "mariadb:11", coverage: none, always: false }
- { php-version: "8.2", db-image: "postgres:11", coverage: none, always: false }
- { php-version: "8.2", db-image: "postgres:16", coverage: none, always: false }
#enable coverage on higher stable php version with higher PostgreSQL version
#cache must be disabled on one always enabled build (not coverage one, this already takes much time than others)
#higher stable php version
- { php-version: "8.5", db-image: "mysql:5.7", coverage: none, always: true }
- { php-version: "8.5", db-image: "mysql:8.1", coverage: none, always: false }
- { php-version: "8.5", db-image: "mariadb:10.4", coverage: none, always: true }
- { php-version: "8.5", db-image: "mariadb:11", coverage: none, always: false }
- { php-version: "8.5", db-image: "postgres:11", coverage: none, always: true }
- { php-version: "8.5", db-image: "postgres:16", coverage: none, always: true }
- { php-version: "8.5", db-image: "postgres:13", coverage: none, cache: true, always: true }
- { php-version: "8.5", db-image: "postgres:17", coverage: none, cache: true, always: true }
- { php-version: "8.5", db-image: "mysql:8.0", coverage: none, cache: true, always: true }
- { php-version: "8.5", db-image: "mysql:9.1", coverage: none, cache: true, always: false }
- { php-version: "8.5", db-image: "mariadb:10.5", coverage: none, cache: false, always: true }
- { php-version: "8.5", db-image: "mariadb:11.6", coverage: none, cache: true, always: false }
#always one test with lower php version
#lower php version
- { php-version: "8.3", db-image: "postgres:13", coverage: none, cache: true, always: false }
- { php-version: "8.3", db-image: "postgres:17", coverage: none, cache: true, always: true }
- { php-version: "8.3", db-image: "mysql:8.0", coverage: none, cache: true, always: false }
- { php-version: "8.3", db-image: "mysql:9.1", coverage: none, cache: true, always: false }
- { php-version: "8.3", db-image: "mariadb:10.5", coverage: none, cache: true, always: false }
- { php-version: "8.3", db-image: "mariadb:11.6", coverage: none, cache: true, always: false }
fail-fast: false

env:
Expand Down Expand Up @@ -168,37 +167,17 @@ jobs:
echo "npm $(npm --version)"
docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else if [[ -n \$(command -v mysql) ]]; then mysql --version; else mariadb --version; fi fi"

- name: Checkout Galette core
- name: Build Galette
if: env.skip != 'true'
uses: actions/checkout@v4
uses: galette/.github/actions/build-galette@main
with:
repository: galette/galette
path: galette-core
fetch-depth: 1
ref: develop
php-version: ${{ matrix.php-version }}

- name: Checkout plugin
uses: actions/checkout@v4
with:
path: galette-core/galette/plugins/plugin-auto

- name: "Restore dependencies cache"
if: env.skip != 'true'
uses: actions/cache@v4
with:
path: |
~/.composer/cache/
~/.npm/_cacache/
key: "${{ runner.os }}-galette-${{ matrix.php-version }}-${{ hashFiles('galette/composer.lock', 'package-lock.json') }}"
restore-keys: |
${{ runner.os }}-galette-${{ matrix.php-version }}-

- name: Install dependencies
if: env.skip != 'true'
run: |
cd galette-core
bin/install_deps

- name: Init for PostgreSQL
env:
POSTGRES_HOST: localhost
Expand Down
16 changes: 8 additions & 8 deletions lib/GaletteAuto/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
*/
class Auto
{
public const TABLE = 'cars';
public const PK = 'id_car';
public const string TABLE = 'cars';
public const string PK = 'id_car';

private Plugins $plugins;
private Db $zdb;
Expand Down Expand Up @@ -134,12 +134,12 @@ class Auto
private int $owner_id;
private Adherent $owner;

public const FUEL_PETROL = 1;
public const FUEL_DIESEL = 2;
public const FUEL_GAS = 3;
public const FUEL_ELECTRICITY = 4;
public const FUEL_BIO = 5;
public const FUEL_HYBRID = 6;
public const int FUEL_PETROL = 1;
public const int FUEL_DIESEL = 2;
public const int FUEL_GAS = 3;
public const int FUEL_ELECTRICITY = 4;
public const int FUEL_BIO = 5;
public const int FUEL_HYBRID = 6;

/** @var array<string, string> */
private array $propnames; //textual properties names
Expand Down
4 changes: 2 additions & 2 deletions lib/GaletteAuto/Autos.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
*/
class Autos
{
public const TABLE = Auto::TABLE;
public const PK = Auto::PK;
public const string TABLE = Auto::TABLE;
public const string PK = Auto::PK;

private Plugins $plugins;
private Db $zdb;
Expand Down
8 changes: 4 additions & 4 deletions lib/GaletteAuto/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
*/
class Body extends AbstractObject
{
public const TABLE = 'bodies';
public const PK = 'id_body';
public const FIELD = 'body';
public const NAME = 'bodies';
public const string TABLE = 'bodies';
public const string PK = 'id_body';
public const string FIELD = 'body';
public const string NAME = 'bodies';

/**
* Default constructor
Expand Down
8 changes: 4 additions & 4 deletions lib/GaletteAuto/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
*/
class Brand extends AbstractObject
{
public const TABLE = 'brands';
public const PK = 'id_brand';
public const FIELD = 'brand';
public const NAME = 'brands';
public const string TABLE = 'brands';
public const string PK = 'id_brand';
public const string FIELD = 'brand';
public const string NAME = 'brands';

/**
* Default constructor
Expand Down
8 changes: 4 additions & 4 deletions lib/GaletteAuto/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
*/
class Color extends AbstractObject
{
public const TABLE = 'colors';
public const PK = 'id_color';
public const FIELD = 'color';
public const NAME = 'colors';
public const string TABLE = 'colors';
public const string PK = 'id_color';
public const string FIELD = 'color';
public const string NAME = 'colors';

/**
* Default constructor
Expand Down
4 changes: 2 additions & 2 deletions lib/GaletteAuto/Filters/ModelsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

class ModelsList extends Pagination
{
public const ORDERBY_MODEL = 0;
public const ORDERBY_BRAND = 1;
public const int ORDERBY_MODEL = 0;
public const int ORDERBY_BRAND = 1;

/**
* Returns the field we want to default set order to
Expand Down
8 changes: 4 additions & 4 deletions lib/GaletteAuto/Finition.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
*/
class Finition extends AbstractObject
{
public const TABLE = 'finitions';
public const PK = 'id_finition';
public const FIELD = 'finition';
public const NAME = 'finitions';
public const string TABLE = 'finitions';
public const string PK = 'id_finition';
public const string FIELD = 'finition';
public const string NAME = 'finitions';

/**
* Default constructor
Expand Down
2 changes: 1 addition & 1 deletion lib/GaletteAuto/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
class History
{
public const TABLE = 'history';
public const string TABLE = 'history';

private Db $zdb;

Expand Down
6 changes: 3 additions & 3 deletions lib/GaletteAuto/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
*/
class Model
{
public const TABLE = 'models';
public const PK = 'id_model';
public const FIELD = 'model';
public const string TABLE = 'models';
public const string PK = 'id_model';
public const string FIELD = 'model';

protected int $id;
protected string $model;
Expand Down
2 changes: 1 addition & 1 deletion lib/GaletteAuto/Picture.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Picture extends GalettePicture
private Plugins $plugins;

protected string $tbl_prefix = AUTO_PREFIX;
public const PK = Auto::PK;
public const string PK = Auto::PK;

/**
* Default constructor.
Expand Down
52 changes: 39 additions & 13 deletions lib/GaletteAuto/PluginGaletteAuto.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@

namespace GaletteAuto;

use DI\Attribute\Inject;
use Galette\Core\Db;
use Galette\Core\Login;
use Galette\Core\Plugins\DashboardProviderInterface;
use Galette\Core\Plugins\InstallableInterface;
use Galette\Core\Plugins\MemberActionProviderInterface;
use Galette\Core\Plugins\MenuProviderInterface;
use Galette\Entity\Adherent;
use Galette\Core\GalettePlugin;

Expand All @@ -33,14 +39,17 @@
* @author Johan Cwiklinski <johan@x-tnd.be>
*/

class PluginGaletteAuto extends GalettePlugin
class PluginGaletteAuto extends GalettePlugin implements MenuProviderInterface, DashboardProviderInterface, MemberActionProviderInterface, InstallableInterface
{
#[Inject]
private readonly Db $zdb; //@phpstan-ignore property.uninitializedReadonly,property.onlyRead (injected from DI)

/**
* Extra menus entries
* Get plugins menus
*
* @return array<string, string|array<string,mixed>>
*/
public static function getMenusContents(): array
public function getMenus(): array
{
/** @var Login $login */
global $login;
Expand Down Expand Up @@ -122,11 +131,11 @@ public static function getMenusContents(): array
}

/**
* Extra public menus entries
* Get plugins public menus
*
* @return array<int, string|array<string,mixed>>
*/
public static function getPublicMenusItemsList(): array
public function getPublicMenus(): array
{
return [
[
Expand All @@ -140,11 +149,11 @@ public static function getPublicMenusItemsList(): array
}

/**
* Get current logged-in user dashboards contents
* Get current logged-in user plugins dashboards
*
* @return array<int, string|array<string,mixed>>
*/
public static function getMyDashboardsContents(): array
public function getMyDashboards(): array
{
/** @var Login $login */
global $login;
Expand All @@ -165,11 +174,11 @@ public static function getMyDashboardsContents(): array
}

/**
* Get dashboards contents
* Get plugins dashboards
*
* @return array<int, string|array<string,mixed>>
*/
public static function getDashboardsContents(): array
public function getDashboards(): array
{
return [];
}
Expand All @@ -181,7 +190,7 @@ public static function getDashboardsContents(): array
*
* @return array<int, string|array<string,mixed>>
*/
public static function getListActionsContents(Adherent $member): array
public function getListActions(Adherent $member): array
{
return [
[
Expand All @@ -202,18 +211,35 @@ public static function getListActionsContents(Adherent $member): array
*
* @return array<int, string|array<string,mixed>>
*/
public static function getDetailedActionsContents(Adherent $member): array
public function getDetailedActions(Adherent $member): array
{
return static::getListActionsContents($member);
return $this->getListActions($member);
}

/**
* Get batch actions contents
*
* @return array<int, string|array<string,mixed>>
*/
public static function getBatchActionsContents(): array
public function getBatchActions(): array
{
return [];
}

/**
* Is the plugin fully installed (including database, extra configuration, etc.)?
*/
public function isInstalled(): bool
{
return
$this->zdb->tableExists(AUTO_PREFIX . Auto::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . Body::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . Brand::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . Color::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . Finition::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . Model::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . State::TABLE) &&
$this->zdb->tableExists(AUTO_PREFIX . Transmission::TABLE)
;
}
}
4 changes: 2 additions & 2 deletions lib/GaletteAuto/Repository/Models.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

class Models extends Repository
{
public const TABLE = Model::TABLE;
public const PK = Model::PK;
public const string TABLE = Model::TABLE;
public const string PK = Model::PK;

private int $count;

Expand Down
Loading
Loading