Release of v3.2.1-alpha1
Add power path override option on component level. Fix the sql build feature. #1032.
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @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\Package\Database;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use VDM\Joomla\Componentbuilder\Search\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Search\Config;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\Search\Model\Insert as Model;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Package Database Insert
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Insert
|
||||
{
|
||||
/**
|
||||
* Search Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Search Table
|
||||
*
|
||||
* @var Table
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Table $table;
|
||||
|
||||
/**
|
||||
* Search Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The search config object.
|
||||
* @param Table|null $table The search table object.
|
||||
* @param Model|null $model The search get model object.
|
||||
* @param \JDatabaseDriver|null $db The database object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Table $table = null,
|
||||
?Model $model = null, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Factory::_('Config');
|
||||
$this->table = $table ?: Factory::_('Table');
|
||||
$this->model = $model ?: Factory::_('Set.Model');
|
||||
$this->db = $db ?: JoomlaFactory::getDbo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set values to a given table
|
||||
* Example: $this->value(Value, 23, 'value_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param int $id The item ID
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, int $id, string $field, ?string $table = null): bool
|
||||
{
|
||||
// load the table
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->config->table_name;
|
||||
}
|
||||
|
||||
// check if this is a valid field and table
|
||||
if ($id > 0 && ($name = $this->table->get($table, $field, 'name')) !== null)
|
||||
{
|
||||
// build the object
|
||||
$item = new \stdClass();
|
||||
$item->id = $id;
|
||||
$item->{$name} = $this->model->value($value, $name, $table);
|
||||
|
||||
// Update the column of this table using id as the primary key.
|
||||
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set values to a given table
|
||||
* Example: $this->item(Object, 23, 'table_name');
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item, ?string $table = null): bool
|
||||
{
|
||||
// load the table
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->config->table_name;
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($fields = $this->table->fields($table)) !== null)
|
||||
{
|
||||
// model the item values
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (isset($item->{$field}))
|
||||
{
|
||||
$item->{$field} = $this->model->value($item->{$field}, $field, $table);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the column of this table using id as the primary key.
|
||||
return $this->db->updateObject('#__componentbuilder_' . $table, $item, 'id');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set values to a given table
|
||||
* Example: $this->items(Array, 'table_name');
|
||||
*
|
||||
* @param array|null $items The items being saved
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items, string $table = null): bool
|
||||
{
|
||||
// load the table
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->config->table_name;
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (ArrayHelper::check($items))
|
||||
{
|
||||
$success = true;
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (!$this->item($item, $table))
|
||||
{
|
||||
$success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @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\Package\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Package\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Database\Load as Database;
|
||||
|
||||
|
||||
/**
|
||||
* Package Database Load
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Load
|
||||
{
|
||||
/**
|
||||
* Search Table
|
||||
*
|
||||
* @var Table
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Table $table;
|
||||
|
||||
/**
|
||||
* Database Load
|
||||
*
|
||||
* @var Database
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Database $load;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Table|null $table The core table object.
|
||||
* @param Database|null $load The database object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Table $table = null, ?Database $load = null)
|
||||
{
|
||||
$this->table = $table ?: Factory::_('Table');
|
||||
$this->load = $load ?: Factory::_('Load');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a given table
|
||||
* Example: $this->value(23, 'value_key', 'table_name');
|
||||
*
|
||||
* @param int $id The item ID
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value(int $id, string $field, string $table)
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($id > 0 && $this->table->exist($table, $field))
|
||||
{
|
||||
return $this->load->value(
|
||||
["a.${field}" => $field], ['a' => $table], ['a.id' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->item(23, 'table_name');
|
||||
*
|
||||
* @param int $id The item ID
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(int $id, ?string $table): ?object
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($id > 0 && $this->table->exist($table))
|
||||
{
|
||||
return $this->load->item(
|
||||
['all' => 'a.*'], ['a' => $table], ['a.id' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->items($ids, 'table_name');
|
||||
*
|
||||
* @param array $ids The item ids
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(array $ids, string $table): ?array
|
||||
{
|
||||
// check if this is a valid table
|
||||
if ($this->table->exist($table))
|
||||
{
|
||||
return $this->load->items(
|
||||
['all' => 'a.*'], ['a' => $table], ['a.id' => $ids]
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage encrypt
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Package\Display;
|
||||
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Package Display Details Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Details
|
||||
{
|
||||
/**
|
||||
* The Owner details template
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private array $owner = [
|
||||
'company' => 'COM_COMPONENTBUILDER_DTCOMPANYDTDDSDD',
|
||||
'owner' => 'COM_COMPONENTBUILDER_DTOWNERDTDDSDD',
|
||||
'email' => 'COM_COMPONENTBUILDER_DTEMAILDTDDSDD',
|
||||
'website' => 'COM_COMPONENTBUILDER_DTWEBSITEDTDDSDD',
|
||||
'license' => 'COM_COMPONENTBUILDER_DTLICENSEDTDDSDD',
|
||||
'copyright' => 'COM_COMPONENTBUILDER_DTCOPYRIGHTDTDDSDD'
|
||||
];
|
||||
|
||||
/**
|
||||
* The Component details template
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private array $component = [
|
||||
'ul' => [
|
||||
'companyname' => 'COM_COMPONENTBUILDER_ICOMPANYI_BSB',
|
||||
'author' => 'COM_COMPONENTBUILDER_IAUTHORI_BSB',
|
||||
'email' => 'COM_COMPONENTBUILDER_IEMAILI_BSB',
|
||||
'website' => 'COM_COMPONENTBUILDER_IWEBSITEI_BSB',
|
||||
],
|
||||
'other' => [
|
||||
'license' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP',
|
||||
'copyright' => 'COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* get the JCB package owner details display
|
||||
*
|
||||
* @param array $info The package info object
|
||||
* @param bool $trust The trust switch
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function owner(array $info, $trust = false): string
|
||||
{
|
||||
$hasOwner = false;
|
||||
|
||||
$ownerDetails = '<h2 class="module-title nav-header">' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '</h2>';
|
||||
$ownerDetails .= '<dl class="uk-description-list-horizontal">';
|
||||
|
||||
// load the list items
|
||||
foreach ($this->owner as $key => $dd)
|
||||
{
|
||||
if ($value = $this->getInfoValue($key, $info))
|
||||
{
|
||||
$ownerDetails .= Text::sprintf($dd, $value);
|
||||
|
||||
// check if we have a owner/source name
|
||||
if (('owner' === $key || 'company' === $key) && !$hasOwner)
|
||||
{
|
||||
$hasOwner = true;
|
||||
$owner = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ownerDetails .= '</dl>';
|
||||
|
||||
// provide some details to how the user can get a key
|
||||
if ($hasOwner && isset($info['getKeyFrom']['buy_link']) && StringHelper::check($info['getKeyFrom']['buy_link']))
|
||||
{
|
||||
$ownerDetails .= '<hr />';
|
||||
$ownerDetails .= Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA', 'class="btn btn-primary" href="' . $info['getKeyFrom']['buy_link'] . '" target="_blank" title="get a key from ' . $owner . '"', $owner);
|
||||
}
|
||||
// add more custom links
|
||||
elseif ($hasOwner && isset($info['getKeyFrom']['buy_links']) && ArrayHelper::check($info['getKeyFrom']['buy_links']))
|
||||
{
|
||||
$buttons = array();
|
||||
foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link)
|
||||
{
|
||||
$buttons[] = Text::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA', $owner, 'class="btn btn-primary" href="' . $link . '" target="_blank" title="get a key from ' . $owner . '"', $keyName);
|
||||
}
|
||||
$ownerDetails .= '<hr />';
|
||||
$ownerDetails .= implode('<br />', $buttons);
|
||||
}
|
||||
|
||||
// return the owner details
|
||||
if (!$hasOwner)
|
||||
{
|
||||
$ownerDetails = '<h2>' . Text::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '</h2>';
|
||||
|
||||
if (!$trust)
|
||||
{
|
||||
$ownerDetails .= '<p style="color: #922924;">' . Text::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
return '<div>'.$ownerDetails.'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if info details has owner values set
|
||||
*
|
||||
* @param array $info The package info object
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function hasOwner(array &$info): bool
|
||||
{
|
||||
if ($this->getInfoValue('owner', $info) || $this->getInfoValue('company', $info))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the JCB package components details display
|
||||
*
|
||||
* @param array $info The package info object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function components(array &$info): string
|
||||
{
|
||||
// check if these components need a key
|
||||
$needKey = $this->hasKey($info);
|
||||
|
||||
if (isset($info['name']) && ArrayHelper::check($info['name']))
|
||||
{
|
||||
$cAmount = count((array) $info['name']);
|
||||
$class2 = ($cAmount == 1) ? 'span12' : 'span6';
|
||||
$counter = 1;
|
||||
$display = array();
|
||||
foreach ($info['name'] as $key => $value)
|
||||
{
|
||||
// set the name
|
||||
$name = $value . ' v' . $info['component_version'][$key];
|
||||
if ($cAmount > 1 && $counter == 3)
|
||||
{
|
||||
$display[] = '</div>';
|
||||
$counter = 1;
|
||||
}
|
||||
if ($cAmount > 1 && $counter == 1)
|
||||
{
|
||||
$display[] = '<div>';
|
||||
}
|
||||
$display[] = '<div class="well well-small ' . $class2 . '">';
|
||||
$display[] = '<h3>';
|
||||
$display[] = $name;
|
||||
if ($needKey)
|
||||
{
|
||||
$display[] = ' - <em>' . Text::sprintf('COM_COMPONENTBUILDER_PAIDLOCKED') . '</em>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$display[] = ' - <em>' . Text::sprintf('COM_COMPONENTBUILDER_FREEOPEN') . '</em>';
|
||||
}
|
||||
$display[] = '</h3><h4>';
|
||||
$display[] = $info['short_description'][$key];
|
||||
$display[] = '</h4>';
|
||||
$display[] = '<ul class="uk-list uk-list-striped">';
|
||||
|
||||
// load the list items
|
||||
foreach ($this->component['ul'] as $li => $value)
|
||||
{
|
||||
if (isset($info[$li]) && isset($info[$li][$key]))
|
||||
{
|
||||
$display[] = '<li>'.Text::sprintf($value, $info[$li][$key]).'</li>';
|
||||
}
|
||||
}
|
||||
$display[] = '</ul>';
|
||||
|
||||
// if we have a source link we add it
|
||||
if (isset($info['joomla_source_link']) && ArrayHelper::check($info['joomla_source_link']) && isset($info['joomla_source_link'][$key]) && StringHelper::check($info['joomla_source_link'][$key]))
|
||||
{
|
||||
$display[] = '<a class="uk-button uk-button-mini uk-width-1-1 uk-margin-small-bottom" href="' .
|
||||
$info['joomla_source_link'][$key] . '" target="_blank" title="' . Text::_('COM_COMPONENTBUILDER_SOURCE_CODE_FOR_JOOMLA_COMPONENT') . ' ('. $name . ')">' . Text::_('COM_COMPONENTBUILDER_SOURCE_CODE') . '</a>';
|
||||
}
|
||||
|
||||
// load other
|
||||
foreach ($this->component['other'] as $other => $value)
|
||||
{
|
||||
if (isset($info[$other]) && isset($info[$other][$key]))
|
||||
{
|
||||
$display[] = Text::sprintf($value, $info[$other][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$display[] = '</div>';
|
||||
|
||||
$counter++;
|
||||
}
|
||||
|
||||
// close the div if needed
|
||||
if ($cAmount > 1)
|
||||
{
|
||||
$display[] = '</div>';
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $display);
|
||||
}
|
||||
|
||||
return '<div>' . Text::_('COM_COMPONENTBUILDER_NO_COMPONENT_DETAILS_FOUND_SO_IT_IS_NOT_SAFE_TO_CONTINUE') . '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* get the value from INFO array
|
||||
*
|
||||
* @param string $key The value key
|
||||
* @param array $info The package info object
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private function getInfoValue(string $key, array &$info): ?string
|
||||
{
|
||||
$source = (isset($info['source']) && isset($info['source'][$key])) ? 'source' : ((isset($info['getKeyFrom']) && isset($info['getKeyFrom'][$key])) ? 'getKeyFrom' : null);
|
||||
if ($source && StringHelper::check($info[$source][$key]))
|
||||
{
|
||||
return $info[$source][$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the JCB package has a key
|
||||
*
|
||||
* @param array $info The package info object
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private function hasKey(array &$info): bool
|
||||
{
|
||||
// check the package key status
|
||||
if (!isset($info['key']))
|
||||
{
|
||||
if (isset($info['getKeyFrom']) && isset($info['getKeyFrom']['owner']))
|
||||
{
|
||||
// has a key
|
||||
$info['key'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// does not have a key
|
||||
$info['key'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $info['key'];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @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\Package;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Componentbuilder\Service\Crypt;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Database;
|
||||
use VDM\Joomla\Componentbuilder\Service\Server;
|
||||
use VDM\Joomla\Componentbuilder\Package\Service\Display;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Package Factory
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Factory implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Database())
|
||||
->registerServiceProvider(new Crypt())
|
||||
->registerServiceProvider(new Server())
|
||||
->registerServiceProvider(new Display());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @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\Package\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Database\Load;
|
||||
use VDM\Joomla\Database\Insert;
|
||||
use VDM\Joomla\Componentbuilder\Package\Database\Load as LoadDatabase;
|
||||
use VDM\Joomla\Componentbuilder\Package\Database\Insert as InsertDatabase;
|
||||
|
||||
|
||||
/**
|
||||
* Database Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Database implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Load::class, 'Load')
|
||||
->share('Load', [$this, 'getLoad'], true);
|
||||
|
||||
$container->alias(Insert::class, 'Insert')
|
||||
->share('Insert', [$this, 'getInsert'], true);
|
||||
|
||||
$container->alias(LoadDatabase::class, 'Load.Database')
|
||||
->share('Load.Database', [$this, 'getDatabaseLoad'], true);
|
||||
|
||||
$container->alias(InsertDatabase::class, 'Insert.Database')
|
||||
->share('Insert.Database', [$this, 'getDatabaseInsert'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Load Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Load
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLoad(Container $container): Load
|
||||
{
|
||||
return new Load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Insert Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Insert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getInsert(Container $container): Insert
|
||||
{
|
||||
return new Insert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Load Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return LoadDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getDatabaseLoad(Container $container): LoadDatabase
|
||||
{
|
||||
return new LoadDatabase(
|
||||
$container->get('Table'),
|
||||
$container->get('Load')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Insert Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return InsertDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getDatabaseInsert(Container $container): InsertDatabase
|
||||
{
|
||||
return new InsertDatabase(
|
||||
$container->get('Table'),
|
||||
$container->get('Insert')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @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\Package\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Package\Display\Details;
|
||||
|
||||
|
||||
/**
|
||||
* Display Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Display implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Details::class, 'Display.Details')
|
||||
->share('Display.Details', [$this, 'getDetails'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Display Details
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Details
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getDetails(Container $container): Details
|
||||
{
|
||||
return new Details();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user