Page MenuHomeMnkras Phabricator

S3 controller.php
ActivePublic

Authored by Mnkras on Apr 22 2015, 11:02 PM.
<?php
namespace Concrete\Package\S3Storage;
defined('C5_EXECUTE') or die("Access Denied.");
use \Concrete\Core\File\StorageLocation\Type\Type;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
/**
*
* @author Michael Krasnow <mnkras@gmail.com>
*
*/
class Controller extends \Package
{
protected $pkgHandle = 's3_storage';
protected $appVersionRequired = '5.7.3';
protected $pkgVersion = '2.0';
public function getPackageDescription()
{
return t("File storage using Amazon S3.");
}
public function getPackageName()
{
return t("S3 Storage");
}
public function install()
{
$pkg = parent::install();
Type::add('s3', 'Amazon S3', $pkg);
}
/**
* @throws \Illuminate\Filesystem\FileNotFoundException
*/
public function on_start()
{
$fs = new Filesystem;
try {
$fs->getRequire(__DIR__ . '/vendor/autoload.php');
} catch (\Illuminate\Filesystem\FileNotFoundException $e) {
throw new \Exception(t('You forgot to run composer :/'));
}
$loader = new Psr4ClassLoader();
$loader->addPrefix('\\S3Storage', __DIR__ . '/src/S3Storage/');
//This is to account for c5 changing autoloading in 5.7.4 >.< (Korvin's fault)
$loader->addPrefix(
'\\Concrete\\Package\\S3Storage\\Core\\File\\StorageLocation\\Configuration',
__DIR__ . '/src/S3Storage/'
);
$loader->register();
//This is also needed because c5 won't autoload the class anymore
\Core::bind(
'\Concrete\Package\S3Storage\Core\File\StorageLocation\Configuration\S3Configuration',
'S3Storage\S3Configuration'
);
}
}

Event Timeline

Mnkras edited the content of this paste. (Show Details)Apr 22 2015, 11:02 PM
Mnkras changed the title of this paste from untitled to S3 controller.php.
Mnkras updated the paste's language from autodetect to autodetect.
Mnkras changed the visibility from "All Users" to "Public (No Login Required)".
Mnkras added a project: concrete5.