-
Notifications
You must be signed in to change notification settings - Fork 97
Conversation
src/Cpanel/PluginActions.php
Outdated
'featureManagerIsFullZoneProvisioningEnabled' => true, | ||
'isDNSPageEnabled' => true, | ||
'useHostAPILogin' => true, | ||
'homePageCards' => array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI you could just do:
array('AlwaysOnlineCard','IPV6Card',...,'PurgeCacheCard');
Don't need to change but in the future lets avoid hard coding indexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but make sure @thellimist approves before merging.
src/Cpanel/PluginActions.php
Outdated
$this->getComposerJson(); | ||
|
||
//Clone the config to manipulate | ||
$config = array_merge(array(), self::$CONFIG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if array_merge
does deep copy. You might need to use array_merge_recursive
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you would only need to do this if you weren't merging into an empty array()
. None of the child arrays will conflict since they don't exist on the empty array()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically I think you're right but since we're using array_merge()
to clone an array it doesn't matter.
src/Cpanel/PluginActions.php
Outdated
$this->userConfig = []; | ||
} else { | ||
$this->userConfig = json_decode($userConfigContent, true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
case is almost never needed. This can be written as
$this->userConfig = [];
if ($userConfigContent) {
$this->userConfig = json_decode($userConfigContent, true);
}
]; | ||
$this->pluginActions->setUserConfig($userConfig); | ||
$response = $this->pluginActions->getConfig(); | ||
$this->assertEquals(true, $response['debug']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertTrue
can be used
config.json.sample
Outdated
@@ -0,0 +1,3 @@ | |||
{ | |||
"featureManagerIsFullZoneProvisioningEnabled": false | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwineman we can't write comments on .json
files. We need to let the user figure out what settings are configurable. From this sample file as a user I'd say only featureManagerIsFullZoneProvisioningEnabled
is configurable.
In my opinion, we should have all the default settings which can be configurable in the sample. I've listed the items which I think should be configurable.
{
"debug": false,
"featureManagerIsFullZoneProvisioningEnabled": true,
"homePageCards": [
"AlwaysOnlineCard",
"IPV6Card",
"CacheLevelCard",
"RailgunCard",
"PurgeCacheCard"
],
"moreSettingsCards": {
"container.moresettings.security": [
"SecurityLevelCard",
"ChallengePassageCard",
"BrowserIntegrityCheckCard"
],
"container.moresettings.speed": [
"MinifyCard",
"DevelopmentModeCard",
"BrowserCacheTTLCard"
]
},
"locale": "en",
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, lets put it in the README instead of the sample. I don't want the sample merging duplicate keys every time if we can avoid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only ones they should care about are debug
, locale
, and featureManagerIsFullZoneProvisioningEnabled
though. We don't want them overwriting the cards but we don't necessarily care if they do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If debug
, locale
and featureManagerIsFullZoneProvisioningEnabled
will be configurable I think we should add all of them in the sample. It provides an ease of mind to the user when it's already there with default settings.
Additionally, we can make the README more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only add those three to the sample we don't need to make the README more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manatarms sorry to make you change again. Could you only add those 3 settings in the sample.
Thanks
src/Cpanel/PluginActions.php
Outdated
), | ||
'locale' => 'en', | ||
'integrationName' => 'cpanel', | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want all of the fields to be configurable. I think the below fields should not be configurable by the config.json
file.
'isDNSPageEnabled' => true,
'useHostAPILogin' => true,
'integrationName' => 'cpanel',
@jwineman I just wrote the settings I think which shouldn't be configurable. I only have strong opinions on integrationName
and useHostAPILogin
. isDNSPageEnabled
could be configurable...
src/Cpanel/PluginActions.php
Outdated
} else { | ||
$this->userConfig = []; | ||
//If we did find a config decode it | ||
if ($userConfigContent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't comment what is obvious like
//The width of the line is 2
lineWidth = 2;
Write comments explaining "why" rather than "what" and only write it when it's needed. The "what" should be understandable by reading the code itself
@thellimist @jwineman Made all the changes. Let me know if it's good to merge. |
src/Cpanel/PluginActions.php
Outdated
@@ -16,33 +16,39 @@ class PluginActions extends AbstractPluginActions | |||
protected $userConfig; | |||
protected $composer; | |||
|
|||
public static $CONFIG = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].
from http://php.net/manual/en/language.types.array.php
In WordPress we support PHP 5.3.10. We need to use array()
rather than []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized this is CPanel 😄. What is the CPanel min PHP version we support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized this wasn't the backend. cPanel is pinned to 5.6, we can use short array syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!
Make sure we include the changes from #149 here. |
e85752e
to
565de4e
Compare
Okay this seems good to go! Let me know if you'll are cool with the merge. |
Updated cloudflare-plugin-backend to 2.2.0
Implemented getConfig and updated related files
Some formatting thing
Added sample json