This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7cd5582
Showing
88 changed files
with
4,105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
name: Checking coding standards | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache Composer Downloads | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Cache PHP dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: vendor | ||
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} | ||
|
||
- uses: MilesChou/composer-action@master | ||
with: | ||
args: config "http-basic.repo.magento.com" ${{ secrets.MAGE_USER }} ${{ secrets.MAGE_PASS }} | ||
|
||
- uses: MilesChou/composer-action@master | ||
with: | ||
args: install --prefer-dist | ||
|
||
|
||
- run: ./vendor/bin/grumphp run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/composer.lock | ||
/vendor | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Api; | ||
|
||
use Exception; | ||
use Magento\Framework\Api\SearchCriteriaInterface; | ||
use Magento\Framework\Api\SearchResultsInterface; | ||
use PHPro\CookieConsent\Api\Data\CookieGroupInterface; | ||
|
||
interface CookieGroupRepositoryInterface | ||
{ | ||
/** | ||
* @param CookieGroupInterface $cookieGroup | ||
* | ||
* @return CookieGroupInterface | ||
* @throws Exception | ||
*/ | ||
public function save(CookieGroupInterface $cookieGroup): CookieGroupInterface; | ||
|
||
/** | ||
* @param int $cookieGroupId | ||
* @param int $storeId | ||
* | ||
* @return CookieGroupInterface | ||
* @throws Exception | ||
*/ | ||
public function getById(int $cookieGroupId, int $storeId): CookieGroupInterface; | ||
|
||
/** | ||
* @param SearchCriteriaInterface $searchCriteria | ||
* | ||
* @return SearchResultsInterface | ||
* @throws Exception | ||
*/ | ||
public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface; | ||
|
||
/** | ||
* @param CookieGroupInterface $cookieGroup | ||
* | ||
* @return bool true on success | ||
* @throws Exception | ||
*/ | ||
public function delete(CookieGroupInterface $cookieGroup): bool; | ||
|
||
/** | ||
* @param int $id | ||
* | ||
* @return bool true on success | ||
* @throws Exception | ||
*/ | ||
public function deleteById(int $id): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Api\Data; | ||
|
||
interface CookieGroupInterface | ||
{ | ||
const ENTITY = 'phpro_cc_cookie_group'; | ||
const ENTITY_TABLE = self::ENTITY . '_entity'; | ||
|
||
const FIELD_SYSTEM_NAME = 'system_name'; | ||
const FIELD_NAME = 'name'; | ||
const FIELD_DESCRIPTION = 'description'; | ||
const FIELD_IS_ESSENTIAL = 'is_essential'; | ||
const FIELD_IS_ACTIVE = 'is_active'; | ||
|
||
const ATTRIBUTE_GROUP_GENERAL = 'General'; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId(): int; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSystemName(): string; | ||
|
||
/** | ||
* @param string $systemName | ||
* | ||
* @return CookieGroupInterface | ||
*/ | ||
public function setSystemName(string $systemName): CookieGroupInterface; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string; | ||
|
||
/** | ||
* @param string $name | ||
* | ||
* @return CookieGroupInterface | ||
*/ | ||
public function setName(string $name): CookieGroupInterface; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getDescription(): string; | ||
|
||
/** | ||
* @param string $description | ||
* | ||
* @return CookieGroupInterface | ||
*/ | ||
public function setDescription(string $description): CookieGroupInterface; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isEssential(): bool; | ||
|
||
/** | ||
* @param bool $essential | ||
* | ||
* @return CookieGroupInterface | ||
*/ | ||
public function setEssential(bool $essential): CookieGroupInterface; | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isActive(): bool; | ||
|
||
/** | ||
* @param bool $active | ||
* | ||
* @return CookieGroupInterface | ||
*/ | ||
public function setActive(bool $active): CookieGroupInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Api\Data; | ||
|
||
interface EavModelInterface | ||
{ | ||
const FIELD_STORE_ID = 'store_id'; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId(); | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getStoreId(): int; | ||
|
||
/** | ||
* @param int $storeId | ||
* | ||
* @return EavModelInterface | ||
*/ | ||
public function setStoreId(int $storeId): EavModelInterface; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEntityType(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Block\Adminhtml\Store\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class BackButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Back'), | ||
'on_click' => sprintf("location.href='%s'", $this->getBackUrl()), | ||
'class' => 'back', | ||
'sort_order' => 10, | ||
]; | ||
} | ||
|
||
public function getBackUrl(): string | ||
{ | ||
return $this->getUrl('*/*/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Block\Adminhtml\Store\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class DeleteButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->getModelId()) { | ||
$data = [ | ||
'label' => __('Delete Cookie Group'), | ||
'class' => 'delete', | ||
'on_click' => 'deleteConfirm(\'' . __( | ||
'Are you sure you want to do this?' | ||
) . '\', \'' . $this->getDeleteUrl() . '\')', | ||
'sort_order' => 20, | ||
]; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
public function getDeleteUrl(): string | ||
{ | ||
return $this->getUrl('*/*/delete', ['entity_id' => $this->getModelId()]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Block\Adminhtml\Store\Edit; | ||
|
||
use Magento\Backend\Block\Widget\Context; | ||
|
||
abstract class GenericButton | ||
{ | ||
/** | ||
* @var Context | ||
*/ | ||
protected $context; | ||
|
||
public function __construct(Context $context) | ||
{ | ||
$this->context = $context; | ||
} | ||
|
||
public function getModelId() | ||
{ | ||
return $this->context->getRequest()->getParam('entity_id'); | ||
} | ||
|
||
public function getUrl($route = '', $params = []): string | ||
{ | ||
return $this->context->getUrlBuilder()->getUrl($route, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Block\Adminhtml\Store\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData(): array | ||
{ | ||
return [ | ||
'label' => __('Save and Continue Edit'), | ||
'class' => 'save', | ||
'data_attribute' => [ | ||
'mage-init' => [ | ||
'button' => ['event' => 'saveAndContinueEdit'], | ||
], | ||
], | ||
'sort_order' => 80, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Block\Adminhtml\Store\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class SaveButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData(): array | ||
{ | ||
return [ | ||
'label' => __('Save Cookie Group'), | ||
'class' => 'save primary', | ||
'data_attribute' => [ | ||
'mage-init' => ['button' => ['event' => 'save']], | ||
'form-role' => 'save', | ||
], | ||
'sort_order' => 90, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PHPro\CookieConsent\Block\Widget; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Widget\Block\BlockInterface; | ||
use PHPro\CookieConsent\Model\ResourceModel\CookieGroup\CollectionFactory; | ||
|
||
class Overview extends Template implements BlockInterface | ||
{ | ||
protected $_template = "PHPro_CookieConsent::widget/overview.phtml"; | ||
|
||
/** | ||
* @var CollectionFactory | ||
*/ | ||
private $collectionFactory; | ||
|
||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
public function __construct( | ||
Context $context, | ||
CollectionFactory $collectionFactory, | ||
StoreManagerInterface $storeManager, | ||
array $data = [] | ||
) { | ||
$this->collectionFactory = $collectionFactory; | ||
$this->storeManager = $storeManager; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
public function getCookieGroups(): array | ||
{ | ||
$collection = $this->collectionFactory->create(); | ||
$collection->setStoreId($this->storeManager->getStore()->getId()) | ||
->addAttributeToSelect('*') | ||
->addAttributeToFilter('is_active', 1); | ||
|
||
return $collection->getItems(); | ||
} | ||
} |
Oops, something went wrong.