XF 2.0 Getting error while developing addon as suggested in dev doc

I am getting below error while following "xf-addon:install-step" step from dev doc.

PHP:
An exception occurred: [TypeError] Argument 1 passed to Demo\Portal\Setup::Demo\Portal\{closure}() must be an instance of Demo\Portal\Alter, instance of XF\Db\Schema\Alter given, called in /var/www/xf207/src/XF/Db/SchemaManager.php on line 142 in src/addons/Demo/Portal/Setup.php on line 18
#0 src/XF/Db/SchemaManager.php(142): Demo\Portal\Setup->Demo\Portal\{closure}(Object(XF\Db\Schema\Alter))
#1 src/addons/Demo/Portal/Setup.php(21): XF\Db\SchemaManager->alterTable('xf_forum', Object(Closure))
#2 src/XF/Cli/Command/AddOn/AbstractSetupStep.php(128): Demo\Portal\Setup->installStep1(Array)
#3 src/XF/Cli/Command/AddOn/AbstractSetupStep.php(68): XF\Cli\Command\AddOn\AbstractSetupStep->runStep(Object(Demo\Portal\Setup), Object(Symfony\Component\Console\Output\ConsoleOutput), 'install', '1', NULL, Array)
#4 src/vendor/symfony/console/Command/Command.php(242): XF\Cli\Command\AddOn\AbstractSetupStep->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 src/vendor/symfony/console/Application.php(843): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 src/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\AddOn\InstallStep), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 src/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 src/XF/Cli/Runner.php(63): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 cmd.php(15): XF\Cli\Runner->run()
#10 {main}

So please suggest what the issue is and how to resolve it?
 
Without looking at any code, I'm going to guess that you forgot to add the namespace to the type passed as a parameter - or more likely, forgot to add the use clause to the top of the file.
 
you probably need to add use XF\Db\Schema\Alter; to the top of the file.

PHP:
<?php

namespace Demo\Portal;

use XF\Db\Schema\Alter; // <--- DID YOU FORGET THIS?
use XF\Db\Schema\Create;

class Setup extends \XF\AddOn\AbstractSetup
{
    use \XF\AddOn\StepRunnerInstallTrait;
    use \XF\AddOn\StepRunnerUpgradeTrait;
    use \XF\AddOn\StepRunnerUninstallTrait;

    public function installStep1()
    {
        $this->schemaManager()->alterTable('xf_forum', function(Alter $table)
        {
            $table->addColumn('demo_portal_auto_feature', 'tinyint')->setDefault(0);
        });
    }
}
 
Getting a error while trying to create forum_edit template as suggested at here Modifying the forum edit form .

According to the doc
When you entered the template name in the "Template" field, you may notice that a preview of the template contents was displayed........
But I am getting nothing but a message "The requested template could not be found." (See in attached screenshot also)

Please suggest what could be the issue here.
 

Attachments

  • Selection_369.webp
    Selection_369.webp
    38 KB · Views: 8
  • Selection_370.webp
    Selection_370.webp
    21.6 KB · Views: 8
  • Selection_371.webp
    Selection_371.webp
    36.5 KB · Views: 6
That's because forum_edit is an admin template - you need to swap to the Admin template list.

1533728244460.webp



... similarly when adding a template modification, change to the Admin template modification list first:

1533728297226.webp


... then make sure your template modification type is Admin before you proceed:

1533728353042.webp

... don't worry - I forget to do this myself occasionally!

I would like to see the UI changed somewhat in future versions to make it a little more obvious about what's going on. Also, it would be nice to be able to change between public/email/admin templates at the add template or add template modification stage.
 
Also, it would be nice to be able to change between public/email/admin templates at the add template or add template modification stage.
This. And the template search should be able to search in all categories so we don't have to pre-pick.
 
I would like to see the UI changed somewhat in future versions to make it a little more obvious about what's going on. Also, it would be nice to be able to change between public/email/admin templates at the add template or add template modification stage.
Yes, I think. As I didn't notice this tab at my first view.

I think, when are creating the template, in the form "Template modification type" could be a "select option" type field for better visibility.

Thank you for you help.
 
Back
Top Bottom