PHP code example of heptacom / shopware-platform-admin-open-auth

1. Go to this page and download the library: Download heptacom/shopware-platform-admin-open-auth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

heptacom / shopware-platform-admin-open-auth example snippets




namespace Heptacom\MyCustomPlugin\HeptacomOpenAuth;

use Heptacom\AdminOpenAuth\Contract\OAuthRuleScope;
use Heptacom\AdminOpenAuth\Contract\RuleActionInterface;
use Heptacom\AdminOpenAuth\Database\ClientRuleEntity;

class CustomRuleAction implements RuleActionInterface
{
    public static function getName(): string
    {
        return 'heptacom_my_custom_action';
    }
    
    public function getActionConfigurationComponent(): string
    {
        return 'heptacom-my-custom-action-config';
    }
    
    public function preResolveUser(ClientRuleEntity $rule, OAuthRuleScope $ruleScope): void {
        // your business logic here
    }
    
    public function postResolveUser(ClientRuleEntity $rule, OAuthRuleScope $ruleScope): void {
        // your business logic here
    }
}



namespace Heptacom\MyCustomPlugin\HeptacomOpenAuth;

use Heptacom\AdminOpenAuth\Contract\RuleActionInterface;
use Heptacom\AdminOpenAuth\Contract\OAuthRuleScope;
use Heptacom\AdminOpenAuth\Database\ClientRuleEntity;
use Psr\Log\LoggerInterface;

class CustomRuleAction implements RuleActionInterface
{
    public function __construct(
        private readonly LoggerInterface $logger
    ) {
    }
    
    // ...
    
    public function preResolveUser(ClientRuleEntity $rule, OAuthRuleScope $ruleScope): void {
        $this->logger->info(sprintf(
            'My custom action (preResolveUser) was executed with text: %s',
            $rule->getActionConfig()['myText']
        ));
    }
    
    public function postResolveUser(ClientRuleEntity $rule, OAuthRuleScope $ruleScope): void {
        $this->logger->info(sprintf(
            'My custom action (postResolveUser) was executed with text: %s',
            $rule->getActionConfig()['myText']
        ));
    }
}