Skip to content

Commit

Permalink
better check interface then type of submitted button
Browse files Browse the repository at this point in the history
in example is checking of type of button submited, but you extended from
Nette\Forms and you need getChanell function , so it should be better to
implement interface

public function gopayButtonsSubmittedForm(\Markette\Gopay\IPaymentButton
$button)
{
$channel = $button->getChannel();

}
  • Loading branch information
matak committed Aug 30, 2014
1 parent bf638e2 commit c6b5359
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Gopay/IPaymentButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Markette\Gopay;

interface IPaymentButton
{





function getChannel();
}
2 changes: 1 addition & 1 deletion Gopay/ImagePaymentButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @property-read $channel
*/
class ImagePaymentButton extends ImageButton
class ImagePaymentButton extends ImageButton implements IPaymentButton
{

/** @var string */
Expand Down
2 changes: 1 addition & 1 deletion Gopay/PaymentButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @property-read $channel
*/
class PaymentButton extends SubmitButton
class PaymentButton extends SubmitButton implements IPaymentButton
{

/** @var string */
Expand Down

4 comments on commit c6b5359

@matak
Copy link
Owner Author

@matak matak commented on c6b5359 Aug 30, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad example in documentation? need to check interface not type of button?

@vojtech-dobes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is this change good for?

@racinmat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Markette/Gopay in README.md you have:

$gopay->bindPaymentButtons($form, array($this->submittedForm));
Předaný callback bude zavolán po úspěšném odeslání formuláře jedním z platebních tlačítek (tedy jako po zavolání ->onClick[] na daném tlačítku). Zvolený kanál lze získat z tlačítka:

public function submittedForm(Markette\Gopay\PaymentButton $button)
{
$channel = $button->getChannel();
}

and this typehint is quite problematic, because when I use METHOD_GOPAY as payment method, it crashes because METHOD_GOPAY uses Markette\Gopay\ImagePaymentButton instead of Markette\Gopay\PaymentButton

@vojtech-dobes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now, you're right. Oki.

Please sign in to comment.