Skip to content

Conversation

@lucatume
Copy link
Contributor

While the Asset::add_to_group_path() method should be used while the
Asset is being registered, nothing currently prevents (e.g. an
exception) the method from being called on the Asset object after
registration.

Since the path resolution in the get_root_path method is done
lazily, when the method is called, the fact the Asset has been added to
a specific group path should matter.

This updates the code to support correctly, in my opinion, calls to the
Asset::add_to_group_path method after the object registration and take
the group path into account when resolving the root path.

See the test in this PR to have a better understanding.

@lucatume lucatume self-assigned this Dec 16, 2024
While the `Asset::add_to_group_path()` method _should_ be used while the
Asset is being registered, nothing currently prevents (e.g. an
exception) the method from being called on the `Asset` object after
registration.

Since the path resolution in the `get_root_path` method is done
lazily, when the method is called, the fact the Asset has been added to
a specific group path should matter.

This updates the code to support correctly, in my opinion, calls to the
`Asset::add_to_group_path` method after the object registration and take
the group path into account when resolving the root path.

See the test in this PR to have a better understanding.
@lucatume lucatume force-pushed the feat/add-to-group-path branch from 959ec5b to c97cd03 Compare December 16, 2024 12:38
@lucatume lucatume marked this pull request as ready for review December 16, 2024 12:40
@lucatume lucatume requested review from borkweb and dpanta94 December 16, 2024 12:41
Copy link
Member

@dpanta94 dpanta94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good - I would only ask to also update docs to reflect this change.

The places i have in mind is:

  1. Docblock of protected string $group_path_name property
  2. readme.md file related to group path feature.

@lucatume lucatume marked this pull request as draft December 16, 2024 13:16
Replace uses of `file_exists` with `is_file`. While there is
functionally no difference between the two in this context, the
`is_file` function will use a cached check for a small performance
boost.
@lucatume lucatume marked this pull request as ready for review December 16, 2024 13:28
@lucatume lucatume requested a review from dpanta94 December 16, 2024 13:28
@lucatume lucatume merged commit b0432d1 into main Dec 17, 2024
3 checks passed
@lucatume lucatume deleted the feat/add-to-group-path branch December 17, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants