getDefault example

$this->assertEquals(404, $response->getStatusCode());
  }

  /** * Checks that the router items are properly registered. */
  public function testPageRouterItems() {
    $collection = \Drupal::service('views.route_subscriber')->routes();

    // Check the controller defaults.     foreach ($collection as $id => $route) {
      $this->assertEquals('Drupal\\views\\Routing\\ViewPageController::handle', $route->getDefault('_controller'));
      $id_parts = explode('.', $id);
      $this->assertEquals($id_parts[1]$route->getDefault('view_id'));
      $this->assertEquals($id_parts[2]$route->getDefault('display_id'));
    }

    // Check the generated patterns and default values.     $route = $collection->get('view.test_page_display_route.page_1');
    $this->assertEquals('/test_route_without_arguments', $route->getPath());

    $route = $collection->get('view.test_page_display_route.page_2');
    $this->assertEquals('/test_route_with_argument/{arg_0}', $route->getPath());
    
private string $defaultLocale;

    protected function setUp(): void
    {
        // we test against different locales, so we need the full         // implementation         IntlTestHelper::requireFullIntl($this, false);

        parent::setUp();

        $this->defaultLocale = \Locale::getDefault();
    }

    protected function tearDown(): void
    {
        parent::tearDown();

        \Locale::setDefault($this->defaultLocale);
    }

    public function testSubmitWithRoundingMode()
    {
        


        // NumberFormatter::parse() does not round         return $this->round($result);
    }

    /** * Returns a preconfigured \NumberFormatter instance. */
    protected function getNumberFormatter(): \NumberFormatter
    {
        $formatter = new \NumberFormatter($this->locale ?? \Locale::getDefault(), \NumberFormatter::DECIMAL);

        if (null !== $this->scale) {
            $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->scale);
            $formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, $this->roundingMode);
        }

        $formatter->setAttribute(\NumberFormatter::GROUPING_USED, $this->grouping);

        return $formatter;
    }

    
