Skip to content

Commit 3c58030

Browse files
committed
first commit
1 parent f708f0b commit 3c58030

10 files changed

+257
-1
lines changed

.gitignore

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
### webdev-gitignore by https://github.com/TurboLabIt/webdev-gitignore/ ###
2+
########################################################################
3+
#
4+
# curl -o .gitignore https://raw.githubusercontent.com/TurboLabIt/webdev-gitignore/master/.gitignore?$(date +%s)
5+
6+
# IDEs #
7+
########
8+
.idea
9+
.settings
10+
nbproject
11+
.buildpath
12+
.project
13+
*.code-workspace
14+
.vscode
15+
.run
16+
17+
18+
# Logs #
19+
########
20+
*.log
21+
22+
23+
# SVN #
24+
#######
25+
.svn
26+
27+
28+
# composer #
29+
############
30+
composer.lock
31+
/vendor/
32+
website/www/vendor/
33+
34+
35+
# OS generated files #
36+
######################
37+
__MACOSX
38+
*.DS_Store*
39+
._*
40+
.Spotlight-V100
41+
.Trash*
42+
ehthumbs.db
43+
Thumbs.db
44+
desktop.ini
45+
46+
47+
# Links #
48+
##########
49+
*.lnk
50+
51+
52+
# Let's Encrypt #
53+
#################
54+
.well-known/
55+
56+
57+
# Node.js #
58+
###########
59+
node_modules/
60+
npm-debug.log
61+
.sass-cache/
62+
bower_components/
63+
64+
65+
# Patches #
66+
###########
67+
*.rej
68+
69+
70+
## Autodeploy ##
71+
################
72+
public/autodeploy.php
73+
public/autodeploy-async.php
74+
public/async-runner-request.php
75+
76+
77+
## Webdriver ##
78+
################
79+
drivers/chromedriver
80+
drivers/geckodriver
81+
82+
83+
## Sitemap ##
84+
#############
85+
/public/sitemap/
86+
/public/sitemap_new/
87+
88+
89+
## Environment ##
90+
#################
91+
# https://github.com/TurboLabIt/bash-fx/blob/main/scripts/app-env.sh
92+
/env
93+
94+
95+
###> symfony/framework-bundle ###
96+
/.env.local
97+
/.env.local.php
98+
/.env.*.local
99+
/config/secrets/prod/prod.decrypt.private.php
100+
/public/bundles/
101+
/var/
102+
/src/.preload.php
103+
###< symfony/framework-bundle ###
104+
105+
###> symfony/phpunit-bridge ###
106+
.phpunit
107+
.phpunit.result.cache
108+
/phpunit.xml
109+
###< symfony/phpunit-bridge ###
110+
111+
112+
/wordpress/

.php-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.2

README.md

-1
This file was deleted.

composer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "turbolabit/php-symfony-shopify-sdk",
3+
"description": "",
4+
"type": "symfony-bundle",
5+
"autoload": {
6+
"psr-4": {
7+
"TurboLabIt\\ShopifySdk\\": "src/"
8+
}
9+
},
10+
"autoload-dev": {
11+
"psr-4": {
12+
"TurboLabIt\\ShopifySdk\\tests\\": "tests/"
13+
}
14+
},
15+
"authors": [
16+
{
17+
"name": "Zane"
18+
}
19+
],
20+
"require": {
21+
"php": "^8.2",
22+
"sammyjo20/saloon": "^2.0"
23+
},
24+
"require-dev": {
25+
"phpunit/phpunit": "^10.2",
26+
"symfony/framework-bundle": "^6.3"
27+
},
28+
"config": {
29+
"allow-plugins": {
30+
"pestphp/pest-plugin": false
31+
}
32+
}
33+
}

config/services.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
TurboLabIt\ShopifySdk\Service\ShopifyAdminConnector:
3+
4+
shopifysdk.admin_connector:
5+
alias: TurboLabIt\ShopifySdk\Service\ShopifyAdminConnector
6+
public: true

scripts/test-runner.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
clear
3+
4+
source "/usr/local/turbolab.it/webstackup/script/base.sh"
5+
APP_NAME=BaseCommand
6+
EXPECTED_USER=$(logname)
7+
8+
fxHeader "🧪 ${APP_NAME} Test Runner"
9+
#export XDEBUG_MODE=off
10+
11+
# https://github.com/TurboLabIt/webstackup/tree/master/script/php/test-runner-package.sh
12+
source "${WEBSTACKUP_SCRIPT_DIR}php/test-runner-package.sh"
13+
14+
fxTitle "🧹 Cleaning up..."
15+
#rm -rf /tmp/BaseCommandTestInstance
16+
17+
fxEndFooter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
namespace TurboLabIt\ShopifySdkExtension\DependencyInjection;
3+
4+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
5+
use Symfony\Component\Config\FileLocator;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
8+
9+
10+
class ShopifySdkExtension extends Extension
11+
{
12+
public function load(array $configs, ContainerBuilder $container)
13+
{
14+
$loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/../config'));
15+
$loader->load('services.yaml');
16+
}
17+
}

src/Service/ShopifyAdminConnector.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
namespace TurboLabIt\ShopifySdk\Service;
3+
4+
use Saloon\Http\Connector;
5+
6+
7+
class ShopifyAdminConnector extends Connector
8+
{
9+
protected string $endpoint = 'https://##shop-name##.myshopify.com/admin/api/##api-version##/graphql.json';
10+
11+
12+
public function __construct(protected array $arrConfig)
13+
{ }
14+
15+
16+
public function resolveBaseUrl(): string
17+
{
18+
$arrData = [
19+
"##shop-name##" => $this->arrConfig["shop_name"],
20+
"##api-version##" => $this->arrConfig["api_version"],
21+
];
22+
23+
$endpoint = str_ireplace(array_keys($arrData), array_values($arrData), $this->endpoint);
24+
return $endpoint;
25+
}
26+
}

src/ShopifySdkBundle.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace TurboLabIt\ShopifySdk;
3+
4+
use Symfony\Component\HttpKernel\Bundle\Bundle;
5+
6+
7+
class ShopifySdkBundle extends Bundle
8+
{
9+
10+
}

tests/ShopifyAdminConnectorTest.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
namespace TurboLabIt\ShopifySdk\tests;
3+
4+
use PHPUnit\Framework\TestCase;
5+
use Symfony\Component\Config\Loader\LoaderInterface;
6+
use Symfony\Component\HttpKernel\Kernel;
7+
use TurboLabIt\ShopifySdk\ShopifySdkBundle;
8+
9+
10+
class ShopifyAdminConnectorTest extends TestCase
11+
{
12+
public function test()
13+
{
14+
$kernel = new ShopifySdkTestingKernel("test", true);
15+
$kernel->boot();
16+
$container = $kernel->getContainer();
17+
18+
$connector = $container->get('shopifysdk.admin_connector');
19+
}
20+
}
21+
22+
23+
class ShopifySdkTestingKernel extends Kernel
24+
{
25+
public function registerBundles(): iterable
26+
{
27+
return [
28+
new ShopifySdkBundle(),
29+
];
30+
}
31+
32+
public function registerContainerConfiguration(LoaderInterface $loader)
33+
{
34+
}
35+
}

0 commit comments

Comments
 (0)