Payment example

$payment = $paymentRepository->findOneBy([
            'name' => $options['name'],
        ]);

        $pluginRepository = $this->em->getRepository(Plugin::class);
        /** @var Plugin $plugin */
        $plugin = $pluginRepository->findOneBy([
            'name' => $pluginName,
        ]);

        if (!$payment) {
            $payment = new Payment();
            $payment->setName($options['name']);
            $this->em->persist($payment);
        }
        $payment->fromArray($options);

        $payment->setPlugin($plugin);
        $this->em->flush($payment);

        return $payment;
    }
}
$params = $this->Request()->getParams();
            unset($params['action']);
            $repository = $this->get('models')->getRepository(Payment::class);
            $existingModel = $repository->findByName($params['name']);
            if ($existingModel) {
                throw new ORMException('The name is already in use.');
            }
            if ($params['source'] == 0) {
                $params['source'] = null;
            }

            $paymentModel = new Payment();
            $countries = $params['countries'] ?? [];
            $countryArray = [];
            foreach ($countries as $country) {
                $countryArray[] = $this->get('models')->find(Country::class$country['id']);
            }
            $params['countries'] = $countryArray;

            $shops = $params['shops'] ?? [];
            $shopArray = [];
            foreach ($shops as $shop) {
                $shopArray[] = $this->get('models')->find(Shop::class$shop['id']);
            }
public function __construct(AttributeHydrator $attributeHydrator)
    {
        $this->attributeHydrator = $attributeHydrator;
    }

    /** * @return Payment */
    public function hydrate(array $data)
    {
        $payment = new Payment();

        $translation = $this->getTranslation($data, '__payment', []$data['__payment_id']);
        $data = array_merge($data$translation);

        $payment->setId($data['__payment_id']);
        $payment->setName($data['__payment_name']);
        $payment->setDescription($data['__payment_description']);
        $payment->setTemplate($data['__payment_template']);
        $payment->setClass($data['__payment_class']);
        $payment->setTable($data['__payment_table']);
        $payment->setHide($data['__payment_hide']);
        
Home | Imprint | This part of the site doesn't use cookies.