setConfig example

// Get the request path condition and test and configure it to check against     // different patterns and requests.
    $pages = "/my/pass/page\r\n/my/pass/page2\r\n/foo";

    $request = Request::create('/my/pass/page2');
    $this->requestStack->push($request);

    /** @var \Drupal\system\Plugin\Condition\RequestPath $condition */
    $condition = $this->pluginManager->createInstance('request_path');
    $this->assertEquals('No page is specified', $condition->summary());
    $condition->setConfig('pages', $pages);

    $this->aliasManager->addAlias('/my/pass/page2', '/my/pass/page2');

    $this->assertTrue($condition->execute(), 'The request path matches a standard path');
    $this->assertEquals('Return true on the following pages: /my/pass/page, /my/pass/page2, /foo', $condition->summary(), 'The condition summary matches for a standard path');

    // Test an aliased path.     $this->currentPath->setPath('/my/aliased/page', $request);
    $this->requestStack->pop();
    $this->requestStack->push($request);

    
$em = $this->Application()->Models();
        $id = $this->getPluginId($bootstrap->getName());
        $plugin = $em->find(Plugin::class$id);

        $newInfo = $bootstrap->getInfo();
        $newInfo = new Enlight_Config($newInfo, true);
        unset($newInfo->source);
        $bootstrap->Info()->merge($newInfo);
        $this->registerPlugin($bootstrap);

        $this->setConfig($bootstrap->getName()$bootstrap->Config());

        $this->Application()->Events()->notify(
            'Shopware_Plugin_PreInstall',
            [
                'subject' => $this,
                'plugin' => $bootstrap,
            ]
        );

        $result = $bootstrap->install();

        
$event = new CheckoutOrderPlacedEvent($context$order, TestDefaults::SALES_CHANNEL);

        $subscriber = new SetOrderStateAction(
            $this->getContainer()->get(Connection::class),
            $this->getContainer()->get('logger'),
            $this->getContainer()->get(OrderService::class)
        );

        /** @var FlowFactory $flowFactory */
        $flowFactory = $this->getContainer()->get(FlowFactory::class);
        $flow = $flowFactory->create($event);
        $flow->setConfig($config);

        $subscriber->handleFlow($flow);

        $orderStateAfterAction = $this->getOrderState(Uuid::fromHexToBytes($orderId));
        static::assertSame($expects['order']$orderStateAfterAction);

        $orderDeliveryStateAfterAction = $this->getOderDeliveryState(Uuid::fromHexToBytes($orderId));
        static::assertSame($expects['order_delivery']$orderDeliveryStateAfterAction);

        $orderTransactionStateAfterAction = $this->getOrderTransactionState(Uuid::fromHexToBytes($orderId));
        static::assertSame($expects['order_transaction']$orderTransactionStateAfterAction);
    }
public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_values = $form_state->getValue(['translation', 'config_names']);

    foreach ($form_values as $name => $value) {
      $schema = $this->typedConfigManager->get($name);

      // Set configuration values based on form submission and source values.       $base_config = $this->configFactory()->getEditable($name);
      $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId()$name);

      $element = $this->createFormElement($schema);
      $element->setConfig($base_config$config_translation$value);

      // If no overrides, delete language specific configuration file.       $saved_config = $config_translation->get();
      if (empty($saved_config)) {
        $config_translation->delete();
        $this->messenger()->addStatus($this->t('@language translation was not added. To add a translation, you must modify the configuration.', ['@language' => $this->language->getName()]));
      }
      else {
        $config_translation->save();
        $this->messenger()->addStatus($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()]));
      }
    }
$this->setHttpAccept($value);
                    break;
                case 'user_agent':
                    $this->setUserAgent($value);
                    break;
                default:
                    // Cache remaining options for $_config                     $config[$key] = $value;
                    break;
            }
        }
        $this->setConfig($config);

        return $this;
    }

    /** * Comparison of the UserAgent chain and browser signatures. * * The comparison is case-insensitive : the browser signatures must be in lower * case * * @param string $deviceClass Name of class against which a match will be attempted * @return bool */
