*/ class SquareTwigRuntime { private $apiClient; public function __construct($apiClient, $twig, $config) { $this->apiClient = $apiClient; $this->twig = $twig; $this->config = $config; } public function getCatalog() { try { $catalogApi = new \SquareConnect\Api\CatalogApi($this->apiClient); $products = $catalogApi->listCatalog(); } catch (Exception $e) { error_log($e->getMessage()); return 'ERROR: '.$e->getMessage(); } $response = []; foreach($products['objects'] as $p) { if ($p['type'] === 'ITEM') { array_push($response, $p); } } return $response; } public function displayCCForm() { $context = $this->config + [ 'testmode' => true ]; return $this->twig->render('@Squarefront/cardentryform.twig', $context); } }