Reliable Package Install and Upgrades

Permalink
So I checked out this how-to: http://www.concrete5.org/documentation/how-tos/developers/reliable-...

I've added this to my controller.php to install attributes:

public function configureAttributes($pkg) {
      Loader::model('attribute/categories/collection');
      $eaku = AttributeKeyCategory::getByHandle('collection');
      $eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
      $eventpostSet = $eaku->addSet('event_post',t('News and Events'),$pkg);
      $bool = AttributeType::getByHandle('boolean'); //checkbox
      $dt = AttributeType::getByHandle('date_time'); //date picker
      $txt = AttributeType::getByHandle('text'); //text box
      $collection_attributes = array(
          array('akHandle' => 'is_featured',
                  'akName' => 'Featured Post',
                  'akType' => $bool),
          array('akHandle' => 'date_range',
                  'akName' => 'Multile Date Event',
                  'akType' => $bool),


Having done that, I'm getting this error:
Catchable fatal error: Object of class AttributeType could not be converted to string in /Users/justrjlewis/RJLewisDesign/Sites/zphiboklahoma.org/concrete/libraries/3rdparty/adodb/adodb.inc.php on line 1015


Any ideas as to why?

justrj
 
justrj replied on at Permalink Best Answer Reply
justrj
Answered my own question!

First off I was assigning the Collection Attribute Key twice. My variables should have been:
$bool = 'boolean';

instead of
$bool = CollectionAttributeKey::getByHandle('boolean');


Secondly, I modified the private function from the how-to so that the collection that I created is assigned to the new attributes, which required passing an additional variable in.

public function configureAttributes($pkg) {
...
$eventpostSet = $eaku->addSet('event_post',t('News and Events'),$pkg);
...
}

private function addNewAttribute($attributeSet,$collection_attributes,$newAttribute,$pkg) {
        $newAttributeHandle = CollectionAttributeKey::getByHandle($newAttribute['akHandle']);
        if(!is_object($newAttributeHandle)) {
          $attributeType = AttributeType::getByHandle($newAttribute['akType']);
          $newAttributeHandle = CollectionAttributeKey::add($attributeType,$newAttribute,$pkg)->setAttributeSet($attributeSet);
        }
        return $newAttributeHandle;
    }