$orderRepo = $this->createMock(EntityRepository::class);
        $orderRepo->expects(static::once())
            ->method('search')
            ->willReturn($entitySearchResult);

        $awareEvent = new CheckoutOrderPlacedEvent(Context::createDefaultContext()$order, 'asdsad');

        $orderStorer = new OrderStorer($orderRepo$this->createMock(EventDispatcherInterface::class));
        $flowFactory = new FlowFactory([$orderStorer]);

        $flow = $flowFactory->create($awareEvent);
        $flow->setConfig($config);

        $stringTemplateRender = $this->createMock(StringTemplateRenderer::class);
        $stringTemplateRender->expects(static::exactly(6))
            ->method('render')
            ->willReturnOnConsecutiveCalls(
                'Text 1',
                'Text 2',
                'Text 3',
                'Text 1',
                'Text 2 and Text 3',
                'application/json'
            );
$oldDocument = $documents->get($documentIdOlder);
        static::assertInstanceOf(DocumentEntity::class$oldDocument);
        static::assertFalse($oldDocument->getSent());
        $oldDocumentOrderVersionId = $oldDocument->getOrderVersionId();

        // new version is created         static::assertNotEquals($newDocumentOrderVersionId, Defaults::LIVE_VERSION);
        static::assertNotEquals($oldDocumentOrderVersionId, Defaults::LIVE_VERSION);

        $flowFactory = $this->getContainer()->get(FlowFactory::class);
        $flow = $flowFactory->create($event);
        $flow->setConfig($config);

        $subscriber->handleFlow($flow);

        static::assertInstanceOf(FlowSendMailActionEvent::class$mailFilterEvent);
        static::assertEquals(1, $mailService->calls);
        static::assertIsArray($mailService->data);
        static::assertArrayHasKey('recipients', $mailService->data);

        switch ($recipients['type']) {
            case 'admin':
                $admin = $this->getContainer()->get(Connection::class)->fetchAssociative(
                    


  /** * {@inheritdoc} */
  public function setConfig(Config $base_config, LanguageConfigOverride $config_translation$config_values$base_key = NULL) {
    foreach ($this->element as $key => $element) {
      $element_key = isset($base_key) ? "$base_key.$key" : $key;
      if ($form_element = ConfigTranslationFormBase::createFormElement($element)) {
        // Traverse into the next level of the configuration.         $value = $config_values[$key] ?? NULL;
        $form_element->setConfig($base_config$config_translation$value$element_key);
      }
    }
  }

  /** * Returns the title for the 'details' element of a group of schema elements. * * For some configuration elements the same element structure can be repeated * multiple times (for example views displays, filters, etc.). Thus, we try to * find a more usable title for the details summary. First check if there is * an element which is called title or label and use its value. Then check if * there is an element which contains these words and use those. Fall back * to the generic definition label if no such element is found. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition * The definition of the schema element. * @param array $group_build * The renderable array for the group of schema elements. * * @return string * The title for the group of schema elements. */

    private function overwriteSlotConfig(CmsPageEntity $page, array $config): void
    {
        $sections = $page->getSections();
        if ($sections === null) {
            return;
        }

        foreach ($sections->getBlocks()->getSlots() as $slot) {
            if ($slot->getConfig() === null && $slot->getTranslation('config') !== null) {
                $slot->setConfig($slot->getTranslation('config'));
            }

            if (empty($config)) {
                continue;
            }

            if (!isset($config[$slot->getId()])) {
                continue;
            }

            $defaultConfig = $slot->getConfig() ?? [];
            

class StorableFlowTest extends TestCase
{
    private StorableFlow $storableFlow;

    protected function setUp(): void
    {
        $this->storableFlow = new StorableFlow('checkout.order.place', Context::createDefaultContext()[][]);
        $this->storableFlow->setConfig(['config' => 'value']);
    }

    public function testGetName(): void
    {
        static::assertEquals('checkout.order.place', $this->storableFlow->getName());
    }

    public function testGetContext(): void
    {
        static::assertEquals(Context::createDefaultContext()$this->storableFlow->getContext());
    }

    
'subject' => $document,
                'orderID' => $orderID,
                'documentID' => $documentID,
            ]
        );

        /** @var Shopware_Models_Document_Order $documentOrder */
        $documentOrder = Enlight_Class::Instance('Shopware_Models_Document_Order', [$orderID$config]);

        $document->setOrder($documentOrder);

        $document->setConfig($config);

        $document->setDocumentId($documentID);
        if (!empty($orderID)) {
            $document->_subshop = Shopware()->Db()->fetchRow(
                "SELECT s.id, m.document_template_id as doc_template_id, m.template_id as template_id, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.document_template_id) as doc_template, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.template_id) as template, s.id as isocode, s.locale_id as locale FROM s_order, s_core_shops s LEFT JOIN s_core_shops m ON m.id=s.main_id OR (s.main_id IS NULL AND m.id=s.id) WHERE s_order.language = s.id AND s_order.id = ?",

    public function testExecutedAction(array $config, array $existsData, array $expected): void
    {
        $customer = new CustomerEntity();
        $customer->setCustomFields($existsData);

        $context = Context::createDefaultContext();
        $customerId = Uuid::randomHex();
        $flow = new StorableFlow('', $context[][CustomerAware::CUSTOMER_ID => $customerId]);
        $flow->setConfig($config);

        $this->entitySearchResult->expects(static::once())
            ->method('first')
            ->willReturn($customer);

        $this->repository->expects(static::once())
            ->method('search')
            ->willReturn($this->entitySearchResult);

        $this->connection->expects(static::once())
            ->method('fetchOne')
            

        static::assertSame('image-slider', $this->imageSliderResolver->getType());
    }

    public function testCollectWithEmptyConfig(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('image-slider');
        $slot->setConfig([]);
        $slot->setFieldConfig(new FieldConfigCollection());

        $criteriaCollection = $this->imageSliderResolver->collect($slot$resolverContext);

        static::assertNull($criteriaCollection);
    }

    public function testCollectWithStaticConfig(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        

    public function testFiltersAndPropertyWhitelist($expectations$slotConfig): void
    {
        $resolverContext = new ResolverContext(
            $this->salesChannelContext,
            new Request()
        );

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('product-listing');
        $slot->setConfig($slotConfig);
        $slot->addTranslated('config', $slotConfig);

        $this->productListingCMSElementResolver->enrich($slot$resolverContextnew ElementDataCollection());

        $request = $resolverContext->getRequest();

        foreach ($expectations as $field => $expected) {
            if ($field === ProductListingFeaturesSubscriber::PROPERTY_GROUP_IDS_REQUEST_PARAM) {
                $value = $request->request->all($field);
            } else {
                $value = $request->request->get($field, true);
            }
ImportExportProfileEntity $profile,
        array $config
    ): ImportExportLogEntity {
        $logEntity = new ImportExportLogEntity();
        $logEntity->setId(Uuid::randomHex());
        $logEntity->setActivity($activity);
        $logEntity->setState(Progress::STATE_PROGRESS);
        $logEntity->setProfileId($profile->getId());
        $logEntity->setProfileName($profile->getTranslation('label'));
        $logEntity->setFileId($file->getId());
        $logEntity->setRecords(0);
        $logEntity->setConfig($this->getConfig($profile$config));

        $contextSource = $context->getSource();
        $userId = $contextSource instanceof AdminApiSource ? $contextSource->getUserId() : null;
        if ($userId !== null) {
            $logEntity->setUsername($this->findUser($context$userId)->getUsername());
            $logEntity->setUserId($userId);
        }

        $context->scope(Context::SYSTEM_SCOPE, function DContext $context) use ($logEntity): void {
            $logData = array_filter($logEntity->jsonSerialize()fn ($value) => $value !== null);
            $this->logRepository->create([$logData]$context);
        });
Home | Imprint | This part of the site doesn't use cookies.