-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
97 lines (77 loc) · 3.42 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
namespace Concrete\Package\CommunityStoreFileUploads;
use Concrete\Core\Attribute\Key\Category;
use Concrete\Core\Attribute\Type as AttributeType;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Block\BlockType\Set as BlockTypeSet;
use Concrete\Core\Package\Package;
use Concrete\Core\Page\Page;
use Concrete\Core\Page\Single as SinglePage;
use Concrete\Core\Support\Facade\Route;
use Concrete\Package\CommunityStore\Entity\Attribute\Key\StoreProductKey;
use Whoops\Exception\ErrorException;
use Concrete\Core\Package\PackageService;
use Concrete\Core\Support\Facade\Application as ApplicationFacade;
class Controller extends Package
{
protected $pkgHandle = 'community_store_file_uploads';
protected $appVersionRequired = '8.4';
protected $pkgVersion = '1.1.2';
protected $packageDependencies = ['community_store'=>'2.0'];
protected $pkgAutoloaderRegistries = [
'src/CommunityStore' => '\Concrete\Package\CommunityStoreFileUploads\Src\CommunityStore',
];
public function getPackageDescription()
{
return t("Community Store File Uploads");
}
public function getPackageName()
{
return t("Community Store File Uploads");
}
public function install()
{
$pkg = parent::install();
$orderCategory = Category::getByHandle('store_order');
$orderCategory->associateAttributeKeyType(AttributeType::getByHandle('image_file'));
$blockType = BlockType::getByHandle('community_store_file_upload');
if (!is_object($blockType)) {
BlockType::installBlockType('community_store_file_upload', $pkg);
}
$this->installAttributes($pkg);
}
public function upgrade()
{
parent::upgrade();
$pkg = $this->app->make('Concrete\Core\Package\PackageService')->getByHandle('community_store_file_uploads');
$this->installAttributes($pkg);
}
private function installAttributes($pkg) {
$app = ApplicationFacade::getFacadeApplication();
$boolean = AttributeType::getByHandle('boolean');
$text = AttributeType::getByHandle('text');
$number = AttributeType::getByHandle('number');
$productCatgegory = $app->make('Concrete\Package\CommunityStore\Attribute\Category\ProductCategory');
$attr = $productCatgegory->getAttributeKeyByHandle('file_upload');
if (!is_object($attr)) {
$key = new StoreProductKey();
$key->setAttributeKeyHandle('file_upload');
$key->setAttributeKeyName(t('File Upload'));
$key = $productCatgegory->add($boolean, $key, null, $pkg);
}
$attr = $productCatgegory->getAttributeKeyByHandle('file_upload');
if (!is_object($attr)) {
$key = new StoreProductKey();
$key->setAttributeKeyHandle('file_upload_label');
$key->setAttributeKeyName(t('File Upload Label'));
$key = $productCatgegory->add($text, $key, null, $pkg);
}
$attr = $productCatgegory->getAttributeKeyByHandle('file_upload_number_uploads');
if (!is_object($attr)) {
$key = new StoreProductKey();
$key->setAttributeKeyHandle('file_upload_number_uploads');
$key->setAttributeKeyName(t('Number Of Uploads Per Item'));
$key = $productCatgegory->add($number, $key, null, $pkg);
}
}
}