Skip to content

Commit

Permalink
Merge branch 'b-7.2.x' into b-8.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieg committed Aug 23, 2024
2 parents 9c91069 + 98ac58d commit 8da334f
Show file tree
Hide file tree
Showing 30 changed files with 444 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/commit-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker compose exec --workdir /var/www/vendor/oxid-esales/module-template php composer static
docker compose exec -T --workdir /var/www/vendor/oxid-esales/module-template php composer static
37 changes: 31 additions & 6 deletions .github/workflows/dispatch_module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ on:
type: choice
options:
- 'no'
- 'PHP8.1/MySQL5.7'
- 'PHP8.1/MySQL8.0'
- 'PHP8.2/MySQL5.7'
- 'PHP8.2/MySQL8.0'
default: 'PHP8.1/MySQL5.7'
- 'PHP8.3/MySQL5.7'
- 'PHP8.3/MySQL8.0'
default: 'PHP8.2/MySQL8.0'
description: 'Limit to one PHP/MySQL combination'
use_dev_version:
type: choice
options: ['no', 'v0']
description: 'Use the dev version of github actions'
default: 'no'

jobs:
build_testplan:
Expand All @@ -28,19 +33,20 @@ jobs:
# shellcheck disable=SC2088
case "${{ inputs.limit }}" in
"no") LIMIT='';;
"PHP8.1/MySQL5.7") LIMIT='~/defaults/php8.1_mysql5.7_only.yaml,' ;;
"PHP8.1/MySQL8.0") LIMIT='~/defaults/php8.1_mysql8.0_only.yaml,' ;;
"PHP8.2/MySQL5.7") LIMIT='~/defaults/php8.2_mysql5.7_only.yaml,' ;;
"PHP8.2/MySQL8.0") LIMIT='~/defaults/php8.2_mysql8.0_only.yaml,' ;;
"PHP8.3/MySQL5.7") LIMIT='~/defaults/php8.3_mysql5.7_only.yaml,' ;;
"PHP8.3/MySQL8.0") LIMIT='~/defaults/php8.3_mysql8.0_only.yaml,' ;;
*) echo "Illegal choice, fix the workflow"
exit 1
;;
esac
# shellcheck disable=SC2088
TESTPLAN="~/defaults/7.1.x.yaml,${LIMIT}~/module-template.yaml"
TESTPLAN="~/defaults/7.2.x.yaml,${LIMIT}~/module-template.yaml"
echo "testplan=${TESTPLAN}" | tee -a "${GITHUB_OUTPUT}"
dispatch_stable:
if: ${{ inputs.use_dev_version == 'no' }}
needs: build_testplan
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v4
with:
Expand All @@ -57,3 +63,22 @@ jobs:
enterprise_github_token: ${{ secrets.enterprise_github_token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

dispatch_v0:
if: ${{ inputs.use_dev_version == 'v0' }}
needs: build_testplan
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v0
with:
testplan: ${{ needs.build_testplan.outputs.testplan }}
runs_on: '"ubuntu-latest"'
defaults: 'v0'
plan_folder: '.github/oxid-esales'
secrets:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
CACHE_ENDPOINT: ${{ secrets.CACHE_ENDPOINT }}
CACHE_ACCESS_KEY: ${{ secrets.CACHE_ACCESS_KEY }}
CACHE_SECRET_KEY: ${{ secrets.CACHE_SECRET_KEY }}
enterprise_github_token: ${{ secrets.enterprise_github_token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
if: always()
uses: oxid-eSales/github-actions/.github/workflows/universal_workflow_light.yaml@v4
with:
testplan: '~/defaults/7.1.x.yaml,~/defaults/scheduled.yaml,~/module-template.yaml'
testplan: '~/defaults/7.2.x.yaml,~/defaults/scheduled.yaml,~/module-template.yaml'
runs_on: '"ubuntu-latest"'
defaults: 'v4'
plan_folder: '.github/oxid-esales'
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v3.1.0] - unreleased

### Added
- Admin controller example in Greeting namespace
- Template for special greeting admin controller
- Example with extending of current admin template
- ``oxNew`` model object factory example in Greeting namespace infrastructure

### Fixed
- "the input device is not a TTY" error message during github hook if problems found

## [v3.1.0] - Unreleased

### Removed
- PHP 8.1 support removed

## [v3.0.0] - 2024-06-27

This is the stable release for v3.0.0. No changes have been made since v3.0.0-rc.1.
Expand All @@ -29,6 +45,14 @@ This is the stable release for v3.0.0. No changes have been made since v3.0.0-rc
- Smarty support
- Migration are not triggered anymore on module activation. Ensure you run them separately after module **Installation**.

## [v2.2.0] - unreleased

### Added
- Admin controller
- Template for admin controller
- Example of extending of current admin template
- ``oxNew`` object factory example

## [v2.1.0] - 2024-05-30

### Added
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ Story:
* extending a shop model (`OxidEsales\ModuleTemplate\Extension\Model\User`) / (`OxidEsales\ModuleTemplate\Extension\Model\Basket`)
* extending a shop controller (`OxidEsales\ModuleTemplate\Extension\Controller\StartController`)
* extending a shop database table (`oxuser`)
* extending a shop template block (`start_welcome_text`)
* extending a shop template block (`start_newest_articles`)
* extending a shop admin template block (`admin_user_main_form` - only an extension of a block, without functionality)

**HINT**: only extend the shop core if there is no other way like listen and handle shop events,
decorate/replace some DI service. Your module might be one of many in the class chain and you should
Expand All @@ -227,10 +228,12 @@ If you need to extend the shop class chain by overwriting, try to stick to the p

#### Sometimes we need to bring our own
* own module controller (`oemtgreeting` with own template and own translations)
* own module admin controller (`oemt_admin_greeting` with own template and own translations)
* module setting (`oemoduletemplate_GreetingMode`)
* event subscriber (`OxidEsales\ModuleTemplate\Tracker\Subscriber\BeforeModelUpdate`)
* model with a database (`OxidEsales\ModuleTemplate\Tracker\Model\GreetingTracker`)
* DI service examples
* ``oxNew`` object factory example (`OxidEsales\ModuleTemplate\Greeting\Infrastructure\UserModelFactory`)

#### Whatever you do, ensure it is covered with tests
* unit/integration test
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"phpstan/phpstan": "^1.9.14",
"squizlabs/php_codesniffer": "3.*",
"phpmd/phpmd": "^2.11",
"oxid-esales/oxideshop-ce": "dev-b-7.1.x",
"oxid-esales/oxideshop-ce": "dev-b-7.2.x",
"phpunit/phpunit": "~10.5.17",
"mikey179/vfsstream": "~1.6.8",
"codeception/codeception": "*",
Expand Down
10 changes: 10 additions & 0 deletions menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="ISO-8859-15"?>
<OX>
<OXMENU id="NAVIGATION_ESHOPADMIN">
<MAINMENU id="mxuadmin">
<SUBMENU id="mxusers">
<TAB id="tbcluser_greetings" cl="oemt_admin_greeting" />
</SUBMENU>
</MAINMENU>
</OXMENU>
</OX>
3 changes: 2 additions & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
\OxidEsales\Eshop\Application\Model\User::class => \OxidEsales\ModuleTemplate\Extension\Model\User::class,
],
'controllers' => [
'oemtgreeting' => \OxidEsales\ModuleTemplate\Greeting\Controller\GreetingController::class
'oemtgreeting' => \OxidEsales\ModuleTemplate\Greeting\Controller\GreetingController::class,
'oemt_admin_greeting' => \OxidEsales\ModuleTemplate\Greeting\Controller\Admin\GreetingAdminController::class,
],
'events' => [
'onActivate' => '\OxidEsales\ModuleTemplate\Core\ModuleEvents::onActivate',
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ final class Module
public const OEMT_COUNTER_TEMPLATE_VARNAME = 'oemt_greeting_counter';

public const DEFAULT_PERSONAL_GREETING_LANGUAGE_CONST = 'OEMODULETEMPLATE_GREETING_GENERIC';

public const OEMT_ADMIN_GREETING_TEMPLATE_VARNAME = 'greeting_message';
}
32 changes: 32 additions & 0 deletions src/Greeting/Controller/Admin/GreetingAdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\ModuleTemplate\Greeting\Controller\Admin;

use OxidEsales\ModuleTemplate\Core\Module as ModuleCore;
use OxidEsales\Eshop\Application\Controller\Admin\AdminController;
use OxidEsales\ModuleTemplate\Extension\Model\User as TemplateModelUser;
use OxidEsales\ModuleTemplate\Greeting\Service\UserServiceInterface;

class GreetingAdminController extends AdminController
{
protected $_sThisTemplate = '@oe_moduletemplate/admin/user_greetings';

public function render()
{
$userService = $this->getService(UserServiceInterface::class);
if ($this->getEditObjectId()) {
/** @var TemplateModelUser $oUser */
$oUser = $userService->getUserById($this->getEditObjectId());
$this->addTplParam(ModuleCore::OEMT_ADMIN_GREETING_TEMPLATE_VARNAME, $oUser->getPersonalGreeting());
}

return parent::render();
}
}
23 changes: 23 additions & 0 deletions src/Greeting/Infrastructure/UserModelFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\ModuleTemplate\Greeting\Infrastructure;

use OxidEsales\Eshop\Application\Model\User;

class UserModelFactory implements UserModelFactoryInterface
{
/**
* @inheritDoc
*/
public function create(): User
{
return oxNew(User::class);
}
}
18 changes: 18 additions & 0 deletions src/Greeting/Infrastructure/UserModelFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

namespace OxidEsales\ModuleTemplate\Greeting\Infrastructure;

use OxidEsales\Eshop\Application\Model\User;

interface UserModelFactoryInterface
{
/**
* @return User
*/
public function create(): User;
}
38 changes: 38 additions & 0 deletions src/Greeting/Service/UserService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\ModuleTemplate\Greeting\Service;

use OxidEsales\Eshop\Application\Model\User as EshopModelUser;
use OxidEsales\ModuleTemplate\Greeting\Infrastructure\UserModelFactoryInterface;

/**
* @extendable-class
*/
class UserService implements UserServiceInterface
{
/**
* @var UserModelFactoryInterface
*/
private $userModelFactory;

public function __construct(
UserModelFactoryInterface $userModelFactory
) {
$this->userModelFactory = $userModelFactory;
}

public function getUserById(string $userId): EshopModelUser
{
$userModel = $this->userModelFactory->create();
$userModel->load($userId);

return $userModel;
}
}
17 changes: 17 additions & 0 deletions src/Greeting/Service/UserServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\ModuleTemplate\Greeting\Service;

use OxidEsales\Eshop\Application\Model\User as EshopModelUser;

interface UserServiceInterface
{
public function getUserById(string $userId): EshopModelUser;
}
9 changes: 8 additions & 1 deletion src/Greeting/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ services:

OxidEsales\ModuleTemplate\Greeting\Service\GreetingMessageServiceInterface:
class: OxidEsales\ModuleTemplate\Greeting\Service\GreetingMessageService
public: true
public: true

OxidEsales\ModuleTemplate\Greeting\Infrastructure\UserModelFactoryInterface:
class: OxidEsales\ModuleTemplate\Greeting\Infrastructure\UserModelFactory

OxidEsales\ModuleTemplate\Greeting\Service\UserServiceInterface:
class: OxidEsales\ModuleTemplate\Greeting\Service\UserService
public: true
5 changes: 5 additions & 0 deletions tests/Codeception/Acceptance.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ modules:
depends:
- WebDriver
- Db
- \OxidEsales\Codeception\Module\OxideshopAdmin:
screen_shot_url: '%SCREEN_SHOT_URL%'
depends:
- WebDriver
- \OxidEsales\Codeception\Module\Oxideshop
- \OxidEsales\Codeception\Module\Database:
depends: Db
- \OxidEsales\Codeception\Module\SelectTheme:
Expand Down
Loading

0 comments on commit 8da334f

Please sign in to comment.