getGroup example

$this->pluginDefinition['provider'] = 'Breakpoint';
    $this->setupBreakpoint();
    $this->assertEquals('Breakpoint', $this->breakpoint->getProvider());
  }

  /** * @covers ::getGroup */
  public function testGetGroup() {
    $this->pluginDefinition['group'] = 'Breakpoint';
    $this->setupBreakpoint();
    $this->assertEquals('Breakpoint', $this->breakpoint->getGroup());
  }

}
if (!$constraint instanceof Valid) {
            throw new UnexpectedTypeException($constraint, Valid::class);
        }

        if (null === $value) {
            return;
        }

        $this->context
            ->getValidator()
            ->inContext($this->context)
            ->validate($value, null, $this->context->getGroup());
    }
}
if (!$customer->getPaymentId()) {
            $customer->setPaymentId($this->config->get('defaultPayment'));
        }

        $subShop = $this->modelManager->find(ShopModel::class$shop->getId());
        if (!$subShop instanceof ShopModel) {
            throw new ModelNotFoundException(ShopModel::class$shop->getId());
        }
        $customer->setLanguageSubShop($subShop);

        if ($customer->getGroup() === null) {
            $customerGroup = $this->modelManager->find(Group::class$subShop->getCustomerGroup()->getId());
            if (!$customerGroup instanceof Group) {
                throw new ModelNotFoundException(Group::class$subShop->getCustomerGroup()->getId());
            }
            $customer->setGroup($customerGroup);
        }

        if ($customer->getAffiliate()) {
            $customer->setAffiliate((int) $this->getPartnerId($customer));
        } else {
            $customer->setAffiliate(0);
        }
$optionIds = explode('|', trim($variation['options'], '|'));

        $options = $this->get('models')
            ->getRepository(Article::class)
            ->getAllConfiguratorOptionsIndexedByIdQuery(['options.id' => $optionIds])
            ->getResult();

        $variation['option_names'] = [];

        foreach ($options as $option) {
            $variation['option_names'][] = [
                'group' => $option->getGroup()->getName(),
                'option' => $option->getName(),
            ];
        }

        unset($variation['options']);

        return $variation;
    }

    /** * Coverts a Price Variation's options from detailed options into the squashed array * * @param array $variation * * @return array */

    public function isOrderStateMail()
    {
        if ($this->getMailtype() != self::MAILTYPE_STATE) {
            return false;
        }

        if ($this->getStatus() === null) {
            return false;
        }

        return $this->getStatus()->getGroup() === 'state';
    }

    /** * Returns whether or not this is a paymentstate-mail * * @return bool */
    public function isPaymentStateMail()
    {
        if ($this->getMailtype() != self::MAILTYPE_STATE) {
            return false;
        }
$attached_assets->setLibraries(explode(',', $include_string));

    if ($request->query->has('exclude')) {
      $exclude_string = UrlHelper::uncompressQueryParameter($request->query->get('exclude'));
      if (!$exclude_string) {
        throw new BadRequestHttpException('The libraries to exclude are encoded incorrectly.');
      }
      $attached_assets->setAlreadyLoadedLibraries(explode(',', $exclude_string));
    }
    $groups = $this->getGroups($attached_assets$request);

    $group = $this->getGroup($groups$request->query->get('delta'));
    // Generate a hash based on the asset group, this uses the same method as     // the collection optimizer does to create the filename, so it should match.     $generated_hash = $this->generateHash($group);
    $data = $this->optimizer->optimizeGroup($group);

    // However, the hash from the library definitions in code may not match the     // hash from the URL. This can be for three reasons:     // 1. Someone has requested an outdated URL, i.e. from a cached page, which     // matches a different version of the code base.     // 2. Someone has requested an outdated URL during a deployment. This is     // the same case as #1 but a much shorter window.
'name' => 'foo',
                'registrationActive' => true,
                'registrationTitle' => 'test',
                'registrationSalesChannels' => [['id' => $this->salesChannel->getSalesChannel()->getId()]],
            ],
        ], Context::createDefaultContext());

        $request = new Request();
        $request->attributes->set('customerGroupId', $this->ids->get('group'));

        $page = $this->getPageLoader()->load($request$this->salesChannel);
        static::assertSame($this->ids->get('group')$page->getGroup()->getId());
        static::assertSame('test', $page->getGroup()->getRegistrationTitle());
    }

    protected function getPageLoader(): CustomerGroupRegistrationPageLoader
    {
        return $this->getContainer()->get(CustomerGroupRegistrationPageLoader::class);
    }
}
public function load(Request $request, SalesChannelContext $salesChannelContext): CustomerGroupRegistrationPage
    {
        $page = CustomerGroupRegistrationPage::createFrom($this->accountLoginPageLoader->load($request$salesChannelContext));
        $customerGroupId = $request->attributes->get('customerGroupId');

        $page->setGroup(
            $this->customerGroupRegistrationRoute->load($customerGroupId$salesChannelContext)->getRegistration()
        );

        if ($page->getMetaInformation()) {
            $metaDescription = $page->getGroup()->getTranslation('registrationSeoMetaDescription');
            if ($metaDescription) {
                $page->getMetaInformation()->setMetaDescription($metaDescription);
            }

            $title = $page->getGroup()->getTranslation('registrationTitle');
            if ($title) {
                $page->getMetaInformation()->setMetaTitle($title);
            }
        }

        $this->eventDispatcher->dispatch(new CustomerGroupRegistrationPageLoadedEvent($page$salesChannelContext$request));

        


        if (null !== $constraint->divisibleBy) {
            $this->context
                ->getValidator()
                ->inContext($this->context)
                ->validate($count[
                    new DivisibleBy([
                        'value' => $constraint->divisibleBy,
                        'message' => $constraint->divisibleByMessage,
                    ]),
                ]$this->context->getGroup());
        }
    }
}

        $groups = new PropertyGroupCollection();

        foreach ($this->getIterator() as $element) {
            if (!$element->getOption()) {
                continue;
            }

            if ($groups->has($element->getOption()->getGroupId())) {
                $group = $groups->get($element->getOption()->getGroupId());
            } else {
                $group = PropertyGroupEntity::createFrom($element->getOption()->getGroup() ?? new PropertyGroupEntity());

                $groups->add($group);

                $group->setOptions(new PropertyGroupOptionCollection());
            }

            if ($group->getOptions()) {
                $group->getOptions()->add($element->getOption());
            }
        }

        
