Initial commit
This commit is contained in:
80
local/Beds24/Form/ConfigurationForm.php
Normal file
80
local/Beds24/Form/ConfigurationForm.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia 2 PayZen Embedded payment module */
|
||||
/* */
|
||||
/* Copyright (c) Lyra Networks */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Beds24\Form;
|
||||
|
||||
use Beds24\Beds24;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
* PayZen Embedded payment module configuration form
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class ConfigurationForm extends BaseForm
|
||||
{
|
||||
/**
|
||||
* @return void|null
|
||||
* @throws Beds24\Beds24Exception
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
// -- Username and passwords -------------------------------------------------------------------------------
|
||||
->add(
|
||||
'api_key',
|
||||
'text',
|
||||
[
|
||||
'constraints' => [new NotBlank()],
|
||||
'required' => true,
|
||||
'label' => $this->trans('Beds24 API Key '),
|
||||
'label_attr' => [
|
||||
'help' => $this->trans('You\'ll find this key in your Beds24 account SETTINGS >> ACCOUNT >> ACCOUNT ACCESS.')
|
||||
]
|
||||
]
|
||||
)
|
||||
;
|
||||
|
||||
$api = new Beds24\Beds24Request();
|
||||
|
||||
$properties = $api->getPropertyList();
|
||||
|
||||
if (! $api->hasError($properties)) {
|
||||
foreach ($properties as $property) {
|
||||
$this->formBuilder->add(
|
||||
'prop_key_' . $property['id'],
|
||||
'text',
|
||||
[
|
||||
'constraints' => [new NotBlank()],
|
||||
'required' => true,
|
||||
'label' => $this->trans('Key for property ' . $property['name'] . ' - ' . $property['id']),
|
||||
'label_attr' => [
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function trans($string, $args = [])
|
||||
{
|
||||
return $this->translator->trans($string, $args, Beds24::DOMAIN_NAME);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'beds24_configuration_form';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user