jordanlev / c5_package_installer_utils Goto Github PK
View Code? Open in Web Editor NEWA bunch of utility functions which encapsulate common installation tasks in package controllers.
A bunch of utility functions which encapsulate common installation tasks in package controllers.
Hi Jordan...stellar work as always! Wish this had been around a few weeks ago when I was putting together my first package for the Marketplace-proper and trying to get my head around one or two of the more arcane things you can achieve with package installation!
Anyway, whilst I forked this repository and had a stab at making a couple of additions, my PHP prowess sort of failed me...figured it might be best to just describe a couple of cool little additions that you can probably figure out how to add into this class in your sleep!
In my Maximizer package I use the installer to create a new attribute set (a nifty, underrated new 5.5 feature) called 'Dashboard' and add my new 'maximize' select-type attribute to it. Involved a fair bit of trial and error and hitting the Concrete forums to achieve it so, if you think it would be a nice addition here and if my working code might help you, here it is! The key bits are obviously 'addSet' and 'setAttributeSet', and I don't think your installer utils currently have any methods that cover them and their use during package installation in any way.
I know...very selfish of me to push this forward, but I would certainly find it useful and so might yourself and others going forward as Attribute Sets start to become a little more widely-known and employed. Cheers!
private function installPkgAttributes($pkg) {
// Install 'maximize' attribute (if doesn't already exist)
Loader::model('collection_types');
Loader::model('collection_attributes');
Loader::model('attribute/categories/collection');
// Create an attribute set - called 'Dashboard' - to help avoid confusion with adding to pages. This attribute will obviously only do anything when assigned to dashboard pages
// Check if attribute set already exists...if not, create it!
$attrSet = AttributeSet::getByHandle('dashboard');
if(!is_object($attrSet)){
$eaku = AttributeKeyCategory::getByHandle('collection');
$eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
$attrSet = $eaku->addSet('dashboard', t('Dashboard'), $pkg);
}
// Check if attribute already exists...if not, create it!
$maximizeAttribute=CollectionAttributeKey::getByHandle('maximize');
$atType = AttributeType::getByHandle('select');
if(!$maximizeAttribute || !intval($maximizeAttribute->getAttributeKeyID())){
$maximizeAttribute = CollectionAttributeKey::add($atType,
array('akHandle' => 'maximize',
'akName' => t('Maximize (Dashboard)'),
'akIsSearchable' => true,
'akIsSearchableIndexed' => false,
'akSelectAllowMultipleValues' => false,
'akSelectAllowOtherValues' => false,
'akSelectOptionDisplayOrder' => 'alpha_desc'
),$pkg);
}
// Select options to add -- yes (activated for page), no (specifically NOT activated for page).
$maximizeAttrOpts = array('Yes','No');
foreach($maximizeAttrOpts as $maximizeAttrOpt){
// Check for attribute option - if doesn't exist, create it!
if(!SelectAttributeTypeOption::getByValue($maximizeAttrOpt,$maximizeAttribute)){
$maxAttr = SelectAttributeTypeOption::add( $maximizeAttribute, $maximizeAttrOpt, 0);
}
}
// Finally, add new attribute to new set.
$maxAttrInSet = CollectionAttributeKey::getByHandle('maximize')->setAttributeSet($attrSet);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.