/** * Legacy options were specified this way: * - either an array with a top level property 'cta_text' * and then the other properties * - or a numerically indexed array or arrays as described above * Since this was a mess, this method is provided to convert them. * It takes as input a legacy option (in either form) and always * returns an array of instances of PrestaShop\PrestaShop\Core\Payment\PaymentOption */ public static function convertLegacyOption(array $legacyOption) { if (!$legacyOption) { return; } if (array_key_exists('cta_text', $legacyOption)) { $legacyOption = array($legacyOption); } $newOptions = array(); $defaults = array('additionalInformation' => null, 'action' => null, 'form' => null, 'method' => null, 'inputs' => array(), 'logo' => null); foreach ($legacyOption as $option) { $option = array_merge($defaults, $option); $newOption = new self(); $newOption->setCallToActionText($option['cta_text'])->setAdditionalInformation($option['additionalInformation'])->setAction($option['action'])->setForm($option['form'])->setInputs($option['inputs'])->setLogo($option['logo']); $newOptions[] = $newOption; } return $newOptions; }