Skip to content

Commit 9efd5e7

Browse files
author
Rafael Grigorian
committed
Released Version 1.2.0
Fixed #9
1 parent c6ee8b2 commit 9efd5e7

File tree

169 files changed

+303
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+303
-171
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
> Interact with popular Cloudflare features though Magento's backend portal.
33
44
![](https://img.shields.io/badge/License-MIT-orange.svg?style=for-the-badge)
5-
![](https://img.shields.io/badge/Version-1.1.1-orange.svg?style=for-the-badge)
5+
![](https://img.shields.io/badge/Version-1.2.0-orange.svg?style=for-the-badge)
66
![](https://img.shields.io/badge/Stability-Stable-orange.svg?style=for-the-badge)
77
![](https://img.shields.io/badge/Magento-2-orange.svg?style=for-the-badge)
88

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "jetrails/magento2-cloudflare",
33
"description": "Interact with popular Cloudflare features though Magento's backend portal",
44
"type": "magento2-module",
5-
"version": "1.1.1",
5+
"version": "1.2.0",
66
"license": "MIT",
77
"authors": [
88
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.1.1",
2+
"version": "1.2.0",
33
"name": "magento2-cloudflare",
44
"description": "Interact with popular Cloudflare features though Magento's backend portal",
55
"author": "Rafael Grigorian",

src/app/code/JetRails/Cloudflare/Block/Adminhtml/Dashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* methods that load and render tab contents. It also contains methods that
1515
* help determine if the current store is configured with the supplied
1616
* Cloudflare account.
17-
* @version 1.1.1
17+
* @version 1.2.0
1818
* @package JetRails® Cloudflare
1919
* @author Rafael Grigorian <[email protected]>
2020
* @copyright © 2018 JETRAILS, All rights reserved

src/app/code/JetRails/Cloudflare/Block/Adminhtml/Dashboard/Section.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* folder. This block class has methods that give the template access to a
1414
* valid form key for AJAX communications. This block class also returns a
1515
* custom endpoint for every section based on the binded template's path.
16-
* @version 1.1.1
16+
* @version 1.2.0
1717
* @package JetRails® Cloudflare
1818
* @author Rafael Grigorian <[email protected]>
1919
* @copyright © 2018 JETRAILS, All rights reserved

src/app/code/JetRails/Cloudflare/Block/Adminhtml/Dashboard/Tab.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* This block class is used for tab template files. These template files
1313
* use this block's helper methods in order to render all the sections that
1414
* belong to said tab.
15-
* @version 1.1.1
15+
* @version 1.2.0
1616
* @package JetRails® Cloudflare
1717
* @author Rafael Grigorian <[email protected]>
1818
* @copyright © 2018 JETRAILS, All rights reserved
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
namespace JetRails\Cloudflare\Console\Command;
4+
5+
use JetRails\Cloudflare\Helper\Adminhtml\Data;
6+
use Magento\Framework\App\Cache\TypeListInterface;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Input\InputOption;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
class SetAuth extends Command {
13+
14+
/**
15+
* These internal data members include instances of helper classes that are injected into
16+
* the class using dependency injection on runtime. Also a boolean variable is included
17+
* that defines if the action should be run if the feature is disabled in the store config.
18+
* @var TypeListInterface _cacheTypeList Instance of the TypeListInterface class
19+
* @var Data _data Instance of the Data class
20+
* @var Logger _logger Instance of the Logger class
21+
* @var Purger _purger Instance of the Purger class
22+
* @var Boolean _runIfDisabled Execute method if feature isn't on?
23+
*/
24+
protected $_cacheTypeList;
25+
protected $_data;
26+
27+
/**
28+
* This constructor is overloaded from the parent class in order to use dependency injection
29+
* to get the dependency classes that we need for this module's command actions to execute.
30+
* @param Data data Instance of the Data class
31+
* @param TypeListInterface cacheTypeList Instance of the TypeListInterface class
32+
*/
33+
public function __construct (
34+
Data $data,
35+
TypeListInterface $cacheTypeList
36+
) {
37+
// Call the parent constructor
38+
parent::__construct ();
39+
// Save injected classes internally
40+
$this->_cacheTypeList = $cacheTypeList;
41+
$this->_data = $data;
42+
}
43+
44+
/**
45+
* Inside we set the command name and set the command description.
46+
* @return void
47+
*/
48+
protected function configure () {
49+
// Register the command and set the arguments
50+
$options = [
51+
new InputOption (
52+
"domain",
53+
null,
54+
InputOption::VALUE_REQUIRED,
55+
"What is the domain name?"
56+
),
57+
new InputOption (
58+
"zone",
59+
null,
60+
InputOption::VALUE_REQUIRED,
61+
"What is the Cloudflare Zone ID?"
62+
),
63+
new InputOption (
64+
"token",
65+
null,
66+
InputOption::VALUE_REQUIRED,
67+
"What is the Cloudflare API token?"
68+
)
69+
];
70+
$this
71+
->setName ("cloudflare:set-auth")
72+
->setDescription ("Save Cloudflare zone-id/api-token for given domain name")
73+
->setDefinition ( $options );
74+
parent::configure ();
75+
}
76+
77+
/**
78+
* This method is here because it interfaces with the abstract parent class. It takes in an
79+
* input and output interface and it runs the command.
80+
* @param InputInterface input The input interface
81+
* @param OutputInterface output The output interface
82+
* @return void
83+
*/
84+
public function execute ( InputInterface $input, OutputInterface $output ) {
85+
$domain = $input->getOption ("domain");
86+
$zone = $input->getOption ("zone");
87+
$token = $input->getOption ("token");
88+
if ( !$domain ) {
89+
$output->writeln ("Error: please pass domain name with --domain option.");
90+
return $this;
91+
}
92+
if ( !$zone ) {
93+
$output->writeln ("Error: please pass zone name with --zone option.");
94+
return $this;
95+
}
96+
if ( !$token ) {
97+
$output->writeln ("Error: please pass token name with --token option.");
98+
return $this;
99+
}
100+
$domains = array_map ( function ( $entry ) {
101+
return $entry ["name"];
102+
}, $this->_data->getDomainNames () );
103+
if ( !in_array ( $domain, $domains ) ) {
104+
$output->writeln ("Error: invalid domain name, available options are:");
105+
$output->writeln ("");
106+
foreach ( $domains as $d) {
107+
$output->writeln ("- $d");
108+
}
109+
$output->writeln ("");
110+
return $this;
111+
}
112+
$this->_data->setAuthZone ( $zone, $domain );
113+
$this->_data->setAuthToken ( $token, $domain );
114+
$output->writeln ("Successfully saved zone and token for domain $domain.");
115+
}
116+
117+
}

src/app/code/JetRails/Cloudflare/Controller/Adminhtml/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* This is a generic controller that is used within other controller classes
1313
* in this module. It supplies many helper methods that the child classes
1414
* can use which simplify the code.
15-
* @version 1.1.1
15+
* @version 1.2.0
1616
* @package JetRails® Cloudflare
1717
* @author Rafael Grigorian <[email protected]>
1818
* @copyright © 2018 JETRAILS, All rights reserved

src/app/code/JetRails/Cloudflare/Controller/Adminhtml/Api/Caching/AlwaysOnline/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* base functionality for interfacing with a getter model. This action
1010
* simply loads the initial value through the Cloudflare API. The rest of
1111
* this class extends on that functionality and adds more endpoints.
12-
* @version 1.1.1
12+
* @version 1.2.0
1313
* @package JetRails® Cloudflare
1414
* @author Rafael Grigorian <[email protected]>
1515
* @copyright © 2018 JETRAILS, All rights reserved

src/app/code/JetRails/Cloudflare/Controller/Adminhtml/Api/Caching/AlwaysOnline/Toggle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* simply loads the initial value through the Cloudflare API as well as
1111
* gives the ability to change the value of said section to be on or off
1212
* though the 'toggle' action.
13-
* @version 1.1.1
13+
* @version 1.2.0
1414
* @package JetRails® Cloudflare
1515
* @author Rafael Grigorian <[email protected]>
1616
* @copyright © 2018 JETRAILS, All rights reserved

0 commit comments

Comments
 (0)