Arkade_S3_Shell_Config::run PHP Method

run() public method

public run ( )
    public function run()
    {
        if (empty($this->getArg('list'))) {
            $updatedCredentials = false;
            if (!empty($this->getArg('access-key-id'))) {
                Mage::getConfig()->saveConfig('arkade_s3/general/access_key', $this->getArg('access-key-id'));
                $updatedCredentials = true;
            }
            if (!empty($this->getArg('secret-key'))) {
                Mage::getConfig()->saveConfig('arkade_s3/general/secret_key', $this->getArg('secret-key'));
                $updatedCredentials = true;
            }
            if (!empty($this->getArg('bucket'))) {
                Mage::getConfig()->saveConfig('arkade_s3/general/bucket', $this->getArg('bucket'));
                $updatedCredentials = true;
            }
            if (!empty($this->getArg('region'))) {
                Mage::getConfig()->saveConfig('arkade_s3/general/region', $this->getArg('region'));
                $updatedCredentials = true;
            }
            if ($updatedCredentials) {
                echo "You have successfully updated your S3 credentials.\n";
                // Refresh the config cache
                Mage::app()->getConfig()->reinit();
            } else {
                echo $this->usageHelp();
            }
        } else {
            /** @var Arkade_S3_Helper_Data $helper */
            $helper = Mage::helper('arkade_s3');
            echo 'Here are your AWS credentials.';
            if ($this->getArg('access-key-id') || $this->getArg('secret-key') || $this->getArg('bucket') || $this->getArg('region')) {
                echo " No configuration setting was updated.";
            }
            echo "\n\n";
            echo sprintf("Access Key ID:     %s\n", $helper->getAccessKey());
            echo sprintf("Secret Access Key: %s\n", $helper->getSecretKey());
            echo sprintf("Bucket:            %s\n", $helper->getBucket());
            echo sprintf("Region:            %s\n", $helper->getRegion());
        }
        return $this;
    }

Usage Example

Example #1
0
        access key ID that you have just generated.

    --bucket <bucket>
        You must provide a valid S3 bucket name that you want media files to be
        uploaded to.

    --region <region>
        You must provide a valid S3 region. As 2016-03-17, S3 has the following
        regions:

        us-east-1
        us-west-1
        us-west-2
        eu-west-1
        eu-central-1
        ap-southeast-1
        ap-southeast-2
        ap-northeast-1
        ap-northeast-2
        sa-east-1

        You can review all valid S3 regions via the AWS documentation
        (http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region).


USAGE;
    }
}
$shell = new Arkade_S3_Shell_Config();
$shell->run();
Arkade_S3_Shell_Config