From e5a248a773f68f71840e04d64c51de90042c4fd1 Mon Sep 17 00:00:00 2001 From: aB0t Date: Tue, 3 Sep 2024 01:25:55 +0200 Subject: [PATCH] Update 2024-09-03 01:25:12 --- README.md | 3 ++ .../README.md | 45 +++++++++++++++++++ .../code.php | 23 ++++++++++ .../code.power | 1 + .../settings.json | 20 +++++++++ .../code.php | 4 ++ .../code.power | 3 ++ .../settings.json | 4 ++ .../code.php | 11 +++-- .../code.power | 10 +++-- .../settings.json | 4 ++ super-powers.json | 11 +++++ 12 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/README.md create mode 100644 src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php create mode 100644 src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.power create mode 100644 src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json diff --git a/README.md b/README.md index 85561f4..7fabb2d 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,9 @@ This repository contains an index (see below) of all the approved powers within - **trait IsString** | [Details](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369) | [Code](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369/code.php) | [Settings](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369/settings.json) | SPK: `Super---ff7d0111_8f79_42aa_ac14_b53ba2c49369---Power` - **trait ToString** | [Details](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e) | [Code](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e/code.php) | [Settings](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e/settings.json) | SPK: `Super---7d494d91_ab60_43cd_aecf_d50e07f7f30e---Power` - **trait VarExport** | [Details](src/52a1d14f-304a-431c-8fa4-411179942db5) | [Code](src/52a1d14f-304a-431c-8fa4-411179942db5/code.php) | [Settings](src/52a1d14f-304a-431c-8fa4-411179942db5/settings.json) | SPK: `Super---52a1d14f_304a_431c_8fa4_411179942db5---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Utilities\Exception](#vdm-joomla-componentbuilder-utilities-exception) + + - **class NoUserIdFoundException** | [Details](src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d) | [Code](src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php) | [Settings](src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json) | SPK: `Super---1c10a5f1_204d_4f17_ad9f_0e0684f2030d---Power` - **Namespace**: [VDM\Joomla\Interfaces\Git\Repository](#vdm-joomla-interfaces-git-repository) - **interface ContentsInterface** | [Details](src/d1de5d5b-bf29-4031-8094-76c4f6c75900) | [Code](src/d1de5d5b-bf29-4031-8094-76c4f6c75900/code.php) | [Settings](src/d1de5d5b-bf29-4031-8094-76c4f6c75900/settings.json) | SPK: `Super---d1de5d5b_bf29_4031_8094_76c4f6c75900---Power` diff --git a/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/README.md b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/README.md new file mode 100644 index 0000000..02fc439 --- /dev/null +++ b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/README.md @@ -0,0 +1,45 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class NoUserIdFoundException (Details) +> namespace: **VDM\Joomla\Componentbuilder\Utilities\Exception** +> extends: **\InvalidArgumentException** + +```uml +@startuml +class NoUserIdFoundException #Gold { +} + +@enduml +``` + +The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you. + +By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component. + +JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability. + +To add this specific Power to your project in JCB: + +> simply use this SPK +``` +Super---1c10a5f1_204d_4f17_ad9f_0e0684f2030d---Power +``` +> remember to replace the `---` with `___` to activate this Power in your code + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php new file mode 100644 index 0000000..773c39a --- /dev/null +++ b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php @@ -0,0 +1,23 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Componentbuilder\Utilities\Exception; + + +/** + * No User Id Found Exception + * + * @since 5.0.2 + */ +class NoUserIdFoundException extends \InvalidArgumentException +{ +} + diff --git a/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.power b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.power new file mode 100644 index 0000000..69309b0 --- /dev/null +++ b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.power @@ -0,0 +1 @@ +###CODEPOWER### \ No newline at end of file diff --git a/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json new file mode 100644 index 0000000..f27edbb --- /dev/null +++ b/src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json @@ -0,0 +1,20 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "-1", + "guid": "1c10a5f1-204d-4f17-ad9f-0e0684f2030d", + "implements": null, + "load_selection": null, + "name": "NoUserIdFoundException", + "power_version": "1.0.0", + "system_name": "Joomla.Utilities.Exception.NoUserIdFoundException", + "type": "class", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Utilities.Exception.NoUserIdFoundException", + "description": "No User Id Found Exception\r\n\r\n@since 5.0.2", + "extends_custom": "\\InvalidArgumentException", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": "" +} \ No newline at end of file diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php index 06682d9..c1e0958 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php @@ -16,6 +16,7 @@ use Joomla\CMS\Factory; use VDM\Joomla\Interfaces\Data\ItemsInterface as Items; use VDM\Joomla\Data\Guid; use VDM\Joomla\Componentbuilder\Utilities\UserHelper; +use VDM\Joomla\Componentbuilder\Utilities\Exception\NoUserIdFoundException; use VDM\Joomla\Interfaces\Data\GuidInterface; use VDM\Joomla\Interfaces\Data\SubformInterface; @@ -392,8 +393,11 @@ final class UsersSubform implements GuidInterface, SubformInterface try { return UserHelper::save($user); + } catch(NoUserIdFoundException $e) { + Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); } catch(\Exception $e) { Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); + return $item['user_id']; } return 0; diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power index d13d14a..1b0d755 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power @@ -363,8 +363,11 @@ try { return UserHelper::save($user); + } catch(NoUserIdFoundException $e) { + Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); } catch(\Exception $e) { Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); + return $item['user_id']; } return 0; diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json index 1c0c77a..5ab98c0 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json @@ -24,6 +24,10 @@ "use_selection2": { "use": "7832a726-87b6-4e95-887e-7b725d3fab8f", "as": "default" + }, + "use_selection3": { + "use": "1c10a5f1-204d-4f17-ad9f-0e0684f2030d", + "as": "default" } }, "extendsinterfaces": null, diff --git a/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.php b/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.php index a967367..26efad7 100644 --- a/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.php +++ b/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.php @@ -20,6 +20,7 @@ use Joomla\CMS\MVC\Model\BaseDatabaseModel; use VDM\Joomla\Utilities\Component\Helper as Component; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Utilities\Exception\NoUserIdFoundException; use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; @@ -42,6 +43,7 @@ abstract class UserHelper * * @throws \InvalidArgumentException If required credentials are missing. * @throws \RuntimeException If the user update or creation fails. + * @throws NoUserIdFoundException If the user is not found. * * @since 5.0.3 */ @@ -75,7 +77,7 @@ abstract class UserHelper ) || ($existingUserId !== null && $existingEmailUserId !== null && $existingEmailUserId != $existingUserId) ) { - throw new \RuntimeException(Text::sprintf('COM_COMPONENTBUILDER_USER_ID_MISMATCH_DETECTED_WHEN_TRYING_TO_SAVE_S_S_CREDENTIALS', $username, $credentials['email'])); + throw new NoUserIdFoundException(Text::sprintf('COM_COMPONENTBUILDER_USER_ID_MISMATCH_DETECTED_WHEN_TRYING_TO_SAVE_S_S_CREDENTIALS', $username, $credentials['email'])); } // Update the existing user. @@ -97,7 +99,8 @@ abstract class UserHelper * * @return int User ID on success. * - * @throws \RuntimeException If user creation fails. + * @throws \RuntimeException If user creation fails. + * @throws NoUserIdFoundException If the user is not found. * * @since 5.0.3 */ @@ -118,7 +121,7 @@ abstract class UserHelper return $userId; } - throw new \RuntimeException(Text::_('COM_COMPONENTBUILDER_USER_CREATION_FAILED')); + throw new NoUserIdFoundException(Text::_('COM_COMPONENTBUILDER_USER_CREATION_FAILED')); } // Check if we have params/config @@ -181,7 +184,7 @@ abstract class UserHelper } } - throw new \RuntimeException( + throw new NoUserIdFoundException( Text::sprintf('COM_COMPONENTBUILDER_USER_S_S_CREATION_FAILEDS', (string) $credentials['username'], (string) $credentials['email'], diff --git a/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.power b/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.power index d9ffd01..d69d1d6 100644 --- a/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.power +++ b/src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.power @@ -10,6 +10,7 @@ * * @throws \InvalidArgumentException If required credentials are missing. * @throws \RuntimeException If the user update or creation fails. + * @throws NoUserIdFoundException If the user is not found. * * @since 5.0.3 */ @@ -43,7 +44,7 @@ ) || ($existingUserId !== null && $existingEmailUserId !== null && $existingEmailUserId != $existingUserId) ) { - throw new \RuntimeException(Text::sprintf('User ID mismatch detected when trying to save %s (%s) credentials.', $username, $credentials['email'])); + throw new NoUserIdFoundException(Text::sprintf('User ID mismatch detected when trying to save %s (%s) credentials.', $username, $credentials['email'])); } // Update the existing user. @@ -65,7 +66,8 @@ * * @return int User ID on success. * - * @throws \RuntimeException If user creation fails. + * @throws \RuntimeException If user creation fails. + * @throws NoUserIdFoundException If the user is not found. * * @since 5.0.3 */ @@ -86,7 +88,7 @@ return $userId; } - throw new \RuntimeException(Text::_('User creation failed!')); + throw new NoUserIdFoundException(Text::_('User creation failed!')); } // Check if we have params/config @@ -149,7 +151,7 @@ } } - throw new \RuntimeException( + throw new NoUserIdFoundException( Text::sprintf('User %s (%s) creation failed!%s', (string) $credentials['username'], (string) $credentials['email'], diff --git a/src/7832a726-87b6-4e95-887e-7b725d3fab8f/settings.json b/src/7832a726-87b6-4e95-887e-7b725d3fab8f/settings.json index 5cb34b1..259175e 100644 --- a/src/7832a726-87b6-4e95-887e-7b725d3fab8f/settings.json +++ b/src/7832a726-87b6-4e95-887e-7b725d3fab8f/settings.json @@ -21,6 +21,10 @@ "use_selection2": { "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", "as": "default" + }, + "use_selection3": { + "use": "1c10a5f1-204d-4f17-ad9f-0e0684f2030d", + "as": "default" } }, "extendsinterfaces": null, diff --git a/super-powers.json b/super-powers.json index 05e95b7..d36b97e 100644 --- a/super-powers.json +++ b/super-powers.json @@ -131,6 +131,17 @@ "spk": "Super---19b2ba92_1655_4384_acfb_979c80de8b6d---Power", "guid": "19b2ba92-1655-4384-acfb-979c80de8b6d" }, + "1c10a5f1-204d-4f17-ad9f-0e0684f2030d": { + "name": "NoUserIdFoundException", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Utilities\\Exception", + "code": "src\/1c10a5f1-204d-4f17-ad9f-0e0684f2030d\/code.php", + "power": "src\/1c10a5f1-204d-4f17-ad9f-0e0684f2030d\/code.power", + "settings": "src\/1c10a5f1-204d-4f17-ad9f-0e0684f2030d\/settings.json", + "path": "src\/1c10a5f1-204d-4f17-ad9f-0e0684f2030d", + "spk": "Super---1c10a5f1_204d_4f17_ad9f_0e0684f2030d---Power", + "guid": "1c10a5f1-204d-4f17-ad9f-0e0684f2030d" + }, "1f28cb53-60d9-4db1-b517-3c7dc6b429ef": { "name": "StringHelper", "type": "abstract class",