setPlugin example


class Enlight_Event_EventHandler extends Enlight_Event_Handler_Default
{
    protected $plugin;

    public function __construct($event$listener$position = null, $plugin = null)
    {
        parent::__construct($event$listener$position);
        $this->setPlugin($plugin);
    }

    /** * @return array */
    public function toArray()
    {
        $listener = $this->listener;
        if (\is_array($listener)) {
            if ($listener[0] instanceof Enlight_Singleton) {
                $listener[0] = \get_class($listener[0]);
            }
$plugin = $pluginRepository->findOneBy([
            'name' => $pluginName,
        ]);

        if (!$payment) {
            $payment = new Payment();
            $payment->setName($options['name']);
            $this->em->persist($payment);
        }
        $payment->fromArray($options);

        $payment->setPlugin($plugin);
        $this->em->flush($payment);

        return $payment;
    }
}
$item = $this->menuRepository->findOneBy([
                'pluginId' => $plugin->getId(),
                'label' => $menuItem['name'],
            ]);
        }

        if (!$item) {
            $item = new Menu();
        }

        $item->setParent($parent);
        $item->setPlugin($plugin);

        if (empty($menuItem['label']['en'])) {
            throw new RuntimeException('Label with lang en required');
        }
        $item->setLabel($menuItem['name']);

        $item->setController($menuItem['controller'] ?? null);

        $item->setAction($menuItem['action'] ?? null);

        $item->setOnclick($menuItem['onclick'] ?? null);

        

    public function createMenuItem(array $options)
    {
        if (!isset($options['label'])) {
            return null;
        }

        $item = new Menu();
        $item->fromArray($options);
        $plugin = $this->Plugin();
        $plugin->getMenuItems()->add($item);
        $item->setPlugin($plugin);

        return $item;
    }

    /** * @return ModelRepository<Payment> */
    final public function Payments(): ModelRepository
    {
        return Shopware()->Models()->getRepository(Payment::class);
    }

    
$plugins = $this->get(PluginStoreService::class)->getPlugins($context);

        foreach ($basket->getPositions() as $position) {
            $name = $this->getTechnicalNameOfOrderNumber($position->getOrderNumber()$positions);

            if ($name === null) {
                continue;
            }

            $key = strtolower($name);
            $position->setPlugin($plugins[$key]);
        }
    }

    /** * @param array<array> $positions */
    private function getTechnicalNameOfOrderNumber(string $orderNumber, array $positions): ?string
    {
        foreach ($positions as $requestPosition) {
            if ($requestPosition['orderNumber'] !== $orderNumber) {
                continue;
            }
/** * Updates the entity with the contents of a row. * * @param \Drupal\Core\Entity\EntityInterface $entity * The search page entity. * @param \Drupal\migrate\Row $row * The row object to update from. */
  protected function updateEntity(EntityInterface $entity, Row $row) {
    parent::updateEntity($entity$row);
    $entity->setPlugin($row->getDestinationProperty('plugin'));
    // The user_search plugin does not have a setConfiguration() method.     $plugin = $entity->getPlugin();
    if ($plugin instanceof ConfigurableSearchPluginBase) {
      $plugin->setConfiguration($row->getDestinationProperty('configuration'));
    }
  }

}

    public function __construct($event$namespace = null, $plugin = null, $listener = null, $position = null)
    {
        if ($namespace !== null) {
            $this->setNamespace($namespace);
        }
        if ($plugin !== null) {
            $this->setPlugin($plugin);
        }
        if ($listener !== null) {
            $this->setListener($listener);
        }
        parent::__construct($event);
        $this->setPosition($position);
    }

    /** * Setter method for the internal plugin property. * * @param mixed $plugin Enlight_Plugin_Bootstrap|string * * @return Enlight_Event_Handler_Plugin */
public function testCreateInstancePluginAware() {
    $plugin_form = $this->prophesize(PluginFormInterface::class)->willImplement(PluginAwareInterface::class);

    $expected = $plugin_form->reveal();

    $this->classResolver->getInstanceFromDefinition(get_class($expected))->willReturn($expected);

    $plugin = $this->prophesize(PluginWithFormsInterface::class);
    $plugin->hasFormClass('operation_aware')->willReturn(TRUE);
    $plugin->getFormClass('operation_aware')->willReturn(get_class($expected));

    $plugin_form->setPlugin($plugin->reveal())->shouldBeCalled();

    $form_object = $this->manager->createInstance($plugin->reveal(), 'operation_aware');
    $this->assertSame($expected$form_object);
  }

  /** * @covers ::createInstance */
  public function testCreateInstanceDefinitionException() {
    $this->expectException(InvalidPluginDefinitionException::class);
    $this->expectExceptionMessage('The "the_plugin_id" plugin did not specify a "anything" form class');

    

    else {
      $form_object = $this->classResolver->getInstanceFromDefinition($form_class);
    }

    // Ensure the resulting object is a plugin form.     if (!$form_object instanceof PluginFormInterface) {
      throw new InvalidPluginDefinitionException($plugin->getPluginId()sprintf('The "%s" plugin did not specify a valid "%s" form class, must implement \Drupal\Core\Plugin\PluginFormInterface', $plugin->getPluginId()$operation));
    }

    if ($form_object instanceof PluginAwareInterface) {
      $form_object->setPlugin($plugin);
    }

    return $form_object;
  }

}
/** * {@inheritdoc} * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param string $action_id * The action ID. */
  public function buildForm(array $form, FormStateInterface $form_state$action_id = NULL) {
    $this->entity->setPlugin($action_id);

    // Derive the label and type from the action definition.     $definition = $this->entity->getPluginDefinition();
    $this->entity->set('label', $definition['label']);
    $this->entity->set('type', $definition['type']);

    return parent::buildForm($form$form_state);
  }

}
$component = $repo->findOneBy([
            'name' => $componentName,
            'pluginId' => $plugin->getId(),
        ]);
        if (!$component) {
            $component = new Component();
        }

        $config = array_merge(static::COMPONENT_DEFAULTS, ['name' => $componentName]$data);
        $component->fromArray($config);
        $component->setPluginId($plugin->getId());
        $component->setPlugin($plugin);
        $plugin->getEmotionComponents()->add($component);

        return $component;
    }
}
/** * Provides a form for adding a search page. * * @internal */
class SearchPageAddForm extends SearchPageFormBase {

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state$search_plugin_id = NULL) {
    $this->entity->setPlugin($search_plugin_id);
    $definition = $this->entity->getPlugin()->getPluginDefinition();
    $this->entity->set('label', $definition['title']);
    return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  protected function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form$form_state);
    $actions['submit']['#value'] = $this->t('Save');
    
$data = $this->getThemeDefinition($theme);

            $template = $this->repository->findOneBy([
                'template' => $theme->getTemplate(),
            ]);

            if (!$template instanceof Template) {
                $template = new Template();

                if ($plugin) {
                    $template->setPlugin($plugin);
                }

                $this->entityManager->persist($template);
            }

            $template->fromArray($data);
            if (!$template->getId() || $settings->getReloadSnippets()) {
                $this->synchronizeSnippets($template);
            }

            $this->entityManager->flush($template);

            
Home | Imprint | This part of the site doesn't use cookies.