setFormat example

$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
    $this->assertEquals('application/json', $response->headers->get('Content-type'));
    $this->assertEquals('{"message":"No route found for \\u0022GET http:\/\/localhost\\/not-found\\u0022"}', $response->getContent());
  }

  /** * Tests the exception handling for HTML and 403 status code. */
  public function testHtml403() {
    $request = Request::create('/router_test/test15');
    $request->setFormat('html', ['text/html']);

    /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $kernel */
    $kernel = \Drupal::getContainer()->get('http_kernel');
    $response = $kernel->handle($request)->prepare($request);

    $this->assertEquals(Response::HTTP_FORBIDDEN, $response->getStatusCode());
    $this->assertEquals('text/html; charset=UTF-8', $response->headers->get('Content-type'));
  }

  /** * Tests the exception handling for HTML and 404 status code. */
if ($active) {
                    $provider = $urlProviderFactory->getProvider($resource);
                    $urls = array_merge($urls$provider->getUrls($context));
                    $totalResultCount += $provider->getCount($context);
                }
            }

            // Progressbar             $progressBar = $io->createProgressBar($totalResultCount);
            $io->writeln(sprintf("\nShop '%s' (ID: %s)", $shop->getName()$shop->getId()));
            $progressBar->setBarWidth(100);
            $progressBar->setFormat('very_verbose');
            $progressBar->start();

            // Warm URL-List             while ($offset < $totalResultCount) {
                $sliceUrls = \array_slice($urls$offset$limit, true);
                $cacheWarmer->warmUpUrls($sliceUrls$context$concurrentRequests);

                $sliceCount = \count($sliceUrls);
                if ($sliceCount === 0) {
                    break;
                }
                
if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        }

        if (is_array($options)) {
            // Received             if (array_key_exists('locale', $options)) {
                $this->setLocale($options['locale']);
            }

            if (array_key_exists('format', $options)) {
                $this->setFormat($options['format']);
            }
        } elseif ($options instanceof Zend_Locale || is_string($options)) {
            // Received Locale object or string locale             $this->setLocale($options);
        }

        $format = $this->getFormat();
        if (empty($format)) {
            throw new Zend_Validate_Exception("A postcode-format string has to be given for validation");
        }
    }

    

  public function __construct(HttpKernelInterface $app) {
    $this->app = $app;
  }

  /** * {@inheritdoc} */
  public function handle(Request $request$type = self::MAIN_REQUEST, $catch = TRUE): Response {
    // Register available mime types.     foreach ($this->formats as $format => $mime_type) {
      $request->setFormat($format$mime_type);
    }

    // Determine the request format using the negotiator.     if ($requested_format = $this->getContentType($request)) {
      $request->setRequestFormat($requested_format);
    }
    return $this->app->handle($request$type$catch);
  }

  /** * Registers a format for a given MIME type. * * @param string $format * The format. * @param string $mime_type * The MIME type. * * @return $this */
/** * Sets node's value * * @param string $value Value * * @return $this */
    public function setValue($value)
    {
        $this->value = (string) $value;
        //Force recalculation of the raw value         return $this->setFormat($this->format);
    }
    
    /** * Sets node's raw value * * @param mixed $raw Raw value * * @return $this * * @throws \Exception */
    
