getActive example


    public function convertConfiguratorOptionStruct(Group $group, Option $option)
    {
        $data = [
            'optionID' => $option->getId(),
            'groupID' => $group->getId(),
            'optionname' => $option->getName(),
            'user_selected' => $option->isSelected(),
            'selected' => $option->isSelected(),
            'selectable' => $option->getActive(),
            'attributes' => $option->getAttributes(),
        ];

        if ($option->getMedia()) {
            $data['media'] = $this->convertMediaStruct($option->getMedia());
        }

        if ($option->hasAttribute('core')) {
            $data['attribute'] = $option->getAttribute('core');
        }

        

        // Set icons         if ($site->getLink()) {
            $iconCls = 'sprite-chain-small';
        } else {
            $iconCls = 'sprite-blue-document-text';
        }

        // Build the structure         $node = [
            'id' => $idPrefix . $site->getId(),
            'active' => $site->getActive(),
            'text' => $site->getDescription() . '(' . $site->getId() . ')',
            'helperId' => $site->getId(),
            'iconCls' => $iconCls,
            'tpl1variable' => $site->getTpl1Variable(),
            'tpl1path' => $site->getTpl1Path(),
            'tpl2variable' => $site->getTpl2Variable(),
            'tpl2path' => $site->getTpl2Path(),
            'tpl3variable' => $site->getTpl3Variable(),
            'tpl3path' => $site->getTpl3Path(),
            'description' => $site->getDescription(),
            'pageTitle' => $site->getPageTitle(),
            
use Shopware\Core\Checkout\Cart\Error\ErrorCollection;
use Shopware\Core\Checkout\Payment\Cart\Error\PaymentMethodBlockedError;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

#[Package('checkout')] class PaymentMethodValidator implements CartValidatorInterface
{
    public function validate(Cart $cart, ErrorCollection $errors, SalesChannelContext $context): void
    {
        $paymentMethod = $context->getPaymentMethod();
        if (!$paymentMethod->getActive()) {
            $errors->add(
                new PaymentMethodBlockedError((string) $paymentMethod->getTranslation('name'), 'inactive')
            );
        }

        $ruleId = $paymentMethod->getAvailabilityRuleId();

        if ($ruleId && !\in_array($ruleId$context->getRuleIds(), true)) {
            $errors->add(
                new PaymentMethodBlockedError((string) $paymentMethod->getTranslation('name'), 'rule not matching')
            );
        }
$pluginManager = $this->container->get(InstallerService::class);
        $pluginName = $input->getArgument('plugin');

        try {
            $plugin = $pluginManager->getPluginByName($pluginName);
        } catch (Exception $e) {
            $output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));

            return 1;
        }

        if (!$plugin->getActive()) {
            $output->writeln(sprintf('The plugin %s is already deactivated.', $pluginName));

            return 1;
        }

        $deactivationContext = $pluginManager->deactivatePlugin($plugin);
        $output->writeln(sprintf('Plugin %s has been deactivated', $pluginName));

        $this->clearCachesIfRequested($input$output$deactivationContext);

        return 0;
    }
$translation = $this->get(Shopware_Components_Translation::class)->readWithFallback($shop->getId()$shop->getFallback() ? $shop->getFallback()->getId() : null, 'blog', $blogArticleId);
        $blogArticleData = array_merge($blogArticleData ?? []$translation ?? []);

        // Redirect if the blog item is not available         if (empty($blogArticleData) || empty($blogArticleData['active'])) {
            throw new Enlight_Controller_Exception(sprintf('Blog article with id %d not found or inactive', $blogArticleId), 404);
        }

        // Redirect if category is not available, inactive or external         /** @var Category|null $category */
        $category = $this->getCategoryRepository()->find($blogArticleData['categoryId']);
        if ($category === null || !$category->getActive()) {
            $location = ['controller' => 'index'];
        }

        // Redirect if blog's category is not a child of the current shop's category         $shopCategory = Shopware()->Shop()->getCategory();
        $isChild = ($shopCategory && $category) ? $category->isChildOf($shopCategory) : false;
        if (!$isChild) {
            $location = ['controller' => 'index'];
        }

        if (isset($location)) {
            

        ], Context::createDefaultContext());

        $this->login($email, 'shopware');

        /** @var CustomerEntity $customer */
        $customer = $this->customerRepository->search(
            new Criteria([$this->ids->get('customer')]),
            Context::createDefaultContext()
        )->first();

        static::assertFalse($customer->getActive());
    }

    private function login(?string $email = null, ?string $password = null): void
    {
        $this->browser
            ->request(
                'POST',
                '/store-api/account/login',
                [
                    'email' => $email,
                    'password' => $password,
                ]
if (mb_strpos($path, '|' . $rootId . '|') !== false) {
            return true;
        }

        return false;
    }

    private function addVisibilityCounts(string $rootId, int $rootLevel, int $depth, CategoryCollection $levels, SalesChannelContext $context): void
    {
        $counts = [];
        foreach ($levels as $category) {
            if (!$category->getActive() || !$category->getVisible()) {
                continue;
            }

            $parentId = $category->getParentId();
            $counts[$parentId] ??= 0;
            ++$counts[$parentId];
        }
        foreach ($levels as $category) {
            $category->setVisibleChildCount($counts[$category->getId()] ?? 0);
        }

        
static::assertSame($product->getTranslations()->first()->getName()$result['translations']['DEFAULT']['name']);
        static::assertSame((string) $product->getStock()$result['stock']);
        static::assertSame($product->getProductNumber()$result['productNumber']);
        static::assertSame('1', $result['active']);

        $result = iterator_to_array($entityPipe->out($config$result));

        static::assertSame($product->getId()$result['id']);
        static::assertSame($product->getTranslations()->first()->getName()$result['translations'][Defaults::LANGUAGE_SYSTEM]['name']);
        static::assertSame($product->getStock()$result['stock']);
        static::assertSame($product->getProductNumber()$result['productNumber']);
        static::assertSame($product->getActive()$result['active']);
    }
}

    public function setChildren($children)
    {
        $this->children = $children;
    }

    /** * @return bool */
    public function isVisible()
    {
        return $this->getActive();
    }

    /** * @return bool */
    public function hasChildren()
    {
        return \count($this->getChildren()) > 0;
    }

    /** * @return Plugin|null */
