1. Go to this page and download the library: Download maatify/shared-common 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/ */
maatify / shared-common example snippets
use Maatify\SharedCommon\Bootstrap\SharedCommonBindings;
use DI\ContainerBuilder;
use Maatify\SharedCommon\Contracts\ClockInterface;
$builder = new ContainerBuilder();
// Register the bindings for SharedCommon contracts
SharedCommonBindings::register($builder);
$container = $builder->build();
// Resolve the Clock
/** @var ClockInterface $clock */
$clock = $container->get(ClockInterface::class);
// Get the current time as a DateTimeImmutable object
$now = $clock->now();
echo $now->format('Y-m-d H:i:s');
declare(strict_types=1);
namespace Maatify\PaymentMethod\Security;
use Maatify\SharedCommon\Contracts\Security\PermissionMapProviderInterface;
use Maatify\SharedCommon\Contracts\Security\PermissionRequirementDefinition;
final class PaymentMethodPermissionMapProvider implements PermissionMapProviderInterface
{
/**
* @return array<string, PermissionRequirementDefinition>
*/
public function permissionMap(): array
{
return [
'payment_methods.list.ui' => PermissionRequirementDefinition::single('payment_methods.list'),
'payment_methods.list.api' => PermissionRequirementDefinition::single('payment_methods.list'),
'payment_methods.dropdown.api' => PermissionRequirementDefinition::anyOf([
'payment_methods.list',
'payment_methods.dropdown',
]),
'payment_methods.create.api' => PermissionRequirementDefinition::single('payment_methods.create'),
'payment_methods.update.api' => PermissionRequirementDefinition::single('payment_methods.update'),
];
}
}
declare(strict_types=1);
namespace Maatify\PaymentMethod;
use Maatify\PaymentMethod\Security\PaymentMethodPermissionMapProvider;
use Maatify\SharedCommon\Contracts\Security\PermissionMapProviderInterface;
use Maatify\SharedCommon\Contracts\Security\ProvidesPermissionMapsInterface;
final class PaymentMethodPackage implements ProvidesPermissionMapsInterface
{
/**
* @return list<PermissionMapProviderInterface>
*/
public function permissionMapProviders(): array
{
return [
new PaymentMethodPermissionMapProvider(),
];
}
}