Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Sachin/pi 1200 #150

Merged
merged 9 commits into from
Jul 14, 2017
Merged

Sachin/pi 1200 #150

merged 9 commits into from
Jul 14, 2017

Conversation

manatarms
Copy link
Contributor

Updated cloudflare-plugin-backend to 2.2.0
 Implemented getConfig and updated related files
 Some formatting thing
 Added sample json

'featureManagerIsFullZoneProvisioningEnabled' => true,
'isDNSPageEnabled' => true,
'useHostAPILogin' => true,
'homePageCards' => array(
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Copy link
Contributor

@jwineman jwineman left a 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.

$this->getComposerJson();

//Clone the config to manipulate
$config = array_merge(array(), self::$CONFIG);
Copy link
Contributor

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.

Copy link
Contributor

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()

Copy link
Contributor

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.

$this->userConfig = [];
} else {
$this->userConfig = json_decode($userConfigContent, true);
}
Copy link
Contributor

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']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue can be used

@@ -0,0 +1,3 @@
{
"featureManagerIsFullZoneProvisioningEnabled": false
}
Copy link
Contributor

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",
}

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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

),
'locale' => 'en',
'integrationName' => 'cpanel',
);
Copy link
Contributor

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...

} else {
$this->userConfig = [];
//If we did find a config decode it
if ($userConfigContent) {
Copy link
Contributor

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

@manatarms
Copy link
Contributor Author

@thellimist @jwineman Made all the changes. Let me know if it's good to merge.

@@ -16,33 +16,39 @@ class PluginActions extends AbstractPluginActions
protected $userConfig;
protected $composer;

public static $CONFIG = array(
Copy link
Contributor

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 []

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

@jwineman
Copy link
Contributor

Make sure we include the changes from #149 here.

@manatarms
Copy link
Contributor Author

Okay this seems good to go! Let me know if you'll are cool with the merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants