forked from joomla/super-powers
Update 2024-09-03 01:25:12
This commit is contained in:
parent
ceb508698d
commit
e5a248a773
@ -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`
|
||||
|
45
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/README.md
Normal file
45
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/README.md
Normal file
@ -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)
|
||||
|
23
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php
Normal file
23
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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
|
||||
{
|
||||
}
|
||||
|
1
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.power
Normal file
1
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/code.power
Normal file
@ -0,0 +1 @@
|
||||
###CODEPOWER###
|
20
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json
Normal file
20
src/1c10a5f1-204d-4f17-ad9f-0e0684f2030d/settings.json
Normal file
@ -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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/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": ""
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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'],
|
||||
|
@ -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'],
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user