/** * @return void */
    public function setLocale(string $locale)
    {
        $this->locale = $locale;
    }

    public function getLocale(): string
    {
        return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en');
    }

    public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
    {
        if (null === $id || '' === $id) {
            return '';
        }

        if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
            return strtr($id$parameters);
        }

        

    public function addResource(string $format, mixed $resource, string $locale, string $domain = null)
    {
        $domain ??= 'messages';

        $this->assertValidLocale($locale);
        $locale ?: $locale = class_exists(\Locale::class) ? \Locale::getDefault() : 'en';

        $this->resources[$locale][] = [$format$resource$domain];

        if (\in_array($locale$this->fallbackLocales)) {
            $this->catalogues = [];
        } else {
            unset($this->catalogues[$locale]);
        }
    }

    /** * @return void */

        } else {
            $autocomplete = $this->autocomplete($output$question$inputStream$autocomplete);
            $ret = $question->isTrimmable() ? trim($autocomplete) : $autocomplete;
        }

        if ($output instanceof ConsoleSectionOutput) {
            $output->addContent(''); // add EOL to the question             $output->addContent($ret);
        }

        $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();

        if ($normalizer = $question->getNormalizer()) {
            return $normalizer($ret);
        }

        return $ret;
    }

    private function getDefaultAnswer(Question $question): mixed
    {
        $default = $question->getDefault();

        
if (isset(self::$_localeData[(string) $locale]) === true) {
            self::$_default = array((string) $locale => $quality);
        } else {
            $elocale = explode('_', (string) $locale);
            if (isset(self::$_localeData[$elocale[0]]) === true) {
                self::$_default = array($elocale[0] => $quality);
            } else {
                throw new Zend_Locale_Exception("Unknown locale '" . (string) $locale . "' can not be set as default!");
            }
        }

        self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
    }

    /** * Expects the Systems standard locale * * For Windows: * f.e.: LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C * would be recognised as de_AT * * @return array */
    

    /** * @var RepositoryInterface */
    protected $repository;

    public function __construct(RepositoryInterface $repository, ModelManager $manager, ShopRegistrationServiceInterface $shopRegistrationService)
    {
        $this->repository = $repository;

        $shopRepository = $manager->getRepository(Shop::class);
        $shopRegistrationService->registerShop($shopRepository->getDefault());
    }

    public function indexAction(
        int $start = 0,
        int $limit = 0,
        array $sort = [],
        array $filter = [],
        bool $resolve = false,
        bool $loadTranslations = false
    ): void {
        $criteria = new Criteria();
        

class SymfonyQuestionHelper extends QuestionHelper
{
    /** * @return void */
    protected function writePrompt(OutputInterface $output, Question $question)
    {
        $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
        $default = $question->getDefault();

        if ($question->isMultiline()) {
            $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
        }

        switch (true) {
            case null === $default:
                $text = sprintf(' <info>%s</info>:', $text);

                break;

            
$this->fileAdapter->addConfigDir($dir);

        return $this;
    }

    /** * @return Locale */
    protected function getDefaultLocale()
    {
        return $this->modelManager->getRepository(Shop::class)->getDefault()->getLocale();
    }

    /** * Defines the 'extends' logic for snippet loading, responsible for the cascading fallbacks * between snippet sets * * @return void */
    protected function initExtends()
    {
        $extends = [];
        

  public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account$view_mode_name = 'default', $bundle = NULL) {
    $access = AccessResult::neutral();
    if ($entity_type_id = $route->getDefault('entity_type_id')) {
      if (empty($bundle)) {
        $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
        $bundle = $route_match->getRawParameter($entity_type->getBundleEntityType());
      }

      $visibility = FALSE;
      if ($view_mode_name == 'default') {
        $visibility = TRUE;
      }
      elseif ($entity_display = $this->entityTypeManager->getStorage('entity_view_display')->load($entity_type_id . '.' . $bundle . '.' . $view_mode_name)) {
        $visibility = $entity_display->status();
      }


    /** * @return list<string> */
    private function getFromRoutes(): array
    {
        $permissions = [];

        foreach ($this->router->getRouteCollection()->all() as $route) {
            /** @var array<string>|null $acl */
            if ($acl = $route->getDefault(PlatformRequest::ATTRIBUTE_ACL)) {
                $permissions[] = $acl;
            }
        }

        return \array_merge(...$permissions);
    }
}

  public function __construct(ArgumentResolverInterface $argument_resolver, FormBuilderInterface $form_builder, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($argument_resolver$form_builder);
    $this->entityTypeManager = $entity_type_manager;
  }

  /** * {@inheritdoc} */
  protected function getFormArgument(RouteMatchInterface $route_match) {
    return $route_match->getRouteObject()->getDefault('_entity_form');
  }

  /** * {@inheritdoc} * * Instead of a class name or service ID, $form_arg will be a string * representing the entity and operation being performed. * Consider the following route: * @code * path: '/foo/{node}/bar' * defaults: * _entity_form: 'node.edit' * @endcode * This means that the edit form for the node entity will used. * If the entity type has a default form, only the name of the * entity {param} needs to be passed: * @code * path: '/foo/{node}/baz' * defaults: * _entity_form: 'node' * @endcode */
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class LanguageValidatorTest extends ConstraintValidatorTestCase
{
    private string $defaultLocale;

    protected function setUp(): void
    {
        parent::setUp();

        $this->defaultLocale = \Locale::getDefault();
    }

    protected function tearDown(): void
    {
        parent::tearDown();

        \Locale::setDefault($this->defaultLocale);
    }

    protected function createValidator(): LanguageValidator
    {
        
'token' => $response->headers->get('X-Debug-Token'),
            'symfony_version' => Kernel::VERSION,
            'symfony_minor_version' => sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION),
            'symfony_lts' => 4 === Kernel::MINOR_VERSION,
            'symfony_state' => $this->determineSymfonyState(),
            'symfony_eom' => $eom->format('F Y'),
            'symfony_eol' => $eol->format('F Y'),
            'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
            'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
            'php_version' => \PHP_VERSION,
            'php_architecture' => \PHP_INT_SIZE * 8,
            'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
            'php_timezone' => date_default_timezone_get(),
            'xdebug_enabled' => \extension_loaded('xdebug'),
            'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL),
            'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL),
            'bundles' => [],
            'sapi_name' => \PHP_SAPI,
        ];

        if (isset($this->kernel)) {
            foreach ($this->kernel->getBundles() as $name => $bundle) {
                $this->data['bundles'][$name] = new ClassStub($bundle::class);
            }
Home | Imprint | This part of the site doesn't use cookies.