foreach ($compatibilities as $compatibility) {
            $skip = $compatibility['statusName'] === self::PLUGIN_COMPATIBILITY_COMPATIBLE
                || $compatibility['statusName'] === self::PLUGIN_COMPATIBILITY_NOT_IN_STORE;

            if ($deactivationFilter !== self::PLUGIN_DEACTIVATION_FILTER_ALL && $skip) {
                continue;
            }

            $extension = $extensions->get($compatibility['name']);

            if ($extension && $extension->getActive()) {
                $extensionsToDeactivate[] = $extension;
            }
        }

        return $extensionsToDeactivate;
    }

    private function fetchActiveExtensions(Context $context): ExtensionCollection
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('active', 1));

        


    /** * {@inheritdoc} */
    public function updateJob(Enlight_Components_Cron_Job $job)
    {
        $data = [];
        $data['action'] = $job->getAction();
        $data[$this->connection->quoteIdentifier('interval')] = $job->getInterval();
        $data['data'] = serialize($job->getData());
        $data['active'] = $job->getActive() ? '1' : '0';
        $data['next'] = $job->getNext() ? $job->getNext()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['start'] = $job->getStart() ? $job->getStart()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['end'] = $job->getEnd() ? $job->getEnd()->toString('YYYY-MM-dd HH:mm:ss') : null;
        $data['disable_on_error'] = $job->getDisableOnError() ? '1' : '0';
        $data['name'] = $job->getName();

        if ($job->getId() === null) {
            $this->connection->insert($this->tableName, $data);
        } else {
            $this->connection->update(
                $this->tableName,
                
$languages = $salesChannel->getLanguages();
            /** @var CurrencyEntity $currency */
            $currency = $salesChannel->getCurrency();
            /** @var CurrencyCollection $currencies */
            $currencies = $salesChannel->getCurrencies();
            /** @var SalesChannelDomainCollection $domains */
            $domains = $salesChannel->getDomains();

            $data[] = [
                $salesChannel->getId(),
                $salesChannel->getName(),
                $salesChannel->getActive() ? 'active' : 'inactive',
                $salesChannel->isMaintenance() ? 'on' : 'off',
                $language->getName(),
                $languages->map(fn (LanguageEntity $language) => $language->getName()),
                $currency->getName(),
                $currencies->map(fn (CurrencyEntity $currency) => $currency->getName()),
                $domains->map(fn (SalesChannelDomainEntity $domain) => $domain->getUrl()),
            ];
        }

        if ($input->getOption('output') === 'json') {
            return $this->renderJson($output$headers$data);
        }

        }

        foreach ($mappedExtensions as $storeExtension) {
            if ($storeExtension->getType() !== ExtensionStruct::EXTENSION_TYPE_PLUGIN) {
                continue;
            }

            /** @var PluginEntity|null $plugin */
            $plugin = $pluginCollection->filterByProperty('name', $storeExtension->getName())->first();
            $storeExtension->assign([
                'active' => $plugin ? $plugin->getActive() : false,
                'installed' => $plugin ? ((bool) $plugin->getInstalledAt()) : false,
            ]);
        }

        foreach ($mappedExtensions as $storeExtension) {
            if ($storeExtension->getType() !== ExtensionStruct::EXTENSION_TYPE_APP) {
                continue;
            }

            /** @var AppEntity|null $app */
            $app = $appCollection->filterByProperty('name', $storeExtension->getName())->first();

            
/** * Tests retrieving active variants. * * @covers ::getActive * @covers ::getActiveMultiple */
  public function testGetActive() {
    $en_contexts = $this->getLanguageContexts('en');

    // Check that when the entity does not exist NULL is returned.     $entity_type_id = 'entity_test';
    $active = $this->entityRepository->getActive($entity_type_id, -1);
    $this->assertNull($active);

    // Check that the correct active variant is returned for a non-translatable,     // non-revisionable entity.     /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
    $storage = $this->entityTypeManager->getStorage($entity_type_id);
    $values = ['name' => $this->randomString()];
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $entity = $storage->create($values);
    $storage->save($entity);
    $entity = $storage->load($entity->id());
    

        $this->container->load('table');

        /** @var Enlight_Components_Cron_Manager $manager */
        $manager = $this->container->get('cron');
        $rows = [];

        foreach ($manager->getAllJobs() as $job) {
            $rows[] = [
                $job->getName(),
                $job->getAction(),
                $job->getActive() ? 'Yes' : 'No',
                $job->getInterval(),
                $job->getNext(),
                $job->getEnd(),
            ];
        }

        $table = new Table($output);
        $table->setHeaders(['Name', 'Action', 'Active', 'Interval', 'Next run', 'Last run'])
              ->setRows($rows);

        $table->render();

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