Skip to content

Commit

Permalink
feat(admin): Improve structure property metadata filtering
Browse files Browse the repository at this point in the history
Changed `StructureFormGroup::formProperties()` to filter property metadata by structure model (new feature) and parent model (existing feature).

BREAKING: The parent model property now receives both its structure/storage property and the structure's sub-property as a dot-delimited key path: `<storageProperty>.<childProperty>`. This fixes the risk of conflicting property identifiers where a structure's child property inherits the parent model's property mutations and fixes the missing context for the structure's property.
  • Loading branch information
mcaskill committed Mar 11, 2024
1 parent aa465e7 commit 8eb96cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,18 @@ public function formProperties()
$propertyMetadata['ident'] = $propertyIdent;
}

if (method_exists($entry, 'filterPropertyMetadata')) {
$propertyMetadata = $entry->filterPropertyMetadata(
$propertyMetadata,
$propertyIdent
);
}

if (method_exists($obj, 'filterPropertyMetadata')) {
$propertyMetadata = $obj->filterPropertyMetadata($propertyMetadata, $propertyIdent);
$propertyMetadata = $obj->filterPropertyMetadata(
$propertyMetadata,
$store->ident() . '.' . $propertyIdent
);
}

if (is_bool($propertyMetadata) && $propertyMetadata === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Charcoal\Property;

use PDO;
use ArrayAccess;
use RuntimeException;
use InvalidArgumentException;
Expand All @@ -13,7 +12,6 @@
use Charcoal\Model\DescribableInterface;
use Charcoal\Model\MetadataInterface;
use Charcoal\Model\ModelInterface;
use Charcoal\Model\Model;
use Charcoal\Validator\ValidatableInterface;
// From 'charcoal-factory'
use Charcoal\Factory\FactoryInterface;
Expand Down

0 comments on commit 8eb96cb

Please sign in to comment.