pdir / key-generator-bundle
Key Generator Wizard for Contao 4
Installs: 34
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 0
Type:contao-bundle
Requires
- php: ^5.6 || ^7.0 || ^8.0
- contao/core-bundle: ^4.4
Requires (Dev)
- contao/manager-plugin: ^2.0
- doctrine/doctrine-cache-bundle: ^1.3
- friendsofphp/php-cs-fixer: ^2.12
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/phpunit: ^5.7.26
- symfony/phpunit-bridge: ^3.2
Conflicts
- contao/core: *
- contao/manager-plugin: <2.0 || >=3.0
This package is auto-updated.
Last update: 2024-11-25 15:14:17 UTC
README
This extension is for Contao 4 and enhances the BE TextField Widget with a keyGenerator Wizard See example:
$GLOBALS['TL_DCA']['tl_member']['fields']['apikey'] = array ( 'label' => &$GLOBALS['TL_LANG']['tl_member']['apikey'], 'exclude' => true, 'search' => false, 'inputType' => 'text', 'wizard' => [['\Pdir\KeyGeneratorBundle\KeyGenerator','getWizard']], 'save_callback' => [['\Pdir\KeyGeneratorBundle\KeyGenerator','setKeyIfEmpty']], 'eval' => ['maxlength'=>32, 'feEditable'=>false, 'feViewable'=>false, 'feGroup'=>'rpc', 'tl_class'=>'w50 wizard'], 'sql' => "varchar(32) NOT NULL default ''" );
You can write your own generator. Use the HOOK
The callback method gets the fieldName and the maxlength. It returns a new key-string or false if the method don't want to set the key
// config.php $GLOBALS['TL_HOOKS']['generateKey'][] = array('\MyClass','generateKey'); // MyClass public function generateKey($strFieldName, $intLength) { if ($strFieldName == 'simplePasswordField') { return str_repeat('X',$intLength); } else if ($strFieldName == 'megaPasswordField') { return 'pasword123'; } return false; }
Original by Sebastian Tilch 2012 for Contao 3