How to get composer label from block controller

Permalink
If a block is displayed in composer view, you can display the composer label for that block with simply $label.

But I need to grab the label from my blocks controller, how can I do that?

ob7dev
 
Gondwana replied on at Permalink Reply
Gondwana
Dunno, but...

In some contexts, $controller is defined. Or, if you can get the block's blockType, you could then use $block_type->getController().

Once you've got a reference to the controller, you can then call its methods.
ob7dev replied on at Permalink Reply
ob7dev
Hmm... well I got sort of close but ended up ditching the idea. I wanted to get the Label being used by composer view so that when there is multiple occurrences of my block in composer view, and something does not validate, it will let you know which one of the blocks it was, and I was going to use the composer view label to determine that.

The label isn't something set by the block. It's set in the dashboard whenever you add it to a page types form. I tried referencing things like composer->label to no avail. I found the method I believe composer uses itself to get the label:
public function getPageTypeComposerControlLabel()
    {
        if ($this->getPageTypeComposerFormLayoutSetControlCustomLabel()) {
            return $this->getPageTypeComposerFormLayoutSetControlCustomLabel();
        } else {
            $control = $this->getPageTypeComposerControlObject();
            return $control->getPageTypeComposerControlName();
        }
    }

but it doesn't seem to return a string, or whatever it returns can't be echoed out like a string. The above code is from FormLayoutSetControl.php
Gondwana replied on at Permalink Reply
Gondwana
Oh sorry; I didn't think it through closely enough. I automatically assumed you meant the block type name.

There's a remote possibility that the ControlLabel returns some sort of HTML, rather than anything correlated with the field you're calling Label. That wouldn't help you.

Glad you got it sorted out.
ob7dev replied on at Permalink Reply
ob7dev
Yea that was just a guess. Do you know of any type of tool that can trace variables to their origin? I'm not even sure where composer.php gets label from, but its a built in variable available in any composer.php file.

I starting tinkering around with PHPStorm... seems really powerful. What do you use for editing?
Gondwana replied on at Permalink Reply
Gondwana
I'm a bit retro. I'm now using Visual Studio Code:
http://code.visualstudio.com/

It has an extension that provides in-editor debugging of php code (as well as other languages), and I've got that working with c5. However, I haven't used it extensively.

It's all free.

I'm sure that phpStorm would be a better environment; alas, it wouldn't be a cost-beneficial investment in my circumstances.
ob7dev replied on at Permalink Reply
ob7dev
I'm still on the trial version, was just checking it out. Nothing can really pull me away from my ultimate coding set up: SPACEMACS!!!