$style->info('Finished setting visibility of objects in all pre-defined buckets.');

        return Command::SUCCESS;
    }

    private function setVisibility(FilesystemOperator $filesystem, ShopwareStyle $style, string $visibility): void
    {
        $files = array_filter($filesystem->listContents('/', true)->toArray()fn (StorageAttributes $object): bool => $object->type() === 'file');
        ProgressBar::setFormatDefinition('custom', '[%bar%] %current%/%max% -- %message%');
        $progressBar = new ProgressBar($style, \count((array) $files));
        $progressBar->setFormat('custom');
        $progressBar->setMessage('');

        foreach ($files as $file) {
            $filesystem->setVisibility($file->path()$visibility);

            $progressBar->advance();
            $progressBar->setMessage($file->path());
        }

        $progressBar->finish();
    }
}
$this->io = new ShopwareStyle($input$output);

        $keys = $this->redis->keys(RedisCartPersister::PREFIX . '*');
        \assert(\is_array($keys));

        if (empty($keys)) {
            $this->io->success('No carts found in Redis');

            return 0;
        }
        $this->progress = $this->io->createProgressBar(\count($keys));
        $this->progress->setFormat("<info>[%message%]</info>\n%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%");
        $this->progress->setMessage('Migrating carts from Redis to SQL');

        $queue = new MultiInsertQueryQueue($this->connection, 50, false, true);

        // @deprecated tag:v6.6.0 - payload always exists         $payloadExists = EntityDefinitionQueryHelper::columnExists($this->connection, 'cart', 'payload');

        foreach ($keys as $index => $key) {
            if (\method_exists($this->redis, '_prefix')) {
                $key = \substr((string) $key, \strlen($this->redis->_prefix('')));
            }

            
 else if (!is_array($options)) {
            $options = func_get_args();
            $temp['format'] = array_shift($options);
            if (!empty($options)) {
                $temp['locale'] = array_shift($options);
            }

            $options = $temp;
        }

        if (array_key_exists('format', $options)) {
            $this->setFormat($options['format']);
        }

        if (array_key_exists('locale', $options)) {
            $this->setLocale($options['locale']);
        }
    }

    /** * Returns the locale option * * @return string|Zend_Locale|null */

    }

    require_once 'core/includes/install.core.inc';

    $progress_bar = $io->createProgressBar();
    install_drupal($class_loader$parametersfunction D$install_state) use ($progress_bar) {
      static $started = FALSE;
      if (!$started) {
        $started = TRUE;
        // We've already done 1.         $progress_bar->setFormat("%current%/%max% [%bar%]\n%message%\n");
        $progress_bar->setMessage(t('Installing @drupal', ['@drupal' => drupal_install_profile_distribution_name()]));
        $tasks = install_tasks($install_state);
        $progress_bar->start(count($tasks) + 1);
      }
      $tasks_to_perform = install_tasks_to_perform($install_state);
      $task = current($tasks_to_perform);
      if (isset($task['display_name'])) {
        $progress_bar->setMessage($task['display_name']);
      }
      $progress_bar->advance();
    });
    


  /** * Tests that handle() correctly hands off to sub application. * * @covers ::handle */
  public function testHandle() {
    $request = $this->prophesize(Request::class);

    // Default empty format list should not set any formats.     $request->setFormat()->shouldNotBeCalled();

    // Request format will be set with default format.     $request->setRequestFormat()->shouldNotBeCalled();

    // Some getContentType calls we don't really care about but have to mock.     $request_data = $this->prophesize(ParameterBag::class);
    $request_data->get('ajax_iframe_upload', FALSE)->willReturn(FALSE)->shouldBeCalled();
    $request_mock = $request->reveal();
    $request_mock->query = new ParameterBag([]);
    $request_mock->request = $request_data->reveal();

    

    public function __construct($options = null, $locale = null)
    {
        $calloptions = $options;
        if (is_array($options) && isset($options['display'])) {
            $this->_options['display'] = $options['display'];
        }

        if (is_array($options)) {
            $this->setLocale($locale);
            $this->setFormat($options);
        } else if (Zend_Locale::isLocale($options, false, false)) {
            $this->setLocale($options);
            $options = $locale;
        } else {
            $this->setLocale($locale);
        }

        // Get currency details         if (!isset($this->_options['currency']) || !is_array($options)) {
            $this->_options['currency'] = self::getShortName($options$this->_options['locale']);
        }

        

        $output->writeln(' // Migrating all media files in your filesystem. This might take some time, depending on the number of media files you have.');
        $output->writeln('');

        $filesToMigrate = 0;

        if (!$skipScan) {
            $filesToMigrate = $this->countFilesToMigrate('media', $fromFilesystem);
        }

        $progressBar = new ProgressBar($output$filesToMigrate);
        $progressBar->setFormat(" %current%/%max% [%bar%] %percent%%, %migrated% migrated, %skipped% skipped, %moved% moved, Elapsed: %elapsed%\n Current file: %filename%");
        $progressBar->setMessage('', 'filename');
        $this->migrateFilesIn('media', $fromFilesystem$toFileSystem$progressBar);
        $progressBar->finish();

        $rows = [];
        foreach ($this->counter as $key => $value) {
            $rows[] = [$key$value];
        }

        $output->writeln('');
        $output->writeln('');

        
ProgressFinishedEvent::NAME => 'finishProgress',
        ];
    }

    public function startProgress(ProgressStartedEvent $event): void
    {
        if (!$this->io) {
            return;
        }

        $this->progress = $this->io->createProgressBar($event->getTotal());
        $this->progress->setFormat("<info>[%message%]</info>\n%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%");
        $this->progress->setMessage($event->getMessage());
    }

    public function advanceProgress(ProgressAdvancedEvent $event): void
    {
        if (!$this->progress) {
            return;
        }

        $this->progress->advance($event->getStep());
    }

    
/** * {@inheritdoc} */
    public function start($count$label = '')
    {
        $this->count = $count;
        $this->current = 0;
        if ($label) {
            $this->output->writeln($label);
        }
        $this->progress = new ProgressBar($this->output, $count);
        $this->progress->setFormat('very_verbose');
    }

    /** * {@inheritdoc} */
    public function advance($step = 1)
    {
        if ($this->current + $step > $this->count) {
            $step = $this->count - $this->current;
        }
        $this->progress->advance($step);
        
$component->rebuildCategoryPath();
            $output->writeln('Removing assignments');
            $component->removeAllAssignments();
        }

        // Get total number of assignments to build         $output->write('Counting…');
        $count = $component->rebuildAllAssignmentsCount();
        $output->writeln("\rCounted {$count} items");

        $progressHelper = new ProgressBar($output$count);
        $progressHelper->setFormat(' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%');

        // create the assignments         while ($progress < $count) {
            $component->rebuildAllAssignments($limit$progress);
            $progress += $limit;
            $progressHelper->advance();
        }
        $progressHelper->finish();

        $output->writeln("\nDone");

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