/** * * @param string $name * @param Ajde_Shop_Transaction $transaction * @return Ajde_Shop_Transaction_Provider * @throws Ajde_Exception */ public static function getProvider($name, $transaction = null) { $providerClass = ExternalLibs::getClassname('Ajde_Shop_Transaction_Provider_' . self::classnameToUppercase($name)); if (!Autoloader::exists($providerClass)) { // TODO: throw new Exception('Payment provider ' . $name . ' not found'); } $obj = new $providerClass(); if ($transaction) { $obj->setTransaction($transaction); } return $obj; }
public function createField($fieldOptions) { if (!isset($fieldOptions['type'])) { $fieldOptions['type'] = 'text'; } $fieldClass = ExternalLibs::getClassname("Ajde_Crud_Field_" . ucfirst($fieldOptions['type'])); $field = new $fieldClass($this, $fieldOptions); if ($this->getOperation() === 'edit') { if (!$field->hasValue() || $field->hasEmpty('value')) { if ($this->isNew() && $field->hasNotEmpty('default')) { $field->setValue($field->getDefault()); } elseif (!$this->isNew() && $this->getItem()->has($field->getName())) { $field->setValue($this->getItem()->get($field->getName())); } else { $field->setValue(false); } } } return $field; }