adding Joomla\CMS\Filesystem\File #1166

Closed
opened 2024-08-25 21:17:19 +00:00 by MustBeAnError · 3 comments

As I wrote on telegram:
'I'm struggling with the differences between J3 and J4 code. I couldn't figure out where and how to integrate the Joomla file system in my admin view (use Joomla\CMS\Filesystem\File). Unfortunately, the old YT tutorials are no longer helpful.'
You guidance how to do this with the new Joomla Power feature is much appreciated.

As I wrote on telegram: 'I'm struggling with the differences between J3 and J4 code. I couldn't figure out where and how to integrate the Joomla file system in my admin view (use Joomla\CMS\Filesystem\File). Unfortunately, the old YT tutorials are no longer helpful.' You guidance how to do this with the new Joomla Power feature is much appreciated.
Owner

In what area of the admin view would you like this? Would be the first question... so if you can give use a screenshot of where you would like to add our custom code?

That is still the same between all versions of Joomla... and JCB, and so for that the tutorials will still give you all the information you need.

Once we know where, as in what area you want to add your Joomla\CMS\Filesystem\File code... you then must just use the JPK key in this way.

Replace your code that might look like this:

File::copy(...)

With this:

Joomla___55e9e8f0_3c5e_483a_a063_7c7565b00ed7___Power::copy(...)

This will then automatically add the use statement to the header of the class and will update the class name with File as needed.

To see the list of all Joomla Powers: https://git.vdm.dev/joomla/joomla-powers#index-of-joomla-powers

remember to replace the --- with ___ in the JPK to activate that Joomla! Power in your code

You can add any Joomla class (using the JPK) anywhere in any custom code area in JCB and JCB will take care of the rest. Should you like to add classes that we have not yet added, Just open an issue here https://git.vdm.dev/joomla/joomla-powers/issues and we will add it.

So just as an heads up Joomla want you to use Joomla\Filesystem\File instead of Joomla\CMS\Filesystem\File and so we already took care of this, as you will see:
image

When you target Joomla 3, we will use Joomla\CMS\Filesystem\File but all other versions Joomla\Filesystem\File as stated here.

In what area of the admin view would you like this? Would be the first question... so if you can give use a screenshot of where you would like to add our custom code? That is still the same between all versions of Joomla... and JCB, and so for that the tutorials will still give you all the information you need. Once we know where, as in what area you want to add your `Joomla\CMS\Filesystem\File` code... you then must just use the JPK key in this way. Replace your code that might look like this: ``` File::copy(...) ``` With this: ``` Joomla___55e9e8f0_3c5e_483a_a063_7c7565b00ed7___Power::copy(...) ``` This will then automatically add the use statement to the header of the class and will update the class name with `File` as needed. To see the list of all Joomla Powers: https://git.vdm.dev/joomla/joomla-powers#index-of-joomla-powers > remember to replace the --- with ___ in the JPK to activate that Joomla! Power in your code You can add any Joomla class (using the JPK) anywhere in any custom code area in JCB and JCB will take care of the rest. Should you like to add classes that we have not yet added, Just open an issue here https://git.vdm.dev/joomla/joomla-powers/issues and we will add it. So just as an heads up Joomla want you to use `Joomla\Filesystem\File` instead of `Joomla\CMS\Filesystem\File` and so we already took care of this, as you will see: ![image](https://git.vdm.dev/attachments/541ee3b3-8f50-4863-94f5-4a84d22d173e) When you target Joomla 3, we will use `Joomla\CMS\Filesystem\File` but all other versions `Joomla\Filesystem\File` as [stated here](https://github.com/joomla/joomla-cms/blob/9c9dd251450d7f87dd44cee45f1c22255c86c7dc/libraries/src/Filesystem/File.php#L28).
Author

Thank your for your advice. The Power feature is really powerful - and worked like a charm!

Thank your for your advice. The Power feature is really powerful - and worked like a charm!
Owner

Give JCB a positive review on the Joomla index 👍

Give JCB a positive review on the Joomla index 👍
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1166
No description provided.