$preferredLabels
        );
    }

    public function testCreateViewFlatPreferredChoiceGroupsSameOrder()
    {
        $view = $this->factory->createView(
            $this->list,
            [$this->obj4, $this->obj2, $this->obj1, $this->obj3],
            null, // label             null, // index             $this->getGroup(...)
        );

        $preferredLabels = array_map(static fn (ChoiceGroupView $groupView): array => array_map(static fn (ChoiceView $view): string => $view->label, $groupView->choices)$view->preferredChoices);

        $this->assertEquals(
            [
                'Group 2' => [
                    2 => 'C',
                    3 => 'D',
                ],
                'Group 1' => [
                    
private array $objectInitializers;

    /** * Creates a validator for the given context. * * @param ObjectInitializerInterface[] $objectInitializers The object initializers */
    public function __construct(ExecutionContextInterface $context, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = [])
    {
        $this->context = $context;
        $this->defaultPropertyPath = $context->getPropertyPath();
        $this->defaultGroups = [$context->getGroup() ?: Constraint::DEFAULT_GROUP];
        $this->metadataFactory = $metadataFactory;
        $this->validatorFactory = $validatorFactory;
        $this->objectInitializers = $objectInitializers;
    }

    public function atPath(string $path)static
    {
        $this->defaultPropertyPath = $this->context->getPropertyPath($path);

        return $this;
    }

    


        $validator = $this->context->getValidator();

        // Build a first violation to have the base message of the constraint translated         $baseMessageContext = clone $this->context;
        $baseMessageContext->buildViolation($constraint->message)->addViolation();
        $baseViolations = $baseMessageContext->getViolations();
        $messages = [(string) $baseViolations->get(\count($baseViolations) - 1)->getMessage()];

        foreach ($constraint->constraints as $key => $item) {
            if (!\in_array($this->context->getGroup()$item->groups, true)) {
                continue;
            }

            $executionContext = clone $this->context;
            $executionContext->setNode($value$this->context->getObject()$this->context->getMetadata()$this->context->getPropertyPath());
            $violations = $validator->inContext($executionContext)->validate($value$item$this->context->getGroup())->getViolations();

            if (\count($this->context->getViolations()) === \count($violations)) {
                return;
            }

            
return $this->redirectToRoute('frontend.account.logout.page');
        }

        if ($context->getCustomer()) {
            return $this->redirectToRoute('frontend.account.home.page');
        }

        $redirect = $request->query->get('redirectTo', 'frontend.account.home.page');

        $page = $this->customerGroupRegistrationPageLoader->load($request$context);

        if ($page->getGroup()->getTranslation('registrationOnlyCompanyRegistration')) {
            $data->set('accountType', CustomerEntity::ACCOUNT_TYPE_BUSINESS);
        }

        $this->hook(new CustomerGroupRegistrationPageLoadedHook($page$context));

        return $this->renderStorefront('@Storefront/storefront/page/account/customer-group-register/index.html.twig', [
            'redirectTo' => $redirect,
            'redirectParameters' => $request->get('redirectParameters', json_encode([])),
            'errorRoute' => $request->attributes->get('_route'),
            'errorParameters' => json_encode(['customerGroupId' => $customerGroupId], \JSON_THROW_ON_ERROR),
            'page' => $page,
            
return $this->fmap(fn (CustomerEntity $customer) => $customer->getDefaultShippingAddressId());
    }

    public function filterByDefaultShippingAddressId(string $id): self
    {
        return $this->filter(fn (CustomerEntity $customer) => $customer->getDefaultShippingAddressId() === $id);
    }

    public function getGroups(): CustomerGroupCollection
    {
        return new CustomerGroupCollection(
            $this->fmap(fn (CustomerEntity $customer) => $customer->getGroup())
        );
    }

    public function getDefaultPaymentMethods(): PaymentMethodCollection
    {
        return new PaymentMethodCollection(
            $this->fmap(fn (CustomerEntity $customer) => $customer->getDefaultPaymentMethod())
        );
    }

    public function getSalesChannels(): SalesChannelCollection
    {
Home | Imprint | This part of the site doesn't use cookies.