Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce getIsEditable for all element types #4116

Open
timkelty opened this Issue Apr 9, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@timkelty
Copy link
Contributor

timkelty commented Apr 9, 2019

Despite their generic names, it seems that ElementHelper::editableSiteIdsForElement and craft\base\Element::getIsEditable are really only concerned with the double-click for HUD edit functionality.

Not knowing this, I ran into trouble when I tried to use it on an element such as MatrixBlock, which despite logically being "editable", MatrixBlock::getIsEditable is false.

To get around this, I had to make a special case for different element types: https://github.com/timkelty/craftcms-site-sync/blob/master/src/models/Syncable.php#L210-L221

What would be ideal is if ElementHelper::editableSiteIdsForElement worked on any element type, letting you know which sites the user had permissions to edit the given element.

For this to work with third party plugins, etc. – it would probably make sense to require elements to implement a getIsEditable.

MatrixBlock might then have something like this:

    public function getIsEditable(): bool
    {
        return $this->owner->getIsEditable();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.