Allow scoped and local extensions on core controllers.#908
Allow scoped and local extensions on core controllers.#908LukeTowers merged 4 commits intodevelopfrom
Conversation
|
the |
|
Traits can't have magic methods AFAIK which is why they aren't there already. |
|
Is this taking into account the existing __call & __callStatic methods on these classes / their parents? |
It is in ExtendableTrait's |
|
@mjauvin I mean this PR is going to overwrite the existing base class' __call() and __callStatic() methods, we need to make sure the behavior remains the same. |
|
@LukeTowers I adjusted CmsController & BackendController's What should we do for the the public static function __callStatic($name, $params)
{
if ($name === 'extend') {
if (empty($params[0])) {
throw new \InvalidArgumentException('The extend() method requires a callback parameter or closure.');
}
self::extendableExtendCallback($params[0], $params[1] ?? false, $params[2] ?? null);
return;
}
throw new BadMethodCallException(sprintf(
'Method %s::%s does not exist.', static::class, $method
));
} |
|
Looking into this again, and the behavior is not changed without calling the parent's What do you think @bennothommo ? |
|
The base class for CmsController & BackendController is Illuminate\Routing\Controller which has no special handling other than returning BadMethodCallException(). So behavior will not change. |
bennothommo
left a comment
There was a problem hiding this comment.
As far as I can tell, this should be OK. I had to do the same thing for the database models.
|
Does it still throw the exact same BadMethodCall Exception if the resolution fails? |
Depends which class and whether it's static or not... Backend\Classes\Controller throws the exact same exception. Backend\Classes\BackendController & Cms\Classes\CmsController used to throw a php Error exception since they didn't have any |
Complement wintercms/storm#134