Skip to content

Commit

Permalink
Add module do master
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanwalek committed Sep 14, 2022
1 parent bfefcaf commit 6e2aea6
Show file tree
Hide file tree
Showing 12 changed files with 1,425 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
20 changes: 20 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is a template, and might need editing before it works on your project.
# Publishes a tag/branch to Composer Packages of the current project
publish:
image: curlimages/curl:latest
stage: build
variables:
URL: "$CI_SERVER_PROTOCOL://$CI_SERVER_HOST:$CI_SERVER_PORT/api/v4/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN"
script:
- version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG")
- insecure=$([ "$CI_SERVER_PROTOCOL" = "http" ] && echo "--insecure" || echo "")
- response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL)
- code=$(echo "$response" | tail -n 1)
- body=$(echo "$response" | head -n 1)
# Output state information
- if [ $code -eq 201 ]; then
echo "Package created - Code $code - $body";
else
echo "Could not create package - Code $code - $body";
exit 1;
fi
22 changes: 22 additions & 0 deletions Api/SfxStoreConfigInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* SFX Store Config interface
*
* Copyright © MageXo, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace StorefrontX\SfxStoreConfig\Api;

use Magento\Framework\App\Config\ScopeConfigInterface;

interface SfxStoreConfigInterface
{
/**
* Retrieve SFX URL value by scope.
*
* @param null|int|string $scopeCode
* @return string
*/
public function getSfxUrl($scopeCode = null):string;
}
43 changes: 43 additions & 0 deletions Model/SfxStoreConfigFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright © MageXo, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace StorefrontX\SfxStoreConfig\Model;

use Magento\Framework\App\Config\ScopeConfigInterface;
use StorefrontX\SfxStoreConfig\Api\SfxStoreConfigInterface;

/**
* SFX fields in store config
*/
class SfxStoreConfigFields implements SfxStoreConfigInterface
{
private const SFX_URL = 'web/sfx/sfx_base_url';

private ScopeConfigInterface $scopeConfig;

public function __construct(ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
}

/**
* Get media URL format for catalog images
*
* @param null|int|string $scopeCode
* @return string
*/
public function getSfxUrl($scopeCode = null): string
{
$value = $this->scopeConfig->getValue(
self::SFX_URL,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$scopeCode
);

return (string)$value;
}
}
Loading

0 comments on commit 6e2aea6

Please sign in to comment.