Component Builder (v.4.0.1-alpha3)
+ Component Builder (v.4.0.1-alpha4)
The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
diff --git a/componentbuilder_update_server.xml b/componentbuilder_update_server.xml
index 96bb7b04e..23a5d7312 100644
--- a/componentbuilder_update_server.xml
+++ b/componentbuilder_update_server.xml
@@ -59,10 +59,10 @@
pkg_component_builder
package
site
- 4.0.1-alpha3
+ 4.0.1-alpha4
https://dev.vdm.io
- https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v4.0.1-alpha3.zip
+ https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v4.0.1-alpha4.zip
alpha
diff --git a/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php b/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php
index 694bbc927..a41d27bae 100644
--- a/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php
+++ b/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php
@@ -343,9 +343,17 @@ abstract class Schema implements SchemaInterface
'expected' => $expected['type']
];
}
-
// check if update of default values is needed
- if ($this->checkDefault($table, $column) && !isset($requireUpdate[$column]))
+ elseif ($this->checkDefault($table, $column))
+ {
+ $requireUpdate[$column] = [
+ 'column' => $column,
+ 'current' => $current->Type,
+ 'expected' => $expected['type']
+ ];
+ }
+ // check if update of null is needed
+ elseif ($this->checkNull($table, $column))
{
$requireUpdate[$column] = [
'column' => $column,
@@ -391,13 +399,21 @@ abstract class Schema implements SchemaInterface
$default = $this->getDefaultValue($type, $db_default);
// Prepare the null switch, and auto increment statement
- $null_switch = !empty($db['null_switch']) ? " " . $db['null_switch'] : '';
+ $null_switch = !empty($db['null_switch']) ? ' ' . $db['null_switch'] : '';
+
+ // Prepare the auto increment statement
$auto_increment = !empty($db['auto_increment']) ? " AUTO_INCREMENT" : '';
+ // If there's a default value, the column should not be nullable
+ if ($default !== '')
+ {
+ $null_switch = '';
+ }
+
$this->setKeys($db);
// Assemble the SQL snippet for the column definition
- return "{$column_name} {$type}{$null_switch}{$default}{$auto_increment}";
+ return "{$column_name} {$type}{$null_switch}{$auto_increment}{$default}";
} catch (\Exception $e) {
throw new \Exception("Error: failed to generate column definition for ($table.$field). " . $e->getMessage());
}
@@ -448,6 +464,61 @@ abstract class Schema implements SchemaInterface
return false;
}
+ /**
+ * Check and Update the null value if needed, including existing data adjustments
+ *
+ * @param string $table The table to update.
+ * @param string $column The column/field to check.
+ *
+ * @return bool
+ * @since 3.2.2
+ */
+ protected function checkNull(string $table, string $column): bool
+ {
+ // Retrieve the expected column configuration
+ $expected = $this->table->get($table, $column, 'db');
+
+ // Skip updates if the null_switch is not set
+ if (!isset($expected['null_switch']))
+ {
+ return false;
+ }
+
+ // Retrieve the current column configuration
+ $current = $this->columns[$column];
+
+ // Skip updates if the Null is not set
+ if (!isset($current->Null))
+ {
+ return false;
+ }
+
+ // set the expected NULL
+ $expected_null = 'NO';
+ if ($expected['null_switch'] === "NULL")
+ {
+ $expected_null = 'YES';
+ }
+
+ // set the current NULL
+ $current_null = $current->Null;
+
+ // Prepare the type and default value SQL statement
+ $type = $expected['type'] ?? 'TEXT';
+ $db_default = isset($expected['default']) ? $expected['default'] : null;
+ $default = $this->getDefaultValue($type, $db_default, true);
+
+ // check the null values if they match
+ if ($current_null !== $expected_null && $current_null === 'NO' && empty($default))
+ {
+ $this->success[] = "Success: updated the ($column) null state in $table table.";
+
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Update the data type of the given fields.
*
@@ -679,8 +750,8 @@ abstract class Schema implements SchemaInterface
* Adjusts the default value SQL fragment for a database field based on its type and specific rules.
*
* If the field is of type DATETIME and the Joomla version is not 3, it sets the default to CURRENT_TIMESTAMP
- * if not explicitly specified otherwise. For all other types, or when a 'EMPTY' default is specified, it handles
- * defaults by either leaving them unset or applying the provided default, properly quoted for SQL safety.
+ * if not explicitly specified otherwise. For all other types it handles defaults by either leaving them unset or applying
+ * the provided default, properly quoted for SQL safety. When a 'EMPTY' default is specified, it returns no default at all. (:)
*
* @param string $type The type of the database field (e.g., 'DATETIME').
* @param string|null $defaultValue Optional default value for the field, null if not provided.
@@ -691,7 +762,7 @@ abstract class Schema implements SchemaInterface
*/
protected function getDefaultValue(string $type, ?string $defaultValue, bool $pure = false): string
{
- if ($defaultValue === null)
+ if ($defaultValue === null || strtoupper($defaultValue) === 'EMPTY')
{
return '';
}
@@ -722,11 +793,7 @@ abstract class Schema implements SchemaInterface
return 'NULL';
}
- if (is_string($value) && strtoupper($value) === 'EMPTY')
- {
- return "''";
- }
- elseif (is_numeric($value))
+ if (is_numeric($value))
{
if (filter_var($value, FILTER_VALIDATE_INT))
{
diff --git a/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Languages.php b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Languages.php
new file mode 100644
index 000000000..a03171f23
--- /dev/null
+++ b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Builder/Languages.php
@@ -0,0 +1,34 @@
+
+ * @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\Compiler\Builder;
+
+
+use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
+use VDM\Joomla\Interfaces\Registryinterface;
+use VDM\Joomla\Abstraction\Registry;
+
+
+/**
+ * Languages Builder Class
+ *
+ * @since 3.2.2
+ */
+final class Languages extends Registry implements Registryinterface
+{
+ /**
+ * Is an Array
+ *
+ * @since 3.2.2
+ */
+ use IsArray;
+}
+
diff --git a/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php
index b6421dd92..6a8a6a6e8 100644
--- a/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php
+++ b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/BuilderLZ.php
@@ -14,6 +14,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
+use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData;
@@ -86,6 +87,9 @@ class BuilderLZ implements ServiceProviderInterface
*/
public function register(Container $container)
{
+ $container->alias(Languages::class, 'Compiler.Builder.Languages')
+ ->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true);
+
$container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages')
->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true);
@@ -246,6 +250,19 @@ class BuilderLZ implements ServiceProviderInterface
->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true);
}
+ /**
+ * Get The Languages Class.
+ *
+ * @param Container $container The DI container.
+ *
+ * @return Languages
+ * @since 3.2.0
+ */
+ public function getLanguages(Container $container): Languages
+ {
+ return new Languages();
+ }
+
/**
* Get The LanguageMessages Class.
*
diff --git a/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Table.php b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Table.php
index 3d8d66197..4cbee85c3 100644
--- a/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Table.php
+++ b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Table.php
@@ -3262,7 +3262,7 @@ class Table extends BaseTable implements Tableinterface
'db' => [
'type' => 'VARCHAR(36)',
'default' => '',
- 'null_switch' => 'NOT NULL',
+ 'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],
@@ -3342,7 +3342,7 @@ class Table extends BaseTable implements Tableinterface
'db' => [
'type' => 'TEXT',
'default' => 'EMPTY',
- 'null_switch' => 'NOT NULL',
+ 'null_switch' => 'NULL',
'unique_key' => false,
'key' => false,
],