3

I would like to make a copy of an extension as a base for my own extension. How can I clone a TYPO3 extension to start my own with the same behaviour. What are the files and parameters I have to change?

3 Answers3

1

You might take a look into this script on github: https://github.com/colorcube/typo3_clone_extension

Basically you have to replace all instances of the Extension key e.g. "my_ext", as well as filenames containing the key.

tripbe
  • 86
  • 1
1

While you can clone an existing extension and change extension key, plugin names, namespaces, database tables etc. (a simple search / replace might work in most cases, make sure to do it case-sensitive though!) ...

But, have you considered using the extension_builder as an alternative to kick-start your new extension? For version 8.7 use the extension_builder from github.

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49
0

If you want manually change the EXT-Key & -Vendor, you have to do the whole way, I did some weeks before ;).

Copy your Extension

With Shell:

cp -r source_ext target_ext

Without Shell:

  • Duplicate the source_ext
  • Rename the source_ext_copy to your target_ext_name

Important to know is:

If your Extension-Directory has a _ inside like `vendor_extkey' the Namespace looks like this: VendorExtkey without the Underscore, but with the CamelCase Spelling.

Migrate Rootfiles

ext_emconf.php: Make your Changes.. this is not so important...

ext_localconf.php:

  • In configurePlugin:
    • Change OldVendor.ExtKey to NewVendor.ExtKey
    • and the PluginName. More to configurePlugin here.
  • In addPageTSConfig: Chage the following:
    • Name under elements
    • EXT: Paths
    • list_type

to your Vendor/ExtKey.

  • In ext_typoscript_setup.txt: you have to change something like this, if this exists:

TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
    subclasses {
        Tx_VendorExtkey_User = Vendor\VendorExtkey\Domain\Model\User
    }
}
Vendor\VendorExtkeyn\Domain\Model\User {
    mapping {
        tableName = fe_users
        recordType = Tx_VendorExtkey_User
    }
}

Migrate Classes: Model, Repository and ViewHelpers

If you have a Model in /Classes/Domain/Model/Yourmodel.php the first lines has to look like this:

<?php
namespace Vendor\ExtKey\Domain\Model;
// Directory ext_key

OR

<?php
namespace Vendor\Extkey\Domain\Model;
// Directory extkey

In a Repository it looks the same: Simply change Model to Repository.

In a ViewHelper it a little different: Simply change Domain\Model to ViewHelpers

Everywhere in the Model you have to check something like this:

/**
 * @param \Vendor\ExtKey\Domain\Model\Yourmodel $yourmodel
 * @return void
 */
public function addLink(\Vendor\ExtKey\Domain\Model\Yourmodel $yourmodel)
{
    ...
}

Here you have to use the FQCN (Fully Quallified Class Name). Leave the other settings as they are.

Migrate Configuration

In each TCA/Overrides/file.php search for the Path: LLL:EXT:source_ext/Resources/Private/Language/locallang_db.xlf and change this to:

LLL:EXT:target_ext/Resources/Private/Language/locallang_db.xlf

Usually you can search for EXT:source_ext and replace this with EXT:target_ext.

Migrate: Configuration/TCA/sys_template.php

Usually here you find something like this:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('source_ext', 'Configuration/TypoScript', 'Extension Name');

Change the source_ext to your target_ext. See more about addStaticFile here.

Migrate: Configuration/TCA/Overrides/tt_content.php

// Register Plugin
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    'Vendor.ExtKey',
    'Plugin Name',
    'Plugin Title'
);

More about registerPlugin here. If the parts in sys_template and tt_content aren't there look in the ext_tables.php -> move it to the right file as above, because ext_tables.php is marked as deprecated.

Migrate Configuration/TypoScript

Here just change EXT:source_ext to EXT:target_ext.

And if you have something like this inside:

## Override storagePid for UserGroups
Vendor\SourceExt\Domain\Model\UserGroup {
    newRecordStoragePid = {$plugin.tx_sourceext.settings.groupStoragePid}

just change the Vendor and the SourceExt to CamelCase spelling.

Migrate Templates, Layouts and Partials

Here you only have to migrate the Namespace, if you use a ViewHelper inside. Should appear in the first lines.

Change {namespace shortcode=Vendor\SourceExt\ViewHelpers} to {namespace shortcode=NewVendor\TargetExt\ViewHelpers}


I hope I could help. If I forgot something leave a comment.

MonTea
  • 1,166
  • 1
  • 13
  • 30