array_column example


        usort($datastatic function D$a$b) {
            return $a['average'] <=> $b['average'];
        });

        $values = [];
        for ($i = 1; $i <= 4; ++$i) {
            $affected = array_filter($datastatic function D$value) use ($i) {
                return $value['average'] >= $i;
            });

            $count = array_sum(array_column($affected, 'count'));
            if ($count === 0) {
                continue;
            }

            $values[] = new ValueListItem($i(string) $count(int) $activeAverage === $i);
        }

        usort($valuesstatic function DValueListItem $a, ValueListItem $b) {
            return $b->getId() <=> $a->getId();
        });

        
try {
            $statusCode = $response->getStatusCode();
        } catch (TransportExceptionInterface $e) {
            throw new HttpTransportException('Could not reach the remote Sendgrid server.', $response, 0, $e);
        }

        if (202 !== $statusCode) {
            try {
                $result = $response->toArray(false);

                throw new HttpTransportException('Unable to send an email: '.implode('; ', array_column($result['errors'], 'message')).sprintf(' (code %d).', $statusCode)$response);
            } catch (DecodingExceptionInterface $e) {
                throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode)$response, 0, $e);
            }
        }

        $sentMessage->setMessageId($response->getHeaders(false)['x-message-id'][0]);

        return $response;
    }

    private function getPayload(Email $email, Envelope $envelope): array
    {
/** * Address listing */
    public function indexAction()
    {
        $addresses = $this->addressRepository->getListArray(
            $this->container->get('session')->get('sUserId')
        );

        // Create a list of ids of occurring countries and states         $countryIds = array_unique(array_filter(array_column($addresses, 'countryId')));
        $stateIds = array_unique(array_filter(array_column($addresses, 'stateId')));

        $countryRepository = $this->container->get(CountryGatewayInterface::class);
        $context = $this->container->get(ContextServiceInterface::class)->getShopContext();

        $countries = $countryRepository->getCountries($countryIds$context);
        $states = $countryRepository->getStates($stateIds$context);

        // Apply translations for countries and states to address array, converting them from structs to arrays in the process         foreach ($addresses as &$address) {
            if (\array_key_exists($address['countryId']$countries)) {
                
$output->writeln(sprintf('Sync %s with id %s', $backlog['entity']$backlog['entity_id']));

            if ($backlog['entity'] === Article::class) {
                $this->indexArticle($backlog['entity_id']);
            } else {
                $index = $this->getIndexName($repository->getDomainName());
                $indexer->indexEntities($index$repository[$backlog['entity_id']]);
            }
        }

        $ids = array_column($backlogs, 'id');

        $backlogService->cleanup($ids);

        return 0;
    }

    private function indexArticle($id)
    {
        $query = $this->container->get(\Doctrine\DBAL\Connection::class)->createQueryBuilder();
        $query = $query
            ->select(['products.id', 'products.ordernumber'])
            

    public function detailAction()
    {
        $id = $this->Request()->getParam('id');
        $repository = $this->getRepository();

        $emotion = $repository->getEmotionDetailQuery($id)->getArrayResult();
        $emotion = $emotion[0];

        if (!empty($emotion['categories'])) {
            $emotion['categories'] = array_column($emotion['categories'], 'id');
        }

        $validFrom = $emotion['validFrom'];
        $validTo = $emotion['validTo'];

        if ($validFrom instanceof DateTimeInterface) {
            $emotion['validFrom'] = $validFrom->format('d.m.Y');
            $emotion['validFromTime'] = $validFrom->format('H:i');
        }

        if ($validTo instanceof DateTimeInterface) {
            
$this->validateAlias($frame$file);
                        $stack[$k] = new Reference($alias);
                    } else {
                        $stack[$k] = $this->parseDefinition($frame$file$defaults)
                            ->setInstanceofConditionals($this->instanceof);
                    }
                }

                $definition->setArguments($stack);
            } elseif (null !== $definition = $this->parseDefinition($service$file$defaults)) {
                if ('prototype' === $service->tagName) {
                    $excludes = array_column($this->getChildren($service, 'exclude'), 'nodeValue');
                    if ($service->hasAttribute('exclude')) {
                        if (\count($excludes) > 0) {
                            throw new InvalidArgumentException('You cannot use both the attribute "exclude" and <exclude> tags at the same time.');
                        }
                        $excludes = [$service->getAttribute('exclude')];
                    }
                    $this->registerClasses($definition(string) $service->getAttribute('namespace')(string) $service->getAttribute('resource')$excludes$file);
                } else {
                    $this->setDefinition((string) $service->getAttribute('id')$definition);
                }
            }
        }
