forked from joomla/super-powers
Update 2024-08-21 11:09:12
This commit is contained in:
parent
7ec399f12f
commit
4a12bd8374
@ -19,7 +19,7 @@ use VDM\Joomla\Abstraction\PHPConfigurationChecker as ExtendingPHPConfigurationC
|
|||||||
/**
|
/**
|
||||||
* Componentbuilder PHP Configuration Checker
|
* Componentbuilder PHP Configuration Checker
|
||||||
*
|
*
|
||||||
* @since 3.2.2
|
* @since 5.02
|
||||||
*/
|
*/
|
||||||
final class PHPConfigurationChecker extends ExtendingPHPConfigurationChecker implements PHPConfigurationCheckerInterface
|
final class PHPConfigurationChecker extends ExtendingPHPConfigurationChecker implements PHPConfigurationCheckerInterface
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"use_selection": null,
|
"use_selection": null,
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].PHPConfigurationChecker",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].PHPConfigurationChecker",
|
||||||
"description": "[[[Component]]] PHP Configuration Checker\r\n\r\n@since 3.2.2",
|
"description": "[[[Component]]] PHP Configuration Checker\r\n\r\n@since 5.02",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
abstract ObjectHelper #Orange {
|
abstract ObjectHelper #Orange {
|
||||||
+ {static} check($object)
|
+ {static} check($object)
|
||||||
+ {static} equal(?object $obj1, ?object $obj2) : bool
|
+ {static} equal(?object $obj1, ?object $obj2) : bool
|
||||||
|
# {static} recursiveKsort($array) : void
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of ObjectHelper::check
|
note right of ObjectHelper::check
|
||||||
@ -23,15 +24,24 @@ note right of ObjectHelper::check
|
|||||||
end note
|
end note
|
||||||
|
|
||||||
note right of ObjectHelper::equal
|
note right of ObjectHelper::equal
|
||||||
Compare two objects for equality based on their property values.
|
Checks if two objects are equal by comparing their properties and values.
|
||||||
Note that this method works only for simple objects that don't
|
This method converts both input objects to
|
||||||
contain any nested objects or resource references. If you need
|
associative arrays, sorts the arrays by keys,
|
||||||
to compare more complex objects, you may need to use a
|
and compares these sorted arrays.
|
||||||
more advanced method such as serialization or reflection.
|
If the arrays are identical, the objects are considered equal.
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of ObjectHelper::recursiveKsort
|
||||||
|
Recursively sorts an associative array by keys.
|
||||||
|
This method will sort an associative array by its keys at all levels.
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -39,17 +39,19 @@ abstract class ObjectHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two objects for equality based on their property values.
|
* Checks if two objects are equal by comparing their properties and values.
|
||||||
*
|
*
|
||||||
* Note that this method works only for simple objects that don't
|
* This method converts both input objects to
|
||||||
* contain any nested objects or resource references. If you need
|
* associative arrays, sorts the arrays by keys,
|
||||||
* to compare more complex objects, you may need to use a
|
* and compares these sorted arrays.
|
||||||
* more advanced method such as serialization or reflection.
|
*
|
||||||
|
* If the arrays are identical, the objects are considered equal.
|
||||||
*
|
*
|
||||||
* @param object|null $obj1 The first object to compare.
|
* @param object|null $obj1 The first object to compare.
|
||||||
* @param object|null $obj2 The second object to compare.
|
* @param object|null $obj2 The second object to compare.
|
||||||
*
|
*
|
||||||
* @return bool True if the objects have the same key-value pairs and false otherwise.
|
* @return bool True if the objects are equal, false otherwise.
|
||||||
|
* @since 5.0.2
|
||||||
*/
|
*/
|
||||||
public static function equal(?object $obj1, ?object $obj2): bool
|
public static function equal(?object $obj1, ?object $obj2): bool
|
||||||
{
|
{
|
||||||
@ -62,17 +64,41 @@ abstract class ObjectHelper
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the objects to arrays of their property values using get_object_vars.
|
// Convert both objects to associative arrays
|
||||||
$array1 = get_object_vars($obj1);
|
$array1 = json_decode(json_encode($obj1), true);
|
||||||
$array2 = get_object_vars($obj2);
|
$array2 = json_decode(json_encode($obj2), true);
|
||||||
|
|
||||||
// Compare the arrays using array_diff_assoc to detect any differences.
|
// Sort the arrays by keys
|
||||||
$diff1 = array_diff_assoc($array1, $array2);
|
self::recursiveKsort($array1);
|
||||||
$diff2 = array_diff_assoc($array2, $array1);
|
self::recursiveKsort($array2);
|
||||||
|
|
||||||
// If the arrays have the same key-value pairs, they will have no differences, so return true.
|
// Compare the sorted arrays
|
||||||
return empty($diff1) && empty($diff2);
|
return $array1 === $array2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively sorts an associative array by keys.
|
||||||
|
*
|
||||||
|
* This method will sort an associative array by its keys at all levels.
|
||||||
|
*
|
||||||
|
* @param array &$array The array to sort.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected static function recursiveKsort(array &$array): void
|
||||||
|
{
|
||||||
|
// Sort the array by its keys
|
||||||
|
ksort($array);
|
||||||
|
|
||||||
|
// Recursively sort nested arrays
|
||||||
|
foreach ($array as &$value)
|
||||||
|
{
|
||||||
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
self::recursiveKsort($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,17 +18,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two objects for equality based on their property values.
|
* Checks if two objects are equal by comparing their properties and values.
|
||||||
*
|
*
|
||||||
* Note that this method works only for simple objects that don't
|
* This method converts both input objects to
|
||||||
* contain any nested objects or resource references. If you need
|
* associative arrays, sorts the arrays by keys,
|
||||||
* to compare more complex objects, you may need to use a
|
* and compares these sorted arrays.
|
||||||
* more advanced method such as serialization or reflection.
|
*
|
||||||
|
* If the arrays are identical, the objects are considered equal.
|
||||||
*
|
*
|
||||||
* @param object|null $obj1 The first object to compare.
|
* @param object|null $obj1 The first object to compare.
|
||||||
* @param object|null $obj2 The second object to compare.
|
* @param object|null $obj2 The second object to compare.
|
||||||
*
|
*
|
||||||
* @return bool True if the objects have the same key-value pairs and false otherwise.
|
* @return bool True if the objects are equal, false otherwise.
|
||||||
|
* @since 5.0.2
|
||||||
*/
|
*/
|
||||||
public static function equal(?object $obj1, ?object $obj2): bool
|
public static function equal(?object $obj1, ?object $obj2): bool
|
||||||
{
|
{
|
||||||
@ -41,14 +43,39 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the objects to arrays of their property values using get_object_vars.
|
// Convert both objects to associative arrays
|
||||||
$array1 = get_object_vars($obj1);
|
$array1 = json_decode(json_encode($obj1), true);
|
||||||
$array2 = get_object_vars($obj2);
|
$array2 = json_decode(json_encode($obj2), true);
|
||||||
|
|
||||||
// Compare the arrays using array_diff_assoc to detect any differences.
|
// Sort the arrays by keys
|
||||||
$diff1 = array_diff_assoc($array1, $array2);
|
self::recursiveKsort($array1);
|
||||||
$diff2 = array_diff_assoc($array2, $array1);
|
self::recursiveKsort($array2);
|
||||||
|
|
||||||
// If the arrays have the same key-value pairs, they will have no differences, so return true.
|
// Compare the sorted arrays
|
||||||
return empty($diff1) && empty($diff2);
|
return $array1 === $array2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively sorts an associative array by keys.
|
||||||
|
*
|
||||||
|
* This method will sort an associative array by its keys at all levels.
|
||||||
|
*
|
||||||
|
* @param array &$array The array to sort.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected static function recursiveKsort(array &$array): void
|
||||||
|
{
|
||||||
|
// Sort the array by its keys
|
||||||
|
ksort($array);
|
||||||
|
|
||||||
|
// Recursively sort nested arrays
|
||||||
|
foreach ($array as &$value)
|
||||||
|
{
|
||||||
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
self::recursiveKsort($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -9104,6 +9104,22 @@ final class Table extends BaseTable implements Tableinterface
|
|||||||
'key' => true,
|
'key' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'addplaceholders' => [
|
||||||
|
'name' => 'addplaceholders',
|
||||||
|
'label' => 'COM_COMPONENTBUILDER_REPOSITORY_ADDPLACEHOLDERS_LABEL',
|
||||||
|
'type' => 'subform',
|
||||||
|
'title' => false,
|
||||||
|
'list' => 'repositories',
|
||||||
|
'store' => 'json',
|
||||||
|
'tab_name' => 'Placeholders',
|
||||||
|
'db' => [
|
||||||
|
'type' => 'TEXT',
|
||||||
|
'default' => 'EMPTY',
|
||||||
|
'null_switch' => 'NOT NULL',
|
||||||
|
'unique_key' => false,
|
||||||
|
'key' => false,
|
||||||
|
],
|
||||||
|
],
|
||||||
'access_repo' => [
|
'access_repo' => [
|
||||||
'name' => 'access_repo',
|
'name' => 'access_repo',
|
||||||
'label' => 'COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_LABEL',
|
'label' => 'COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_LABEL',
|
||||||
|
@ -22,6 +22,7 @@ abstract Set #Orange {
|
|||||||
# string $area
|
# string $area
|
||||||
# array $map
|
# array $map
|
||||||
# array $settings
|
# array $settings
|
||||||
|
# array $repoPlaceholders
|
||||||
+ __construct(array $repos, Grep $grep, ...)
|
+ __construct(array $repos, Grep $grep, ...)
|
||||||
+ table(string $table) : self
|
+ table(string $table) : self
|
||||||
+ area(string $area) : self
|
+ area(string $area) : self
|
||||||
@ -39,13 +40,14 @@ abstract Set #Orange {
|
|||||||
# mergeIndexSettings(string $repoGuid, array $settings) : array
|
# mergeIndexSettings(string $repoGuid, array $settings) : array
|
||||||
# updateIndexMainFile(object $repo, string $path, ...) : void
|
# updateIndexMainFile(object $repo, string $path, ...) : void
|
||||||
# getLocalItems(array $guids) : ?array
|
# getLocalItems(array $guids) : ?array
|
||||||
# fetchLocalItems(array $guids) : ?array
|
|
||||||
# mapItems(array $items) : array
|
|
||||||
# mapItem(object $item) : object
|
# mapItem(object $item) : object
|
||||||
# save(object $item) : void
|
# save(object $item) : void
|
||||||
|
# setRepoPlaceholders(object $repo) : void
|
||||||
|
# updatePlaceholders(string $string) : string
|
||||||
# getIndexItem(object $item) : ?array
|
# getIndexItem(object $item) : ?array
|
||||||
# canWrite() : bool
|
# canWrite() : bool
|
||||||
# areObjectsEqual(object $obj1, object $obj2) : bool
|
# targetRepo(object $item, object $repo) : bool
|
||||||
|
# areObjectsEqual(?object $obj1, ?object $obj2) : bool
|
||||||
# getSettingsPath() : string
|
# getSettingsPath() : string
|
||||||
# getIndexSettingsPath() : string
|
# getIndexSettingsPath() : string
|
||||||
# index_map_IndexName(object $item) : ?string
|
# index_map_IndexName(object $item) : ?string
|
||||||
@ -200,20 +202,6 @@ note right of Set::getLocalItems
|
|||||||
return: ?array
|
return: ?array
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Set::fetchLocalItems
|
|
||||||
Fetch items from the database
|
|
||||||
|
|
||||||
since: 3.2.2
|
|
||||||
return: ?array
|
|
||||||
end note
|
|
||||||
|
|
||||||
note right of Set::mapItems
|
|
||||||
Map items to their properties
|
|
||||||
|
|
||||||
since: 3.2.2
|
|
||||||
return: array
|
|
||||||
end note
|
|
||||||
|
|
||||||
note left of Set::mapItem
|
note left of Set::mapItem
|
||||||
Map a single item to its properties
|
Map a single item to its properties
|
||||||
|
|
||||||
@ -228,6 +216,20 @@ note right of Set::save
|
|||||||
return: void
|
return: void
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note left of Set::setRepoPlaceholders
|
||||||
|
Set the Repo Placeholders
|
||||||
|
|
||||||
|
since: 5.0.3
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Set::updatePlaceholders
|
||||||
|
Update Placeholders in String
|
||||||
|
|
||||||
|
since: 5.0.3
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
note left of Set::getIndexItem
|
note left of Set::getIndexItem
|
||||||
Get index values
|
Get index values
|
||||||
|
|
||||||
@ -242,58 +244,66 @@ note right of Set::canWrite
|
|||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Set::areObjectsEqual
|
note left of Set::targetRepo
|
||||||
Checks if two objects are equal by comparing their JSON representations.
|
check that we have a target repo of this item
|
||||||
This method converts both input objects to JSON strings and compares these strings.
|
|
||||||
If the JSON strings are identical, the objects are considered equal.
|
|
||||||
|
|
||||||
since: 3.2.2
|
since: 5.0.3
|
||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Set::getSettingsPath
|
note right of Set::areObjectsEqual
|
||||||
|
Checks if two objects are equal by comparing their properties and values.
|
||||||
|
This method converts both input objects to associative arrays, sorts the arrays by keys,
|
||||||
|
and compares these sorted arrays.
|
||||||
|
If the arrays are identical, the objects are considered equal.
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Set::getSettingsPath
|
||||||
Get the settings path
|
Get the settings path
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Set::getIndexSettingsPath
|
note right of Set::getIndexSettingsPath
|
||||||
Get the index settings path
|
Get the index settings path
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Set::index_map_IndexName
|
note left of Set::index_map_IndexName
|
||||||
Get the item name for the index values
|
Get the item name for the index values
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?string
|
return: ?string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Set::index_map_IndexSettingsPath
|
note right of Set::index_map_IndexSettingsPath
|
||||||
Get the item settings path for the index values
|
Get the item settings path for the index values
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Set::index_map_IndexPath
|
note left of Set::index_map_IndexPath
|
||||||
Get the item path for the index values
|
Get the item path for the index values
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Set::index_map_IndexKey
|
note right of Set::index_map_IndexKey
|
||||||
Get the item JPK for the index values
|
Get the item JPK for the index values
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Set::index_map_IndexGUID
|
note left of Set::index_map_IndexGUID
|
||||||
Get the item GUID for the index values
|
Get the item GUID for the index values
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
|
@ -17,6 +17,7 @@ use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
|
|||||||
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
|
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
|
||||||
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
|
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
|
||||||
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
|
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
|
||||||
|
use VDM\Joomla\Utilities\ObjectHelper;
|
||||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +148,27 @@ abstract class Set implements SetInterface
|
|||||||
*/
|
*/
|
||||||
protected string $index_settings_path = 'index.json';
|
protected string $index_settings_path = 'index.json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core Placeholders
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected array $placeholders = [
|
||||||
|
'[['.'[NamespacePrefix]]]' => 'VDM',
|
||||||
|
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
|
||||||
|
'[['.'[Component]]]' => 'Componentbuilder',
|
||||||
|
'[['.'[component]]]' => 'componentbuilder'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repo Placeholders
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected array $repoPlaceholders = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -499,55 +521,10 @@ abstract class Set implements SetInterface
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
protected function getLocalItems(array $guids): ?array
|
protected function getLocalItems(array $guids): ?array
|
||||||
{
|
|
||||||
$items = $this->fetchLocalItems($guids);
|
|
||||||
|
|
||||||
if ($items === null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->mapItems($items);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch items from the database
|
|
||||||
*
|
|
||||||
* @param array $guids The global unique ids of the items
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
* @since 3.2.2
|
|
||||||
*/
|
|
||||||
protected function fetchLocalItems(array $guids): ?array
|
|
||||||
{
|
{
|
||||||
return $this->items->table($this->getTable())->get($guids);
|
return $this->items->table($this->getTable())->get($guids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map items to their properties
|
|
||||||
*
|
|
||||||
* @param array $items The items fetched from the database
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @since 3.2.2
|
|
||||||
*/
|
|
||||||
protected function mapItems(array $items): array
|
|
||||||
{
|
|
||||||
$bucket = [];
|
|
||||||
|
|
||||||
foreach ($items as $item)
|
|
||||||
{
|
|
||||||
if (!isset($item->guid))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bucket[$item->guid] = $this->mapItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bucket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map a single item to its properties
|
* Map a single item to its properties
|
||||||
*
|
*
|
||||||
@ -561,9 +538,17 @@ abstract class Set implements SetInterface
|
|||||||
$power = [];
|
$power = [];
|
||||||
|
|
||||||
foreach ($this->map as $key => $map)
|
foreach ($this->map as $key => $map)
|
||||||
|
{
|
||||||
|
$methodName = "mapItemValue_{$key}";
|
||||||
|
if (method_exists($this, $methodName))
|
||||||
|
{
|
||||||
|
$this->{$methodName}($item, $power);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$power[$key] = $item->{$map} ?? null;
|
$power[$key] = $item->{$map} ?? null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (object) $power;
|
return (object) $power;
|
||||||
}
|
}
|
||||||
@ -586,11 +571,15 @@ abstract class Set implements SetInterface
|
|||||||
$index_item = null;
|
$index_item = null;
|
||||||
foreach ($this->repos as $key => $repo)
|
foreach ($this->repos as $key => $repo)
|
||||||
{
|
{
|
||||||
if (empty($repo->write_branch) || $repo->write_branch === 'default')
|
if (empty($repo->write_branch) || $repo->write_branch === 'default' || !$this->targetRepo($item, $repo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$item = $this->mapItem($item);
|
||||||
|
|
||||||
|
$this->setRepoPlaceholders($repo);
|
||||||
|
|
||||||
$this->git->load_($repo->base ?? null, $repo->token ?? null);
|
$this->git->load_($repo->base ?? null, $repo->token ?? null);
|
||||||
|
|
||||||
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
||||||
@ -622,6 +611,43 @@ abstract class Set implements SetInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Repo Placeholders
|
||||||
|
*
|
||||||
|
* @param object $repo The repo
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected function setRepoPlaceholders(object $repo): void
|
||||||
|
{
|
||||||
|
$this->repoPlaceholders = $this->placeholders;
|
||||||
|
if (!empty($repo->placeholders) && is_array($repo->placeholders))
|
||||||
|
{
|
||||||
|
foreach ($repo->placeholders as $key => $value)
|
||||||
|
{
|
||||||
|
$this->repoPlaceholders[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Placeholders in String
|
||||||
|
*
|
||||||
|
* @param string $string The value to update
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected function updatePlaceholders(string $string): string
|
||||||
|
{
|
||||||
|
return str_replace(
|
||||||
|
array_keys($this->repoPlaceholders),
|
||||||
|
array_values($this->repoPlaceholders),
|
||||||
|
$string
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get index values
|
* Get index values
|
||||||
*
|
*
|
||||||
@ -669,25 +695,36 @@ abstract class Set implements SetInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if two objects are equal by comparing their JSON representations.
|
* check that we have a target repo of this item
|
||||||
*
|
*
|
||||||
* This method converts both input objects to JSON strings and compares these strings.
|
* @param object $item The item
|
||||||
* If the JSON strings are identical, the objects are considered equal.
|
* @param object $repo The current repo
|
||||||
*
|
*
|
||||||
* @param object $obj1 The first object to compare.
|
* @return bool
|
||||||
* @param object $obj2 The second object to compare.
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected function targetRepo(object $item, object $repo): bool
|
||||||
|
{
|
||||||
|
return true; // for more control in children classes
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if two objects are equal by comparing their properties and values.
|
||||||
|
*
|
||||||
|
* This method converts both input objects to associative arrays, sorts the arrays by keys,
|
||||||
|
* and compares these sorted arrays.
|
||||||
|
*
|
||||||
|
* If the arrays are identical, the objects are considered equal.
|
||||||
|
*
|
||||||
|
* @param object|null $obj1 The first object to compare.
|
||||||
|
* @param object|null $obj2 The second object to compare.
|
||||||
*
|
*
|
||||||
* @return bool True if the objects are equal, false otherwise.
|
* @return bool True if the objects are equal, false otherwise.
|
||||||
* @since 3.2.2
|
* @since 5.0.2
|
||||||
*/
|
*/
|
||||||
protected function areObjectsEqual(object $obj1, object $obj2): bool
|
protected function areObjectsEqual(?object $obj1, ?object $obj2): bool
|
||||||
{
|
{
|
||||||
// Convert both objects to JSON strings
|
return ObjectHelper::equal($obj1, $obj2); // basic comparison
|
||||||
$json1 = json_encode($obj1);
|
|
||||||
$json2 = json_encode($obj2);
|
|
||||||
|
|
||||||
// Compare the JSON strings
|
|
||||||
return $json1 === $json2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,6 +118,27 @@
|
|||||||
*/
|
*/
|
||||||
protected string $index_settings_path = 'index.json';
|
protected string $index_settings_path = 'index.json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core Placeholders
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected array $placeholders = [
|
||||||
|
'[['.'[NamespacePrefix]]]' => '[[[NamespacePrefix]]]',
|
||||||
|
'[['.'[ComponentNamespace]]]' => '[[[ComponentNamespace]]]',
|
||||||
|
'[['.'[Component]]]' => '[[[Component]]]',
|
||||||
|
'[['.'[component]]]' => '[[[component]]]'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repo Placeholders
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected array $repoPlaceholders = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -470,55 +491,10 @@
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
protected function getLocalItems(array $guids): ?array
|
protected function getLocalItems(array $guids): ?array
|
||||||
{
|
|
||||||
$items = $this->fetchLocalItems($guids);
|
|
||||||
|
|
||||||
if ($items === null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->mapItems($items);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch items from the database
|
|
||||||
*
|
|
||||||
* @param array $guids The global unique ids of the items
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
* @since 3.2.2
|
|
||||||
*/
|
|
||||||
protected function fetchLocalItems(array $guids): ?array
|
|
||||||
{
|
{
|
||||||
return $this->items->table($this->getTable())->get($guids);
|
return $this->items->table($this->getTable())->get($guids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map items to their properties
|
|
||||||
*
|
|
||||||
* @param array $items The items fetched from the database
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @since 3.2.2
|
|
||||||
*/
|
|
||||||
protected function mapItems(array $items): array
|
|
||||||
{
|
|
||||||
$bucket = [];
|
|
||||||
|
|
||||||
foreach ($items as $item)
|
|
||||||
{
|
|
||||||
if (!isset($item->guid))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bucket[$item->guid] = $this->mapItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bucket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map a single item to its properties
|
* Map a single item to its properties
|
||||||
*
|
*
|
||||||
@ -532,9 +508,17 @@
|
|||||||
$power = [];
|
$power = [];
|
||||||
|
|
||||||
foreach ($this->map as $key => $map)
|
foreach ($this->map as $key => $map)
|
||||||
|
{
|
||||||
|
$methodName = "mapItemValue_{$key}";
|
||||||
|
if (method_exists($this, $methodName))
|
||||||
|
{
|
||||||
|
$this->{$methodName}($item, $power);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$power[$key] = $item->{$map} ?? null;
|
$power[$key] = $item->{$map} ?? null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (object) $power;
|
return (object) $power;
|
||||||
}
|
}
|
||||||
@ -557,11 +541,15 @@
|
|||||||
$index_item = null;
|
$index_item = null;
|
||||||
foreach ($this->repos as $key => $repo)
|
foreach ($this->repos as $key => $repo)
|
||||||
{
|
{
|
||||||
if (empty($repo->write_branch) || $repo->write_branch === 'default')
|
if (empty($repo->write_branch) || $repo->write_branch === 'default' || !$this->targetRepo($item, $repo))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$item = $this->mapItem($item);
|
||||||
|
|
||||||
|
$this->setRepoPlaceholders($repo);
|
||||||
|
|
||||||
$this->git->load_($repo->base ?? null, $repo->token ?? null);
|
$this->git->load_($repo->base ?? null, $repo->token ?? null);
|
||||||
|
|
||||||
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
||||||
@ -593,6 +581,43 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Repo Placeholders
|
||||||
|
*
|
||||||
|
* @param object $repo The repo
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected function setRepoPlaceholders(object $repo): void
|
||||||
|
{
|
||||||
|
$this->repoPlaceholders = $this->placeholders;
|
||||||
|
if (!empty($repo->placeholders) && is_array($repo->placeholders))
|
||||||
|
{
|
||||||
|
foreach ($repo->placeholders as $key => $value)
|
||||||
|
{
|
||||||
|
$this->repoPlaceholders[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Placeholders in String
|
||||||
|
*
|
||||||
|
* @param string $string The value to update
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected function updatePlaceholders(string $string): string
|
||||||
|
{
|
||||||
|
return str_replace(
|
||||||
|
array_keys($this->repoPlaceholders),
|
||||||
|
array_values($this->repoPlaceholders),
|
||||||
|
$string
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get index values
|
* Get index values
|
||||||
*
|
*
|
||||||
@ -640,25 +665,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if two objects are equal by comparing their JSON representations.
|
* check that we have a target repo of this item
|
||||||
*
|
*
|
||||||
* This method converts both input objects to JSON strings and compares these strings.
|
* @param object $item The item
|
||||||
* If the JSON strings are identical, the objects are considered equal.
|
* @param object $repo The current repo
|
||||||
*
|
*
|
||||||
* @param object $obj1 The first object to compare.
|
* @return bool
|
||||||
* @param object $obj2 The second object to compare.
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
protected function targetRepo(object $item, object $repo): bool
|
||||||
|
{
|
||||||
|
return true; // for more control in children classes
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if two objects are equal by comparing their properties and values.
|
||||||
|
*
|
||||||
|
* This method converts both input objects to associative arrays, sorts the arrays by keys,
|
||||||
|
* and compares these sorted arrays.
|
||||||
|
*
|
||||||
|
* If the arrays are identical, the objects are considered equal.
|
||||||
|
*
|
||||||
|
* @param object|null $obj1 The first object to compare.
|
||||||
|
* @param object|null $obj2 The second object to compare.
|
||||||
*
|
*
|
||||||
* @return bool True if the objects are equal, false otherwise.
|
* @return bool True if the objects are equal, false otherwise.
|
||||||
* @since 3.2.2
|
* @since 5.0.2
|
||||||
*/
|
*/
|
||||||
protected function areObjectsEqual(object $obj1, object $obj2): bool
|
protected function areObjectsEqual(?object $obj1, ?object $obj2): bool
|
||||||
{
|
{
|
||||||
// Convert both objects to JSON strings
|
return ObjectHelper::equal($obj1, $obj2); // basic comparison
|
||||||
$json1 = json_encode($obj1);
|
|
||||||
$json2 = json_encode($obj2);
|
|
||||||
|
|
||||||
// Compare the JSON strings
|
|
||||||
return $json1 === $json2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
"use_selection4": {
|
"use_selection4": {
|
||||||
"use": "d1de5d5b-bf29-4031-8094-76c4f6c75900",
|
"use": "d1de5d5b-bf29-4031-8094-76c4f6c75900",
|
||||||
"as": "Git"
|
"as": "Git"
|
||||||
|
},
|
||||||
|
"use_selection5": {
|
||||||
|
"use": "91004529-94a9-4590-b842-e7c6b624ecf5",
|
||||||
|
"as": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
|
@ -455,8 +455,8 @@ abstract class Schema implements SchemaInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($expected['default']) && strtoupper($expected['default']) === 'EMPTY' &&
|
if (isset($expected['default']) && is_string($expected['default']) && strtoupper($expected['default']) === 'EMPTY' &&
|
||||||
is_string($current->Default) && strpos($current->Default, 'EMPTY') !== false)
|
isset($current->Default) && is_string($current->Default) && strpos($current->Default, 'EMPTY') !== false)
|
||||||
{
|
{
|
||||||
return true; // little fix
|
return true; // little fix
|
||||||
}
|
}
|
||||||
|
@ -428,8 +428,8 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($expected['default']) && strtoupper($expected['default']) === 'EMPTY' &&
|
if (isset($expected['default']) && is_string($expected['default']) && strtoupper($expected['default']) === 'EMPTY' &&
|
||||||
is_string($current->Default) && strpos($current->Default, 'EMPTY') !== false)
|
isset($current->Default) && is_string($current->Default) && strpos($current->Default, 'EMPTY') !== false)
|
||||||
{
|
{
|
||||||
return true; // little fix
|
return true; // little fix
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user