Franz Okay, i'll give you an example.
I'm trying to find out what calls the ability to rename a post.
First hit..
src/Discussion/DiscussionPolicy.php
public function rename(User $actor, Discussion $discussion)
{
if ($discussion->user_id == $actor->id && $actor->can('reply', $discussion)) {
$allowRenaming = $this->settings->get('allow_renaming');
if ($allowRenaming === '-1'
|| ($allowRenaming === 'reply' && $discussion->participant_count <= 1)
|| ($discussion->created_at->diffInMinutes() < $allowRenaming)) {
return true;
}
}
}
At the top of the file, i see use Flarum\Settings\SettingsRepositoryInterface;
So i open up that file..
namespace Flarum\Settings;
interface SettingsRepositoryInterface
{
public function all();
public function get($key, $default = null);
public function set($key, $value);
public function delete($keyLike);
}
Okay, no idea where these settings are coming from or how the previous file gets them.
OK, the logic to get these is in databasesettingsrepository.php. Now it's apparent where these settings are coming from. fine enough.
Obviously i'm in the wrong place for the logic of renaming a discussion though. So i do a search through the whole system.
The logic is in /src/post/DiscussionRenamedPost.php apparently?
No.. this is a single file that shows whether a post was renamed or not. Why a single file for that?
Okay, time to search again for some kind of rename function.
It's not in /src/event/renamed.php. That just has a constructor in it.
What about discussion/discussion.php?
public function rename($title)
{
if ($this->title !== $title) {
$oldTitle = $this->title;
$this->title = $title;
$this->raise(new Renamed($this, $oldTitle));
}
return $this;
}
Okay, it seems evident this is calling a renamed class to do something.
/src/event/renamed.php
public function __construct(Discussion $discussion, $oldTitle, User $actor = null)
{
$this->discussion = $discussion;
$this->oldTitle = $oldTitle;
$this->actor = $actor;
}
Ok, this looks like it's probably the logic but this functionality is incomplete.
Tracing what triggers say, a form that would allow for the post to be renamed and then the beginning of the chain of events is another matter.
So imagine if this functionality is complete and i have to trace it down through multiple files as someone who doesn't understand the codebase..
What sort of tool would i use to simplify going through the many files that are processed from start to finish?
My only experience with laravel is trying to salvage a failed rewrite of a large LMS done in laravel. It had the chain of events scattered across many files.. about 1000+ 1kb class definitions, but the incomplete system only had 10% of the functionality our Php5.0 era LMS had, which had the model, view, and controller all in one file per page. There were so many layers of classes and abstractions that i could not figure out what was going on, neither could another programmer.
It had me wondering what kind of tools he was using to trace execution or map the whole thing. Perhaps it became too complex for him to handle.. I know he used the sublime text editor... i don't know about any other tools.
We ended up writing the whole codebase off and refactoring the php5.0 LMS all the way up to php7.2 standards, which took 6 months whereas the laravel rewrite went on for 2 years. Hey maybe the programmer was an idiot or something but he sure had a lot of great smaller scale laravel projects under his belt and promised the world with it.
So i never took the time to learn laravel, although everyone is using it now so i really wonder what tools are used to start understanding a new codebase's sequence of events and calls from start to finish.