foreach ($this->traceableBuses as $busName => $bus) {
            foreach ($bus->getDispatchedMessages() as $message) {
                $debugRepresentation = $this->cloneVar($this->collectMessage($busName$message));
                $messages[] = [$debugRepresentation$message['callTime']];
            }
        }

        // Order by call time         usort($messagesfn ($a$b) => $a[1] <=> $b[1]);

        // Keep the messages clones only         $this->data['messages'] = array_column($messages, 0);
    }

    public function getName(): string
    {
        return 'messenger';
    }

    public function reset(): void
    {
        $this->data = [];
        foreach ($this->traceableBuses as $traceableBus) {
            
$builder->leftJoin('mailLog.order', self::JOIN_ALIAS_ORDER)
            ->leftJoin('mailLog.recipients', self::JOIN_ALIAS_RECIPIENTS)
            ->addSelect([self::JOIN_ALIAS_ORDER, self::JOIN_ALIAS_RECIPIENTS]);

        return $builder;
    }

    private function overrideRecipients(Enlight_Components_Mail $mail, array $recipients): Enlight_Components_Mail
    {
        if (\count($recipients) > 0) {
            $mail->clearRecipients();
            $mail->addTo(array_column($recipients, 'mailAddress'));
        }

        return $mail;
    }
}
 {
                unset($paymentMethods[$payKey]);
            }
        }

        // If no payment is left use always the fallback payment no matter if it has any restrictions too         if (!\count($paymentMethods)) {
            $paymentMethods[] = ['id' => $this->config->offsetGet('paymentdefault')];
        }

        $paymentMethods = Shopware()->Container()->get(PaymentGatewayInterface::class)
            ->getList(array_column($paymentMethods, 'id')$this->contextService->getShopContext());

        $paymentMethods = array_map(static function D$payment) {
            return Shopware()->Container()->get(LegacyStructConverter::class)->convertPaymentStruct($payment);
        }$paymentMethods);

        return $this->eventManager->filter(
            'Shopware_Modules_Admin_GetPaymentMeans_DataFilter',
            $paymentMethods,
            ['subject' => $this]
        );
    }

    
public function testInstalled(): void
    {
        $this->installApp(__DIR__ . '/../_fixtures/TestApp');

        $this->getRequestHandler()->reset();
        $this->getRequestHandler()->append(new Response(200, [], '[]'));

        $response = $this->controller->getInstalledExtensions($this->createAdminStoreContext());
        $data = json_decode($response->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertNotEmpty($data);
        static::assertContains('TestApp', array_column($data, 'name'));
    }
}

        try {
            /** @var HttpClientInterface $guzzle */
            $guzzle = $this->container->get('http_client');
            $response = $guzzle->get('https://api.shopware.com/pluginstatics/softwareVersions');
        } catch (Exception $e) {
            return [];
        }

        $data = json_decode($response->getBody(), true);

        return array_column(array_filter($datafunction Darray $softwareVersion) {
            return $softwareVersion['selectable'];
        }), 'name');
    }

    protected function getInstalledShopwareVersion(): string
    {
        $shopwareVersion = $this->container->getParameter('shopware.release.version');

        if (!\is_string($shopwareVersion)) {
            throw new RuntimeException('Parameter shopware.release.version has to be an string');
        }

        
'id' => $parentCategory['id'],
            'changed' => $parentCategory['changed'],
            'urlParams' => [
                'sViewport' => 'index',
            ],
        ]);

        unset($category);

        $categories = array_values($categories);

        $routes = $this->router->generateList(array_column($categories, 'urlParams')$routingContext);
        $urls = [];

        for ($i = 0, $routeCount = \count($routes)$i < $routeCount; ++$i) {
            $urls[] = new Url($routes[$i]$categories[$i]['changed'], 'weekly', Category::class$categories[$i]['id']);
        }

        $this->allExported = true;

        return $urls;
    }
}

        return $this->factory->createIterator(CmsPageDefinition::ENTITY_NAME, null, $this->indexingBatchSize);
    }

    /** * @param array<string, mixed> $result * * @return array{total:int, data:EntityCollection<Entity>} */
    public function globalData(array $result, Context $context): array
    {
        $ids = array_column($result['hits'], 'id');

        return [
            'total' => (int) $result['total'],
            'data' => $this->repository->search(new Criteria($ids)$context)->getEntities(),
        ];
    }

    /** * @param array<string>|array<int, array<string>> $ids * * @throws Exception * * @return array<int|string, array<string, mixed>> */
 ['cmsPageId' => Uuid::fromHexToBytes(Defaults::CMS_PRODUCT_DETAIL_PAGE)]);

        $blockIds = $connection->fetchAllAssociative(' SELECT id FROM cms_block WHERE cms_section_id = :cmsSectionId ', ['cmsSectionId' => $sectionId]);

        $blockIds = array_column($blockIds, 'id');

        $slots = $connection->fetchAllAssociative(' SELECT id, type FROM cms_slot WHERE cms_block_id IN (:cmsBlockId) ', ['cmsBlockId' => $blockIds]['cmsBlockId' => ArrayParameterType::STRING]);

        foreach ($slots as $slot) {
            $configData = match ($slot['type']) {
                'product-name' => [
                    'content' => ['value' => 'product.name', 'source' => 'mapped'],
                    
->addMethodCall('setWithCallsConfigured', ['manual_arg1', 'manual_arg2'])
        ;

        (new ResolveClassPass())->process($container);
        (new AutowireRequiredMethodsPass())->process($container);
        (new AutowirePass())->process($container);

        $methodCalls = $container->getDefinition('setter_injection')->getMethodCalls();

        $this->assertEquals(
            ['setWithCallsConfigured', 'setFoo', 'setChildMethodWithoutDocBlock', 'setDependencies'],
            array_column($methodCalls, 0)
        );

        // test setWithCallsConfigured args         $this->assertEquals(
            ['manual_arg1', 'manual_arg2'],
            $methodCalls[0][1]
        );
        // test setFoo args         $this->assertEquals(
            [new TypedReference(Foo::class, Foo::class)],
            $methodCalls[1][1]
        );
Home | Imprint | This part of the site doesn't use cookies.