Skip to content

Commit

Permalink
refactor(property config): rename method back
Browse files Browse the repository at this point in the history
Do not release `addConstructorCreationBehavior` with
a constructor behavior as parameter. There should
be a single `addCreationBehavior` taking a behavior
factory that may (or may not) execute the constructor
behavior as well as the post-constructor behavior.

`addConstructorBehavior` will be kept for backward
compatibility for now.

Refs: #115
  • Loading branch information
dresslerdemos committed Apr 18, 2024
1 parent f48bc5a commit 468327f
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* refactor: (bc break) adjust constructor of `DynamicTransformer` to take some specific values instead of a whole `TransferableTypeInterface` instance
* refactor: (bc break) require the implementation of five other methods instead of `getResourceConfig` in children of `AbstractResourceType`
* refactor: (bc break) replace `RequiredRelationshipConstructorBehavior` constructor boolean parameter with `Cardinality` enum
* refactor: (bc break) remove `*ConstructorBehaviorFactory*` classes, you can use added static `createFactory` methods in the corresponding `*Behavior` classes instead.
* refactor: (bc break) remove `addConstructorBehavior`, use `addConstructorCreationBehavior` instead
* refactor: (bc break) remove `*ConstructorBehaviorFactory` classes, you can use added static `createFactory` methods in the corresponding `*Behavior` classes instead.
* refactor: (bc break) adjust `*SetBehavior` and `*SetBehaviorFactory` class constructors to take the `OptionalField` enum instead of `bool`
* refactor: (bc break) adjust `*Readability` class constructors to take `DefaultField` instead of `bool`
* refactor: (bc break) remove `ReadablePropertyConfigBuilderInterface`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
*/
public static function createFactory(callable $behavior): RelationshipConstructorBehaviorFactoryInterface
{
return new class($behavior) implements RelationshipConstructorBehaviorFactoryInterface {
return new class ($behavior) implements RelationshipConstructorBehaviorFactoryInterface {
/**
* @param callable(CreationDataInterface): array{mixed, list<non-empty-string>} $callback
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function addUpdateBehavior(object $behaviorFactory): self
return $this;
}

public function addPostConstructorBehavior($behaviorFactory): self
public function addPostConstructorBehavior(object $behaviorFactory): self
{
return $this->addCreationBehavior($behaviorFactory);
}
Expand All @@ -112,7 +112,7 @@ public function addCreationBehavior(object $behaviorFactory): self
return $this;
}

public function addConstructorCreationBehavior($behaviorFactory): self
public function addConstructorBehavior(object $behaviorFactory): self
{
$this->constructorBehaviorFactories[] = $behaviorFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function initializable(
?string $customConstructorArgumentName = null
): self {
if ($constructorArgument) {
$this->addConstructorCreationBehavior(
$this->addConstructorBehavior(
AttributeConstructorBehavior::createFactory($customConstructorArgumentName, OptionalField::NO, null)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function updatable(array $entityConditions = [], callable $updateCallback
*
* @return $this
*
* @deprecated use {@link addConstructorCreationBehavior}, {@link addCreationBehavior} or {@link addPathCreationBehavior} instead
* @deprecated use {@link addConstructorBehavior}, {@link addCreationBehavior} or {@link addPathCreationBehavior} instead
*/
public function initializable(
bool $optionalAfterConstructor = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function addPathUpdateBehavior(array $entityConditions = []): self;
*
* @return $this
*/
public function addConstructorCreationBehavior($behaviorFactory): self;
public function addConstructorBehavior(object $behaviorFactory): self;

/**
* @param TPostConstructorBehaviorFactory $behaviorFactory
Expand Down Expand Up @@ -105,5 +105,5 @@ public function removeAllCreationBehaviors(): self;
*
* @deprecated use {@link addCreationBehavior} instead
*/
public function addPostConstructorBehavior($behaviorFactory): self;
public function addPostConstructorBehavior(object $behaviorFactory): self;
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ public function build(): IdentifierConfigInterface
public function initializable(bool $optionalAfterConstructor = false, bool $constructorArgument = false, ?string $customConstructorArgumentName = null): IdentifierConfigBuilderInterface
{
if ($constructorArgument) {
$this->addConstructorCreationBehavior(
$this->addConstructorBehavior(
DataProvidedIdentifierConstructorBehavior::createFactory($customConstructorArgumentName, OptionalField::NO, null)
);
}

return $this->addPathCreationBehavior(OptionalField::fromBoolean($optionalAfterConstructor));
}

public function addConstructorCreationBehavior(IdentifierConstructorBehaviorFactoryInterface $behaviorFactory): self
public function addConstructorBehavior(IdentifierConstructorBehaviorFactoryInterface $behaviorFactory): self
{
$this->constructorBehaviorFactories[] = $behaviorFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function readable(callable $customReadCallback = null): self;
/**
* @return $this
*/
public function addConstructorCreationBehavior(IdentifierConstructorBehaviorFactoryInterface $behaviorFactory): self;
public function addConstructorBehavior(IdentifierConstructorBehaviorFactoryInterface $behaviorFactory): self;

/**
* @param IdentifierPostConstructorBehaviorFactoryInterface<TEntity> $behaviorFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function initializable(
array $relationshipConditions = []
): self {
if ($constructorArgument) {
$this->addConstructorCreationBehavior(
$this->addConstructorBehavior(
ToManyRelationshipConstructorBehavior::createFactory(
$customConstructorArgumentName,
$relationshipConditions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function initializable(
array $relationshipConditions = []
): self {
if ($constructorArgument) {
$this->addConstructorCreationBehavior(
$this->addConstructorBehavior(
ToOneRelationshipConstructorBehavior::createFactory(
$customConstructorArgumentName,
$relationshipConditions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function addUpdateBehavior(PropertyUpdatabilityInterface $updateBehavior)
return $this;
}

public function addConstructorCreationBehavior(ConstructorBehaviorInterface $behavior): ResourceConfigBuilderInterface
public function addConstructorBehavior(ConstructorBehaviorInterface $behavior): ResourceConfigBuilderInterface
{
$this->generalConstructorBehavior[] = $behavior;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function setToManyRelationshipConfigBuilder(string $propertyName, ToManyR
/**
* @return $this
*/
public function addConstructorCreationBehavior(ConstructorBehaviorInterface $behavior): self;
public function addConstructorBehavior(ConstructorBehaviorInterface $behavior): self;

/**
* @param PropertySetBehaviorInterface<TEntity> $behavior
Expand Down

0 comments on commit 468327f

Please sign in to comment.