Ich bin momentan bei der Erstellung eines Plugins für ein neues Einkaufsweltenelement.
Grundsätzlich erweitere ich den bereits bestehenden ArticleSlider, da ein ähnlicher Aufbau besteht.
Mein Problem ist nun das ich noch keine Artikel in meinem $data Array habe. Da der ArticleSlider die ‚values‘ in der convertFunction „getArticleSlider“ befüllt.
Ist es möglich (und wie?) eine eigene convertFunction beim Emotion Controller zu registrieren?
Folgend noch beispielhafte Auszüge aus dem Code und auftretende Fehlermeldung:
Bootstrap: „MyEmotionPlugin.php“
public function install(InstallContext $context)
{
$component = $this->createEmotionComponent($context->getPlugin(), [
'name' => 'My Emotion Plugin',
'xtype' => 'emotion-components-my-emotion-plugin',
'template' => 'emotion_plugin'
'cls' => 'my_emotion_plugin',
'description' => '',
'convertFunction' => 'myConvertFunction'
]);
/* Form elements */
/** @var ModelManager $em */
$em = $this->container->get('models');
$em->persist($component);
$em->flush();
}
Subscriber/Emotion.php
class Emotion implements SubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Action_PostDispatchSecure_Widgets_Emotion' => 'extendsEmotionTemplates',
'Enlight_Controller_Action_PostDispatchSecure_Backend_Emotion' => 'extendsEmotionTemplates',
];
}
private function myConvertFunction($data, $category, $element)
{
echo 'hello world';
/* Code here */
}
public function extendsEmotionTemplates(\Enlight_Event_EventArgs $args)
{
/** @var \Enlight_Controller_Action $controller */
$controller = $args->getSubject();
$view = $controller->View();
$view->addTemplateDir( __DIR__. '/../Resources/Views/emotion_components/');
if ($controller->Request()->getModuleName() != 'backend')
return;
if ($controller->Request()->getActionName() == 'index')
$view->extendsTemplate('backend/cob_product_list_app.js');
}
}
Folgende Fehlermeldung tritt auf:
Fatal error: Uncaught exception 'Enlight_Exception' with message 'Method "Shopware_Proxies_ShopwareControllersWidgetsEmotionProxy::myConvertFunction" not found failure' in /engine/Shopware/Controllers/Widgets/Emotion.php:300 Stack trace:
#0 /engine/Library/Enlight/Controller/Action.php(408): Enlight_Class->__call('myConvertFuncti...', Array)
#1 /engine/Shopware/Controllers/Widgets/Emotion.php(300): Enlight_Controller_Action->__call('myConvertFuncti...', Array)
#2 /engine/Shopware/Controllers/Widgets/Emotion.php(300): Shopware_Proxies_ShopwareControllersWidgetsEmotionProxy->myConvertFunction(Array, 3, Array)
#3 [internal function]: Shopware_Controllers_Widgets_Emotion->handleElement(Array, Object(Shopware_Proxies_ShopwareModelsEmotionRepositoryProxy), 3)
#4 /var/cache/production_201704210836/proxies/ShopwareCont in /engine/Shopware/Controllers/Widgets/Emotion.php on line 300