Created
May 15, 2017 14:24
-
-
Save fixpunkt/e469296b8a654cdd3bf75050a2cbe999 to your computer and use it in GitHub Desktop.
Base store config tester plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
final class Shopware_Plugins_Backend_BaseStoreConfigsTest_Bootstrap extends Shopware_Components_Plugin_Bootstrap | |
{ | |
/** | |
* @return array | |
*/ | |
public function getInfo() | |
{ | |
return [ | |
'label' => 'Base store configs test', | |
'description' => 'No description' | |
]; | |
} | |
/** | |
* Must be re-declared to please Shopware's automatic code review. | |
* | |
* @return string | |
*/ | |
public function getVersion() | |
{ | |
return '0.1.0'; | |
} | |
/** | |
* @see \Shopware_Components_Plugin_Bootstrap::getCapabilities | |
*/ | |
public function getCapabilities() | |
{ | |
return [ | |
'install' => true, | |
'update' => true, | |
'enable' => true, | |
'secureUninstall' => false | |
]; | |
} | |
public function install() | |
{ | |
return $this->update('install'); | |
} | |
/** | |
* @param string $oldVersion | |
* @return boolean|array | |
*/ | |
public function update($oldVersion) | |
{ | |
// Prepare some helpers | |
$form = $this->Form(); | |
switch ($oldVersion) { | |
case 'install': | |
// Register onStartDispatch subscriber that bootstraps all dynamic subscribers | |
$this->subscribeEvent( | |
'Enlight_Controller_Front_StartDispatch', | |
'onStartDispatch' | |
); | |
// Register console commands | |
$this->subscribeEvent( | |
'Shopware_Console_Add_Command', | |
'onAddConsoleCommand' | |
); | |
// Create the config fields | |
// Single select payment | |
$form->setElement( | |
'select', | |
'selectSinglePaymentMethod', | |
[ | |
'label' => 'Select single payment', | |
'value' => '', | |
'store' => 'Shopware.apps.Base.store.Payment', | |
'displayField' => 'description', | |
'multiSelect' => false, | |
'editable' => false | |
] | |
); | |
// Single select (editable) payment | |
$form->setElement( | |
'select', | |
'selectSinglePaymentMethodEditable', | |
[ | |
'label' => 'Select single payment (editable)', | |
'value' => '', | |
'store' => 'Shopware.apps.Base.store.Payment', | |
'displayField' => 'description', | |
'multiSelect' => false, | |
'editable' => true | |
] | |
); | |
// Multi select payment | |
$form->setElement( | |
'select', | |
'selectMultiPaymentMethod', | |
[ | |
'label' => 'Select multi payment', | |
'value' => '', | |
'store' => 'Shopware.apps.Base.store.Payment', | |
'displayField' => 'description', | |
'multiSelect' => true, | |
'editable' => false | |
] | |
); | |
// Single select dispatch (default) | |
$form->setElement( | |
'select', | |
'selectSingleDispatchMethod', | |
[ | |
'label' => 'Select single dispatch (default filter: active only)', | |
'value' => '', | |
'store' => 'Shopware.apps.Base.store.Dispatch', | |
'displayField' => 'name' | |
] | |
); | |
// Single select dispatch without filters | |
$form->setElement( | |
'select', | |
'selectSingleDispatchMethodNoFilter', | |
[ | |
'label' => 'Select single dispatch (reset filter to select all)', | |
'value' => '', | |
'store' => 'Shopware.apps.Base.store.Dispatch', | |
'displayField' => 'name', | |
'filter' => [] | |
] | |
); | |
// Single select dispatch with filters | |
$form->setElement( | |
'select', | |
'selectSingleDispatchMethodInactiveFilter', | |
[ | |
'label' => 'Select single dispatch (filter: inactive only)', | |
'value' => '', | |
'store' => 'Shopware.apps.Base.store.Dispatch', | |
'displayField' => 'name', | |
'filter' => [ | |
[ | |
'property' => 'active', | |
'value' => false | |
] | |
] | |
] | |
); | |
case '0.1.0': | |
// Next release | |
// *** *** *** *** *** | |
// NEVER REMOVE THE FOLLOWING BREAK! All updates must be added above this comment block! | |
// *** *** *** *** *** | |
break; | |
default: | |
return false; | |
} | |
return true; | |
} | |
/** | |
* @return boolean|array | |
*/ | |
public function uninstall() | |
{ | |
return true; | |
} | |
/** | |
* @return boolean|array | |
*/ | |
public function enable() | |
{ | |
return true; | |
} | |
/** | |
* @return boolean|array | |
*/ | |
public function disable() | |
{ | |
return true; | |
} | |
public function afterInit() | |
{ | |
} | |
public function onStartDispatch(\Enlight_Event_EventArgs $args) | |
{ | |
} | |
public function onAddConsoleCommand(\Enlight_Event_EventArgs $args) | |
{ | |
return []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment