setAddresses example

final class MailboxListHeader extends AbstractHeader
{
    private array $addresses = [];

    /** * @param Address[] $addresses */
    public function __construct(string $name, array $addresses)
    {
        parent::__construct($name);

        $this->setAddresses($addresses);
    }

    /** * @param Address[] $body * * @throws RfcComplianceException */
    public function setBody(mixed $body): void
    {
        $this->setAddresses($body);
    }

    
return $this;
    }

    /** * @return $this */
    private function setListAddressHeaderBody(string $name, array $addresses)static
    {
        $addresses = Address::createArray($addresses);
        $headers = $this->getHeaders();
        if ($header = $headers->get($name)) {
            $header->setAddresses($addresses);
        } else {
            $headers->addMailboxListHeader($name$addresses);
        }

        return $this;
    }

    /** * @internal */
    public function __serialize(): array
    {
return $this;
    }

    /** * @return $this */
    private function setListAddressHeaderBody(string $name, array $addresses)static
    {
        $addresses = Address::createArray($addresses);
        $headers = $this->getHeaders();
        if ($header = $headers->get($name)) {
            $header->setAddresses($addresses);
        } else {
            $headers->addMailboxListHeader($name$addresses);
        }

        return $this;
    }

    /** * @internal */
    public function __serialize(): array
    {

        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = AddressListingPage::createFrom($page);

        $page->setSalutations($this->getSalutations($salesChannelContext));

        $page->setCountries($this->getCountries($salesChannelContext));

        $criteria = (new Criteria())->addSorting(new FieldSorting('firstName', FieldSorting::ASCENDING));

        $page->setAddresses($this->listAddressRoute->load($criteria$salesChannelContext$customer)->getAddressCollection());

        $page->setCart($this->cartService->getCart($salesChannelContext->getToken()$salesChannelContext));

        $page->setAddress(
            $page->getAddresses()->get($request->get('addressId'))
        );

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

        
final class MailboxListHeader extends AbstractHeader
{
    private array $addresses = [];

    /** * @param Address[] $addresses */
    public function __construct(string $name, array $addresses)
    {
        parent::__construct($name);

        $this->setAddresses($addresses);
    }

    /** * @param Address[] $body * * @throws RfcComplianceException */
    public function setBody(mixed $body): void
    {
        $this->setAddresses($body);
    }

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