@@ -445,10 +445,10 @@ ujemal in dajal parametru ``page`` vrednost ``2``. Odlično.
445
445
.. index ::
446
446
single: Routing; Requirements
447
447
448
- Adding Requirements
449
- ~~~~~~~~~~~~~~~~~~~
448
+ Dodajanje zahtev
449
+ ~~~~~~~~~~~~~~~~
450
450
451
- Take a quick look at the routes that have been created so far :
451
+ Na hitro poglejte usmeritve, ki so bile ustvarjene za vas :
452
452
453
453
.. configuration-block ::
454
454
@@ -497,26 +497,26 @@ Take a quick look at the routes that have been created so far:
497
497
498
498
return $collection;
499
499
500
- Can you spot the problem? Notice that both routes have patterns that match
501
- URL's that look like ``/blog/* ``. The Symfony router will always choose the
502
- **first ** matching route it finds. In other words, the ``blog_show `` route
503
- will * never * be matched. Instead, a URL like ``/blog/my-blog-post `` will match
504
- the first route (``blog ``) and return a nonsense value of ``my-blog-post ``
505
- to the ``{page} `` parameter .
506
-
507
- +--------------------+-------+-----------------------+
508
- | URL | route | parameters |
509
- +====================+=======+=======================+
510
- | /blog/2 | blog | {page} = 2 |
511
- +--------------------+-------+-----------------------+
512
- | /blog/my-blog-post | blog | {page} = my-blog-post |
513
- +--------------------+-------+-----------------------+
514
-
515
- The answer to the problem is to add route * requirements * or route * conditions *
516
- (see :ref: `book-routing-conditions `). The routes in this example would work
517
- perfectly if the ``/blog/{page} `` path * only * matched URLs where the `` {page} ``
518
- portion is an integer. Fortunately, regular expression requirements can easily
519
- be added for each parameter. For example :
500
+ Ali opazite problem? Bodite pozorni, da imata obe usmeritvi vzorce, ki se ujemajo
501
+ z URL-ji, ki izgledajo kot ``/blog/* ``. Symfony-jev usmerjevalnik bo vedno izbral
502
+ **prvo ** ujemalno usmeritev, ki jo najde. Z drugimi besedami, usmeritev ``blog_show ``
503
+ se ne bo nikoli ujemala. Namesto tega, URL kot je ``/blog/my-blog-post `` se bo ujel
504
+ s prvo usmeritvijo (``blog ``) in vrnil nesmiselno vrednost ``my-blog-post ``
505
+ parametru ``{page} ``.
506
+
507
+ +--------------------+----------- +-----------------------+
508
+ | URL | usmeritev | parametri |
509
+ +====================+=========== +=======================+
510
+ | /blog/2 | blog | {page} = 2 |
511
+ +--------------------+----------- +-----------------------+
512
+ | /blog/my-blog-post | blog | {page} = my-blog-post |
513
+ +--------------------+----------- +-----------------------+
514
+
515
+ Odgovor na problem je dodati * zahteve * usmeritve ali * pogoje * usmeritve
516
+ (see :ref: `book-routing-conditions `). Usmeritve v tem primeru bi delovale
517
+ odlično, če bi se pot ``/blog/{page} `` ujemala * samo * z URL-ji, kjer je del
518
+ `` {page} `` celo število. Na srečo, so lahko zahteve splošnih izrazov enostavno
519
+ dodane za vsak parameter. Na primer :
520
520
521
521
.. configuration-block ::
522
522
@@ -558,17 +558,17 @@ be added for each parameter. For example:
558
558
559
559
return $collection;
560
560
561
- The ``\d+ `` requirement is a regular expression that says that the value of
562
- the ``{page} `` parameter must be a digit (i.e. a number ). The ``blog `` route
563
- will still match on a URL like ``/blog/2 `` (because 2 is a number ), but it
564
- will no longer match a URL like ``/blog/my-blog-post `` (because ``my-blog-post ``
565
- is * not * a number ).
561
+ Zahteva ``\d+ `` je splošni izraz, ki pravi, da vrednost
562
+ parametra ``{page} `` mora biti celo število (t.j. številka ). Usmeritev ``blog ``
563
+ se bo še vedno ujemala na URL-jih kot je ``/blog/2 `` (ker je 2 številka ), vendar
564
+ se ne bo več ujemala z URL-ji kot je ``/blog/my-blog-post `` (ker ``my-blog-post ``
565
+ * ni * številka ).
566
566
567
- As a result, a URL like ``/blog/my-blog-post `` will now properly match the
568
- ``blog_show `` route .
567
+ Kot rezultat, URL kot je ``/blog/my-blog-post ``, se bo sedaj ustrezno ujemala z
568
+ usmeritvijo ``blog_show ``.
569
569
570
570
+----------------------+-----------+-------------------------+
571
- | URL | route | parameters |
571
+ | URL | usmeritev | parametri |
572
572
+======================+===========+=========================+
573
573
| /blog/2 | blog | {page} = 2 |
574
574
+----------------------+-----------+-------------------------+
@@ -577,18 +577,18 @@ As a result, a URL like ``/blog/my-blog-post`` will now properly match the
577
577
| /blog/2-my-blog-post | blog_show | {slug} = 2-my-blog-post |
578
578
+----------------------+-----------+-------------------------+
579
579
580
- .. sidebar :: Earlier Routes always Win
580
+ .. sidebar :: Prejšnje usmeritve vedno zmagajo
581
581
582
- What this all means is that the order of the routes is very important .
583
- If the ``blog_show `` route were placed above the ``blog `` route, the
584
- URL ``/blog/2 `` would match ``blog_show `` instead of ``blog `` since the
585
- ``{slug} `` parameter of ``blog_show `` has no requirements. By using proper
586
- ordering and clever requirements, you can accomplish just about anything .
582
+ Kaj to vse pomeni je, da je vrstni red usmeritev zelo pomemben .
583
+ Če bi bila usmeritev ``blog_show `` postavljena nad usmeritev ``blog ``,
584
+ bi se URL ``/blog/2 `` ujemal z ``blog_show `` namesto z ``blog ``, ker
585
+ parameter ``{slug} `` od ``blog_show `` nima nobenih zahtev. Z uporabo ustreznega
586
+ vrstnega reda in pametnih zahtev, lahko dosežete karkoli .
587
587
588
- Since the parameter requirements are regular expressions, the complexity
589
- and flexibility of each requirement is entirely up to you. Suppose the homepage
590
- of your application is available in two different languages, based on the
591
- URL:
588
+ Ker so zahteve parametrov splošni izrazi, sta kompleksnost
589
+ in fleksibilnost vsakega zahtevka v celoti odvisna od vas. Predpostavimo, da je domača stran
590
+ vaše aplikacije na voljo v dveh različnih jezikih, na osnovi
591
+ URL-ja :
592
592
593
593
.. configuration-block ::
594
594
630
630
631
631
return $collection;
632
632
633
- For incoming requests, the ``{culture} `` portion of the URL is matched against
634
- the regular expression ``(en|fr) ``.
633
+ Za prihajajoče zahtevke, se del ``{culture} `` URL-ja ujema s
634
+ splošnimi izrazi ``(en|fr) ``.
635
635
636
636
+-----+--------------------------+
637
637
| / | {culture} = en |
@@ -646,14 +646,14 @@ the regular expression ``(en|fr)``.
646
646
.. index ::
647
647
single: Routing; Method requirement
648
648
649
- Adding HTTP Method Requirements
650
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
649
+ Dodajanje zahtev HTTP metod
650
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
651
651
652
- In addition to the URL, you can also match on the * method * of the incoming
653
- request (i.e . GET, HEAD, POST, PUT, DELETE). Suppose you have a contact form
654
- with two controllers - one for displaying the form (on a GET request) and one
655
- for processing the form when it's submitted (on a POST request ). This can
656
- be accomplished with the following route configuration :
652
+ V dodatku URL-ja, lahko tudi ujemate na * metodi * prihajajočega
653
+ zahtevka (t.j . GET, HEAD, POST, PUT, DELETE). Predpostavimo, da imate kontaktni obrazec
654
+ z dvema krmilnikoma - eden za prikaz obrazca (na zahtevku GET) in eden
655
+ za procesiranje obrazca, ko je poslan (na zahtevku POST). To je lahko
656
+ doseženo s sledečo nastavitvijo usmeritve :
657
657
658
658
.. configuration-block ::
659
659
@@ -702,33 +702,33 @@ be accomplished with the following route configuration:
702
702
703
703
return $collection;
704
704
705
- Despite the fact that these two routes have identical paths (``/contact ``),
706
- the first route will match only GET requests and the second route will match
707
- only POST requests. This means that you can display the form and submit the
708
- form via the same URL, while using distinct controllers for the two actions .
705
+ Kljub dejstvu, da imata ti dve usmeritvi identični poti (``/contact ``),
706
+ se bo prva usmeritev ujemala samo z zahtevki GET in druga usmeritev se bo ujemala
707
+ samo z zahtevki POST. To pomeni, da lahko prikažete obrazec in ga pošljete
708
+ preko enakega URL-ja, medtem ko uporabljate različna krmilnika za ti dve akciji .
709
709
710
710
.. note ::
711
711
712
- If no `` methods `` are specified, the route will match on * all * methods .
712
+ Če ni specificirana nobena `` method ``, se bo usmeritev ujemala z * vsemi * metodami .
713
713
714
- Adding a Host Requirement
715
- ~~~~~~~~~~~~~~~~~~~~~~~~~
714
+ Dodajanje zahtev gostitelja
715
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
716
716
717
- You can also match on the HTTP *host * of the incoming request. For more
718
- information, see :doc: `/components/routing/hostname_pattern ` in the Routing
719
- component documentation .
717
+ Ujemate lahko tudi HTTP *host * prihajajočega zahtevka. Za več
718
+ informacij, glejte :doc: `/components/routing/hostname_pattern ` v dokumentaciji Routing
719
+ komponente .
720
720
721
721
.. _book-routing-conditions :
722
722
723
- Completely Customized Route Matching with Conditions
724
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
723
+ Popolnoma prilagojeno ujemanje usmeritev s pogoji
724
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
725
725
726
726
.. versionadded :: 2.4
727
- Route conditions were introduced in Symfony 2.4.
727
+ Pogoji usmeritev so bili predstavljeni v Symfony 2.4.
728
728
729
- As you've seen, a route can be made to match only certain routing wildcards
730
- (via regular expressions ), HTTP methods, or host names. But the routing system
731
- can be extended to have an almost infinite flexibility using `` conditions ``:
729
+ Kot ste videli, je lahko usmeritev narejena, da se ujema samo z določenimi usmeritvenimi nadomestnimi znaki
730
+ (preko splošnih izrazov ), HTTP metodami ali imeni gostiteljev. Vendar je lahko sistem
731
+ usmerjanja razširjen, da ima skoraj neskončno fleksibilnost z uporabo `` pogojev ``:
732
732
733
733
.. configuration-block ::
734
734
@@ -775,11 +775,12 @@ can be extended to have an almost infinite flexibility using ``conditions``:
775
775
776
776
return $collection;
777
777
778
- The ``condition `` is an expression, and you can learn more about its syntax
779
- here : :doc: `/components/expression_language/syntax `. With this, the route
780
- won't match unless the HTTP method is either GET or HEAD *and * if the ``User-Agent ``
781
- header matches ``firefox ``.
778
+ ``condition `` je izraz in lahko se naučite več o njegovi sintaksi
779
+ tu : :doc: `/components/expression_language/syntax `. S tem se usmeritev
780
+ ne bo ujemala razen, če je HTTP metoda ali GET ali HEAD *in *, če je glava ``User-Agent ``
781
+ ``firefox ``.
782
782
783
+ Lahko naredite katerokoli kompleksno logiko, ki jo potrebujete v izrazu
783
784
You can do any complex logic you need in the expression by leveraging two
784
785
variables that are passed into the expression:
785
786
0 commit comments