diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ab95c77 --- /dev/null +++ b/.github/dependabot.yml @@ -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" diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 4c41522..847ffd4 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -5,9 +5,6 @@ on: branches: - master - develop - - 'feature/*' - - 'hotfix/*' - - 'release/*' tags: - '*' pull_request: @@ -25,7 +22,7 @@ jobs: strategy: matrix: - php-versions: [ '8.2', '8.5' ] + php-versions: [ '8.3', '8.5' ] coverage: [none] fail-fast: false @@ -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: @@ -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 diff --git a/lib/GaletteAuto/Auto.php b/lib/GaletteAuto/Auto.php index 2b9c635..5799229 100644 --- a/lib/GaletteAuto/Auto.php +++ b/lib/GaletteAuto/Auto.php @@ -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; @@ -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 */ private array $propnames; //textual properties names diff --git a/lib/GaletteAuto/Autos.php b/lib/GaletteAuto/Autos.php index ab05e94..c4224db 100644 --- a/lib/GaletteAuto/Autos.php +++ b/lib/GaletteAuto/Autos.php @@ -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; diff --git a/lib/GaletteAuto/Body.php b/lib/GaletteAuto/Body.php index 4ee0103..ea4a95e 100644 --- a/lib/GaletteAuto/Body.php +++ b/lib/GaletteAuto/Body.php @@ -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 diff --git a/lib/GaletteAuto/Brand.php b/lib/GaletteAuto/Brand.php index 8463beb..28987a4 100644 --- a/lib/GaletteAuto/Brand.php +++ b/lib/GaletteAuto/Brand.php @@ -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 diff --git a/lib/GaletteAuto/Color.php b/lib/GaletteAuto/Color.php index 09c2540..f54fe48 100644 --- a/lib/GaletteAuto/Color.php +++ b/lib/GaletteAuto/Color.php @@ -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 diff --git a/lib/GaletteAuto/Filters/ModelsList.php b/lib/GaletteAuto/Filters/ModelsList.php index b4a44ee..7ca4997 100644 --- a/lib/GaletteAuto/Filters/ModelsList.php +++ b/lib/GaletteAuto/Filters/ModelsList.php @@ -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 diff --git a/lib/GaletteAuto/Finition.php b/lib/GaletteAuto/Finition.php index b4a1343..052a91c 100644 --- a/lib/GaletteAuto/Finition.php +++ b/lib/GaletteAuto/Finition.php @@ -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 diff --git a/lib/GaletteAuto/History.php b/lib/GaletteAuto/History.php index d4c9aae..209e5f8 100644 --- a/lib/GaletteAuto/History.php +++ b/lib/GaletteAuto/History.php @@ -39,7 +39,7 @@ */ class History { - public const TABLE = 'history'; + public const string TABLE = 'history'; private Db $zdb; diff --git a/lib/GaletteAuto/Model.php b/lib/GaletteAuto/Model.php index dd70bc6..4dc12f2 100644 --- a/lib/GaletteAuto/Model.php +++ b/lib/GaletteAuto/Model.php @@ -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; diff --git a/lib/GaletteAuto/Picture.php b/lib/GaletteAuto/Picture.php index e0f3fe8..df7b420 100644 --- a/lib/GaletteAuto/Picture.php +++ b/lib/GaletteAuto/Picture.php @@ -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. diff --git a/lib/GaletteAuto/PluginGaletteAuto.php b/lib/GaletteAuto/PluginGaletteAuto.php index 9eaafa2..be1c5e9 100644 --- a/lib/GaletteAuto/PluginGaletteAuto.php +++ b/lib/GaletteAuto/PluginGaletteAuto.php @@ -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; @@ -33,14 +39,17 @@ * @author Johan Cwiklinski */ -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> */ - public static function getMenusContents(): array + public function getMenus(): array { /** @var Login $login */ global $login; @@ -122,11 +131,11 @@ public static function getMenusContents(): array } /** - * Extra public menus entries + * Get plugins public menus * * @return array> */ - public static function getPublicMenusItemsList(): array + public function getPublicMenus(): array { return [ [ @@ -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> */ - public static function getMyDashboardsContents(): array + public function getMyDashboards(): array { /** @var Login $login */ global $login; @@ -165,11 +174,11 @@ public static function getMyDashboardsContents(): array } /** - * Get dashboards contents + * Get plugins dashboards * * @return array> */ - public static function getDashboardsContents(): array + public function getDashboards(): array { return []; } @@ -181,7 +190,7 @@ public static function getDashboardsContents(): array * * @return array> */ - public static function getListActionsContents(Adherent $member): array + public function getListActions(Adherent $member): array { return [ [ @@ -202,9 +211,9 @@ public static function getListActionsContents(Adherent $member): array * * @return array> */ - public static function getDetailedActionsContents(Adherent $member): array + public function getDetailedActions(Adherent $member): array { - return static::getListActionsContents($member); + return $this->getListActions($member); } /** @@ -212,8 +221,25 @@ public static function getDetailedActionsContents(Adherent $member): array * * @return array> */ - 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) + ; + } } diff --git a/lib/GaletteAuto/Repository/Models.php b/lib/GaletteAuto/Repository/Models.php index 14da5fc..acfce24 100644 --- a/lib/GaletteAuto/Repository/Models.php +++ b/lib/GaletteAuto/Repository/Models.php @@ -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; diff --git a/lib/GaletteAuto/State.php b/lib/GaletteAuto/State.php index e14989c..a724c18 100644 --- a/lib/GaletteAuto/State.php +++ b/lib/GaletteAuto/State.php @@ -32,10 +32,10 @@ */ class State extends AbstractObject { - public const TABLE = 'states'; - public const PK = 'id_state'; - public const FIELD = 'state'; - public const NAME = 'states'; + public const string TABLE = 'states'; + public const string PK = 'id_state'; + public const string FIELD = 'state'; + public const string NAME = 'states'; /** * Default constructor diff --git a/lib/GaletteAuto/Transmission.php b/lib/GaletteAuto/Transmission.php index 58e67c7..84674c0 100644 --- a/lib/GaletteAuto/Transmission.php +++ b/lib/GaletteAuto/Transmission.php @@ -32,10 +32,10 @@ */ class Transmission extends AbstractObject { - public const TABLE = 'transmissions'; - public const PK = 'id_transmission'; - public const FIELD = 'transmission'; - public const NAME = 'transmissions'; + public const string TABLE = 'transmissions'; + public const string PK = 'id_transmission'; + public const string FIELD = 'transmission'; + public const string NAME = 'transmissions'; /** * Default constructor