Source of file ComponentModel.php
Size: 1,555 Bytes - Last Modified: 2021-12-24T05:18:39+00:00
/var/www/docs.ssmods.com/process/src/src/Model/ComponentModel.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | <?php namespace Toast\ShopAPI\Model; use SilverShop\Checkout\Component\CheckoutComponent; /** * Class ComponentModel */ class ComponentModel extends ShopModelBase { /** @var CheckoutComponent $component */ protected $component; protected $type; protected $form_fields; protected $html; protected static $fields = [ 'type', 'html' ]; public function __construct($type) { parent::__construct(); $class = $type . 'CheckoutComponent'; // Check if the type is valid if (class_exists($class)) { $this->type = $type; $this->component = new $class(); // Get html $this->html = $this->forTemplate(); $this->form_fields = $this->component->getFormFields($this->order); } } public function getComponentFields() { $fields = $this->form_fields; $this->extend('updateComponentFields', $fields); return $this->form_fields; } public function forTemplate() { $componentTitle = preg_replace('/([a-z])([A-Z])/s', '$1 $2', $this->type); $this->extend('updateComponentTitle', $componentTitle); $fields = $this->getComponentFields(); $data = [ 'Title' => _t('TOASTSHOP' . $this->type . 'CheckoutComponentTitle', $componentTitle), 'Fields' => $fields ]; return $this->order->customise($data)->renderWith([$this->type . 'CheckoutComponent', 'CheckoutComponent'])->forTemplate(); } } |