Skip to content

Instantly share code, notes, and snippets.

@fixpunkt
Created May 16, 2017 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fixpunkt/6c5310cdd38a1adf925ab6753f82e3c9 to your computer and use it in GitHub Desktop.
Save fixpunkt/6c5310cdd38a1adf925ab6753f82e3c9 to your computer and use it in GitHub Desktop.
Tester plugin to show a backwards compatibility issue in SW 5.2 removeAttribute()
<?php
final class Shopware_Plugins_Backend_AddRemoveAttributesTest_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function getInfo()
{
return [
'label' => 'Add/remove attributes test',
'description' => 'No description'
];
}
public function getVersion()
{
return '0.1.0';
}
public function install()
{
return $this->update('install');
}
/**
* @param string $oldVersion
* @return boolean|array
*/
public function update($oldVersion)
{
/** @var \Shopware\Components\Model\ModelManager $modelManager */
$modelManager = $this->get('models');
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 an attribute
$modelManager->addAttribute(
's_order_details_attributes',
'viison',
'test',
'int(1)'
);
// Remove the attribute again
$modelManager->removeAttribute(
's_order_details_attributes',
'viison',
'test'
);
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;
}
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