Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Added release 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vrielsa committed Dec 15, 2020
0 parents commit 7cd5582
Show file tree
Hide file tree
Showing 88 changed files with 4,105 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/grumphp.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/composer.lock
/vendor
.idea/
52 changes: 52 additions & 0 deletions Api/CookieGroupRepositoryInterface.php
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;
}
82 changes: 82 additions & 0 deletions Api/Data/CookieGroupInterface.php
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;
}
30 changes: 30 additions & 0 deletions Api/Data/EavModelInterface.php
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;
}
23 changes: 23 additions & 0 deletions Block/Adminhtml/Store/Edit/BackButton.php
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('*/*/');
}
}
30 changes: 30 additions & 0 deletions Block/Adminhtml/Store/Edit/DeleteButton.php
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()]);
}
}
28 changes: 28 additions & 0 deletions Block/Adminhtml/Store/Edit/GenericButton.php
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);
}
}
22 changes: 22 additions & 0 deletions Block/Adminhtml/Store/Edit/SaveAndContinueButton.php
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,
];
}
}
21 changes: 21 additions & 0 deletions Block/Adminhtml/Store/Edit/SaveButton.php
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,
];
}
}
45 changes: 45 additions & 0 deletions Block/Widget/Overview.php
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();
}
}
Loading

0 comments on commit 7cd5582

Please sign in to comment.