Advertisement
Guest User

emotions update duplicating

a guest
Nov 15th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. public function createEmotionElements($emotionsNames)
  2.     {
  3.         $emotions = [];
  4.         foreach ($emotionsNames as $emotionsName)
  5.         {
  6.             $emotionInstaller = $this->container->get('shopware.emotion_component_installer');
  7.             try {
  8.                 $emotions[$emotionsName] = $emotionInstaller->createOrUpdate(
  9.                     $this->getName(),
  10.                     'REDACTED' . ucfirst($emotionsName),
  11.                     [
  12.                         'name' => 'REDACTED ' . ucfirst($emotionsName),
  13.                         'template' => "REDACTED_$emotionsName",
  14.                         'cls' => "emotion-REDACTED-$emotionsName-element",
  15.                         'description' => 'REDACTED ' . ucfirst($emotionsName),
  16.                     ]
  17.                 );
  18.  
  19.                 // We don't need fields, but here are some example if you do need it at some point
  20.                 /**
  21.                 $emotions[$emotionsName]->createHiddenField([
  22.                     'name' => 'api_key'
  23.                 ]);
  24.                 $emotions[$emotionsName]->createHiddenField([
  25.                     'name' => 'store_id'
  26.                 ]);
  27.                 **/
  28.             } catch (\Exception $e) {
  29.                 $emotions[$emotionsName] = null;
  30.             }
  31.         }
  32.  
  33.  
  34.         //We don't need config here so far, but one day we might
  35.         if($emotions['sidebar'] != null)
  36.         {
  37.             $sbe = $emotions['sidebar'];
  38.  
  39.         }
  40.         if($emotions['tooltip'] != null)
  41.         {
  42.             $tte = $emotions['tooltip'];
  43.         }
  44.         if($emotions['widget'] != null)
  45.         {
  46.             $we = $emotions['widget'];
  47.         }
  48.  
  49.  
  50.     }
  51.  
  52.  
  53. $this->createEmotionElements([
  54.              'sidebar',
  55.              'tooltip',
  56.              'widget'
  57. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement