AmphiBee / AmphiBee/MetaboxMaker

Extend addField handling in FieldTransformer to support non-field instances like Heading and Divider

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

In the src/Transformer/FieldTransformer.php file, the current implementation only checks for instances of Field to process through the addField method. This implementation is restrictive as there are other types of objects that need processing, such as Heading and Divider, which are not strictly fields but still require similar handling.

Issue

The code snippet:

if ($subField instanceof Field) {
    $this->addField($subField);
}

This condition only allows objects of type Field to be processed. However, instances of Heading or Divider are also valid inputs that need to be added but are currently being excluded.

Suggested Fix

We propose extending the condition to include Heading and Divider types. This can be implemented by modifying the existing conditional check to include these types, or by implementing a new interface that these classes can inherit, representing all types that are valid for addField.

A possible modification might look like this:

if ($subField instanceof Field || $subField instanceof Heading || $subField instanceof Divider) {
    $this->addField($subField);
}

Alternatively, defining a new interface like FieldCompatible could make the system more flexible and maintainable:

interface FieldCompatible {}

class Field implements FieldCompatible {}
class Heading implements FieldCompatible {}
class Divider implements FieldCompatible {}

if ($subField instanceof FieldCompatible) {
    $this->addField($subField);
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Transformer/FieldTransformer.php and inspect the addField call guarded by the Field instance check, then review how Heading and Divider are defined and used. Done means valid Heading and Divider instances are accepted and processed through addField without excluding existing Field inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.