still not working

This commit is contained in:
Nick Yeoman 2023-06-01 08:20:10 -07:00
parent 985514c51b
commit cca1cc8751
11 changed files with 122 additions and 77 deletions

View File

@ -1,16 +0,0 @@
#!/bin/bash
cat <<EOM
<?php
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\AdminController;
class ${name^}Controller extends AdminController
{
public function __construct(\$config = array())
{
parent::__construct(\$config);
}
}
EOM

View File

@ -1,16 +0,0 @@
#!/bin/bash
cat <<EOM > admin_controller_base.php
<?php
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\Controller;
class ${name^}Controller extends Controller
{
public function __construct(\$config = array())
{
parent::__construct(\$config);
}
}
EOM

View File

@ -0,0 +1,14 @@
#!/bin/bash
# Check if $name is set
if [[ -z "${name}" ]]; then
echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)."
exit 1
fi
cat <<EOM > admin/src/View/${name}/html/default.php
<?php defined('_JEXEC') or die('Restricted Access'); ?>
<h2>Hello ${name}!</h2>
EOM

View File

@ -0,0 +1,29 @@
#!/bin/bash
# Check if $name is set
if [[ -z "${name}" ]]; then
echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)."
exit 1
fi
cat <<EOM > admin/src/Controller/DisplayController.php
<?php
namespace harvst\\Component\\${name}\\Administrator\\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
class DisplayController extends BaseController {
protected \$default_view = '${name}';
public function display(\$cachable = false, \$urlparams = array()) {
parent::display();
}
}
EOM

View File

@ -1,7 +1,7 @@
#!/bin/bash
current_date=$(date +'%B %Y')
current_year=$(date +'%Y')
# Check if JOOMLA_USER is set, otherwise prompt for it
if [ -z "$JOOMLA_USER" ]; then
read -p "Enter the Joomla user: " JOOMLA_USER
@ -15,29 +15,34 @@ fi
cat <<EOM > ${name}.xml
<?xml version="1.0" encoding="UTF-8"?>
<extension type="component" method="upgrade">
<name>com_${name}</name>
<name>${name}</name>
<creationDate>${current_date}</creationDate>
<author>${JOOMLA_USER}</author>
<authorEmail>${EMAIL}</authorEmail>
<authorUrl>https://www.example.com/</authorUrl>
<copyright>Copyright (C) 2023 ${JOOMLA_USER}, All rights reserved.</copyright>
<copyright>Copyright (C) ${current_year} ${JOOMLA_USER}, All rights reserved.</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<!-- The version string is recorded in the components table -->
<version>0.0.1</version>
<!-- The description is optional and defaults to the name -->
<description>COM_${name^^}_DESCRIPTION</description>
<namespace path="src">harvst\Component\com_${name}</namespace>
<namespace path="src/">harvst\Component\\${name}</namespace>
<administration>
<!-- The link that will appear in the Admin panel's "Components" menu -->
<menu link="index.php?option=com_${name}">${name}</menu>
<files folder="admin">
<folder>language</folder>
<folder>services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages folder="admin">
<!-- TODO: It's there but not working -->
<language tag="en-GB">language/en-GB/en-GB.com_${name}.ini</language>
</languages>
</administration>
</extension>
EOM

View File

@ -0,0 +1,35 @@
#!/bin/bash
cat <<EOM > admin/services/provider.php
<?php defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
return new class implements ServiceProviderInterface {
public function register(Container \$container): void {
\$container->registerServiceProvider(new MVCFactory('\\harvst\\Component\\${name}'));
\$container->registerServiceProvider(new ComponentDispatcherFactory('\\harvst\\Component\\${name}'));
\$container->set(
ComponentInterface::class,
function (Container \$container) {
\$component = new MVCComponent(\$container->get(ComponentDispatcherFactoryInterface::class));
\$component->setMVCFactory(\$container->get(MVCFactoryInterface::class));
return \$component;
}
);
}
};
EOM

View File

@ -1,16 +0,0 @@
#!/bin/bash
cat <<EOM
<?php
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
class ${name^}Controller extends BaseController
{
public function __construct(\$config = array())
{
parent::__construct(\$config);
}
}
EOM

View File

@ -1,16 +0,0 @@
#!/bin/bash
cat <<EOM
<?php
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\Controller;
class ${name^}Controller extends Controller
{
public function __construct(\$config = array())
{
parent::__construct(\$config);
}
}
EOM

View File

@ -0,0 +1,26 @@
#!/bin/bash
# Check if $name is set
if [[ -z "${name}" ]]; then
echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)."
exit 1
fi
cat <<EOM > admin/src/View/${name}/HtmlView.php
<?php
namespace harvst\\Component\\${name}\\Administrator\\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
class HtmlView extends BaseHtmlView {
function display(\$tpl = null) {
parent::display(\$tpl);
}
}
EOM

View File

@ -56,17 +56,17 @@ mkdir -p "$component_dir"
# Create the main component files
cd "$component_dir" || exit
mkdir -p site
mkdir -p admin/language/en-GB
mkdir -p admin/language/en-GB admin/services
mkdir -p admin/src/View/${name} admin/tmpl/${name}
# Source the files for generating component files
source "$script_dir/component_parts/manifest.sh"
source "$script_dir/component_parts/language.sh"
# source "$script_dir/component_parts/admin_controller.sh"
# source "$script_dir/component_parts/site_controller.sh"
# source "$script_dir/component_parts/site_controller_base.sh"
# source "$script_dir/component_parts/admin_controller_base.sh"
source "$script_dir/component_parts/provider.sh"
source "$script_dir/component_parts/displaycontroller.sh"
source "$script_dir/component_parts/view.sh"
source "$script_dir/component_parts/defaultview.sh"
echo "Component framework generated successfully!"
echo "You should manually edit the manifest file before checkin"

View File

@ -22,7 +22,7 @@ services:
- joomla-db:/var/lib/mysql
joomla:
image: joomla:4.3.1 # https://hub.docker.com/_/joomla
image: joomla:4.3.2 # https://hub.docker.com/_/joomla
restart: always
environment:
JOOMLA_DB_HOST: mariadb