How to Package up themes?

Permalink
I have the code below in my Package Controller:

public function install() {
      $pkg = parent::install();
        $this->configure($pkg);
   }
    public function configure($pkg = null) { 
   // install theme
        $this->installTheme($pkg);
        // more installations here..
    }
    private function installTheme($pkg = null) {
        foreach($this->themes as $theme) {
            $themeHandle = PageTheme::getByHandle($theme);
            if (!$themeHandle){
                PageTheme::add($themeHandle, $pkg);
            }


But when I try to install my package it returns a MySQL error:
mysql error: [1048: Column 'ptHandle' cannot be null] in EXECUTE("insert into PageThemes (ptHandle, ptName, ptDescription, pkgID) values (NULL, '(No Name)', '(No Description)', '18')")


What could be wrong in the above code?

I've also looked athttp://www.concrete5.org/documentation/how-tos/designers/packaging-... and my code should work based on it.

BreakfastStudio
 
12345j replied on at Permalink Best Answer Reply
12345j
assuming $this->themes is a valid array of handles...
you're mistake is that $themeHandle isn't a handle, its an object. so you check if it exists, all good, but when you install you want it to be PageTheme::add($theme,$pkg);
so that you load the handle. make sense?
BreakfastStudio replied on at Permalink Reply
BreakfastStudio
I was about to find the answer! But, really, thanks! It saved me time there. I don't remember where exactly I caught this
$themeHandle = PageTheme::getByHandle($theme);

I'm pretty sure it's from a theme I've looked at.

Again, thank you!