Files
apart-moment/local/Beds24/Form/ConfigurationForm.php
2021-03-23 13:54:38 +01:00

81 lines
2.9 KiB
PHP

<?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';
}
}