Markette\Gopay\DI\Helpers::registerAddPaymentButtons PHP Метод

registerAddPaymentButtons() публичный статический Метод

Registers 'add*Buttons' & 'add*Button' methods to form
public static registerAddPaymentButtons ( Markette\Gopay\Form\Binder $binder, AbstractPaymentService $service )
$binder Markette\Gopay\Form\Binder
$service Markette\Gopay\Service\AbstractPaymentService
    public static function registerAddPaymentButtons(Binder $binder, AbstractPaymentService $service)
    {
        $class = new ReflectionClass($service);
        $method = lcfirst(str_replace('Service', '', $class->getShortName()));
        FormContainer::extensionMethod('add' . $method . 'Buttons', function ($container, $callbacks) use($binder, $service) {
            $binder->bindPaymentButtons($service, $container, $callbacks);
        });
        FormContainer::extensionMethod('add' . $method . 'Button', function ($container, $channel, $callback = NULL) use($binder, $service) {
            $channels = $service->getChannels();
            if (!isset($channels[$channel])) {
                throw new InvalidArgumentException("Channel '{$channel}' is not allowed.");
            }
            return $binder->bindPaymentButton($channels[$channel], $container, $callback = []);
        });
    }