'Class does not exist' error on upgrading add-on

Permalink
Hi,
I am trying to add a custom block type into my package. But whenever I am trying to upgrade the package I got an 'class does not exist' error message like in attachment. This message is not so helpful because I cannot know where to check. I need help about how to proceed? Is there a log file showing which class it complains about? Or, how can one debug this?

Thanks in advance.

1 Attachment

 
hutman replied on at Permalink Reply
hutman
When I get this 99% of the time it's an incorrect namespace in the Block Controller
muratyil replied on at Permalink Reply
Well I might be in 1% area :) My problem was that $this->pkg using in a custom function configureBlocks() which is called in install() and upgrade() functions in package controller does not return the package. Since there was multiple packages installed $this->pkg returns an Array of all package handlers. Thats why, it couldnt install all the blocks, since it does not know which package to look. So, i have included $pkg = $this->app->make('Concrete\Core\Package\PackageService')->getByHandle('my_package_handler'); in the first line of the configureBlocks() function and replaced all $this->pkg with $pkg and I could solved it.

private function configureBlocks()
    {
        $blockTypeSet = BlockTypeSet::getByHandle('my_package_handler', $this->pkg);
        if (!is_object($blockTypeSet)) {
            BlockTypeSet::add("my_package_handler", "My Package", $this->pkg);
        }
        $blockTypes = [
            'header_slider',
            'new_block',
        ];
        foreach ($blockTypes as $btHandle) {
            $bt = BlockType::getByHandle($btHandle);
            if (!is_object($bt)) {
                $bt = BlockType::installBlockType($btHandle, $pkg);
            }


Final version:
private function configureBlocks()
    {
$pkg = $this->app->make('Concrete\Core\Package\PackageService')->getByHandle('my_package_handler');
        $blockTypeSet = BlockTypeSet::getByHandle('my_package_handler', $pkg);
        if (!is_object($blockTypeSet)) {
            BlockTypeSet::add("my_package_handler", "My Package", $pkg);
        }
        $blockTypes = [
            'header_slider',
            'new_block',
        ];
        foreach ($blockTypes as $btHandle) {
            $bt = BlockType::getByHandle($btHandle);
            if (!is_object($bt)) {
                $bt = BlockType::installBlockType($btHandle, $pkg);