-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow ChildAdmin for Unidirectional References #7893
Conversation
1e4ffce
to
ab5fd74
Compare
Static analysis tool are telling me that I'm calling
So either we ignore the error, either we consider the BC break in the interface. Also, best would be to add a functional test |
IMHO, this patch should include:
|
src/Admin/AbstractAdmin.php
Outdated
@@ -1302,7 +1302,7 @@ final public function getChild(string $code): AdminInterface | |||
return $this->getChildren()[$code]; | |||
} | |||
|
|||
final public function setParent(AdminInterface $parent, string $parentAssociationMapping): void | |||
final public function setParent(AdminInterface $parent, ?string $parentAssociationMapping): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we avoid call parent?
Something like
if $parent !== null $child->setParent()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set parent is doing
final public function setParent(AdminInterface $parent, ?string $parentAssociationMapping): void
{
$this->parent = $parent;
$this->parentAssociationMapping[$parent->getCode()] = $parentAssociationMapping;
}
So, we still need to
- set the parent
- fill the parentAssociationMapping because later we acces it with
final public function getParentAssociationMapping(): ?string
{
if (!$this->isChild()) {
throw new \LogicException(sprintf(
'Admin "%s" has no parent.',
static::class
));
}
$parent = $this->getParent()->getCode();
return $this->parentAssociationMapping[$parent];
}
which already accepts to return null.
Done
I don't think a lot of doc are needed, I added one line
Not possible IMHO. And technically you can decide to not pass a field even if it exists, for some reason... The only issue I have now is the psalm/phpstan errors and if we should do a BC-break or not for this "fix". |
I ignored the static analysis errors to avoid the bc break. But I'm pretty sure nobody are implementing the interface without extending the abstractAdmin ^^ |
Subject
Closes #7857.
Changing the typehint in the AbstractAdmin is BC.
But for the interface we'll have to wait next major (or should we consider the BC-break now @jordisala1991 ?)
Changelog