Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tweaking Doctrine book chapter#3488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
wouterj wants to merge270 commits intosymfony:2.3fromwouterj:refact_book_doctrine
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
270 commits
Select commitHold shift + click to select a range
0e843ff
Merge branch '2.3'
weaverryanJun 22, 2013
7038693
Merge branch '2.3'
weaverryanJun 22, 2013
ff2e2c4
Merge branch '2.3'
weaverryanJun 29, 2013
ca1a38d
Merge branch '2.3'
weaverryanJun 29, 2013
1f78980
[#2720] Playing "catch-up" to get the master branch up to date with t…
weaverryanJun 29, 2013
d7da8a5
Merge pull request #2784 from symfony/version-catchup
weaverryanJun 29, 2013
28d51a9
Merge pull request #2642 from mpartel/progresshelper-clear
weaverryanJun 30, 2013
40f407d
Merge branch '2.3'
weaverryanJul 1, 2013
07341ba
Merge remote-tracking branch 'origin/master'
weaverryanJul 1, 2013
84d569d
Merge branch '2.3'
weaverryanJul 19, 2013
d633094
Merge branch '2.3'
weaverryanJul 20, 2013
f897411
[#2797] Removing the 2.1 version notes on master (since 2.1 has been …
weaverryanJul 20, 2013
95e651f
Merge branch '2.3'
weaverryanJul 20, 2013
f57b569
[#2829] Changing reference back to master - eventually we'll need an …
weaverryanJul 20, 2013
d3b0a38
Merge branch '2.3'
weaverryanJul 20, 2013
b414088
Merge branch '2.3'
weaverryanJul 20, 2013
92a9437
Merge branch '2.3'
weaverryanJul 29, 2013
d0d7c47
Merge branch '2.3'
weaverryanJul 29, 2013
c80e4e7
[#2783] Removing 2.1 versionadded that came back due to a tweak on th…
weaverryanJul 29, 2013
b6d5606
Updated rounding_mode documentation to reflect changed ROUND_ constants.
webmozartAug 1, 2013
2e25e00
adds docs for idle timeout (see symfony/symfony#8651)
schmittjohAug 4, 2013
3fa71b8
adds api link
schmittjohAug 4, 2013
e1cf110
Merge pull request #2875 from schmittjoh/patch-2
weaverryanAug 4, 2013
1891edd
Updated documentation for PR https://github.com/symfony/symfony/pull/…
Jul 21, 2013
e797af3
Merge branch '2.3'
weaverryanAug 5, 2013
fc8a060
Merge branch '2.3'
weaverryanAug 8, 2013
871b340
Merge remote-tracking branch 'origin/master'
weaverryanAug 8, 2013
8b0611a
[Process] Update docs for modifications.
Aug 9, 2013
d695cad
Merge branch '2.3'
weaverryanAug 10, 2013
6f0c697
Merge pull request #2840 from lmammino/improved-image-validator
weaverryanAug 10, 2013
8e6f084
[#2840] Minor tweaks to new orientation Image validation constraints
weaverryanAug 10, 2013
03aaa5c
Document possibility to use ContainerAwareTrait
endroidAug 11, 2013
76e460d
Merge pull request #2630 from WouterJ/document_stopwatch_helper
weaverryanAug 17, 2013
3d27f53
[#2630] Tweaks for new stopwatch tag - updating version, syntax for u…
weaverryanAug 17, 2013
5471a32
Merge branch '2.3'
weaverryanAug 17, 2013
c6e50b7
Removing several "2.1" references, which is consistent with our relea…
weaverryanAug 17, 2013
0dfcdf7
Merge branch '2.3'
weaverryanAug 17, 2013
0c2f735
Merge pull request #2872 from bschussek/issue8473
weaverryanAug 25, 2013
69be273
Merge branch '2.3'
weaverryanAug 26, 2013
a801c09
Improve documentation of ContentAwareTrait
endroidAug 27, 2013
066fcd5
Added docs for the changes proposed in symfony/symfony#8908
ChristianGaertnerSep 1, 2013
7afa87f
Update filesystem.rst
ChristianGaertnerSep 1, 2013
feb346d
Update filesystem.rst
ChristianGaertnerSep 1, 2013
d9050a5
added documentation for the new request_stack service
fabpotSep 8, 2013
7ed82a0
Merge branch '2.3'
weaverryanSep 9, 2013
f1ab2ad
Merge branch '2.3'
weaverryanSep 9, 2013
3780933
Documented Stopwatch Helper
wouterjSep 10, 2013
3548a51
Merge pull request #2956 from fabpot/request-stack
weaverryanSep 12, 2013
b84f52c
[#2956] A few more changes to the scopes chapter to update the new wa…
weaverryanSep 12, 2013
67901ff
document the getEncodings() method of the Request class
xabbuhSep 12, 2013
5f69c8f
Merge branch '2.3'
weaverryanSep 13, 2013
1112cc2
Merge branch 'patch-1' of github.com:endroid/symfony-docs into endroi…
weaverryanSep 18, 2013
3210251
[#2891] Shortening note about ContainerAwareTrait
weaverryanSep 18, 2013
a7e86b0
Merge branch '2.3'
weaverryanSep 23, 2013
6be4f80
Merge branch '2.3'
weaverryanSep 25, 2013
9a715ed
Merge branch '2.3'
weaverryanSep 25, 2013
887f0d2
Updated the documentation for the simplified Callback constraint
webmozartSep 26, 2013
cc70738
Merge branch '2.3'
weaverryanSep 26, 2013
893a780
[#3009] Updating information for 2.4 with the new checkPasswordLength…
weaverryanSep 26, 2013
c8dfa9e
Merge branch '2.3'
weaverryanSep 28, 2013
574d7a8
[#2913] Removing versionadded 2.1 messages from the master branch
weaverryanSep 28, 2013
a866606
Add a cookbook entry on how to limit session metadata writes
adrienbraultSep 27, 2013
0e9f02a
added documentation about Request::setFactory()
fabpotSep 30, 2013
16799b4
added the compact layout information
fabpotOct 2, 2013
81698fe
Merge pull request #2947 from ChristianGaertner/patch-1
weaverryanOct 2, 2013
7e0cb8b
[#2947] Adding versionadded details
weaverryanOct 2, 2013
0f674c1
Merge pull request #2960 from WouterJ/doc_php_stopwatch
weaverryanOct 2, 2013
2be6510
[#2960] Minor changes thanks to @xabbuh
weaverryanOct 2, 2013
6a13396
Merge pull request #2728 from imobilis/ticket_7884
weaverryanOct 2, 2013
88f051a
[#2728] Minor tweaks to docs on Process flush methods
weaverryanOct 2, 2013
32c510f
Merge pull request #2971 from xabbuh/issue-2958
weaverryanOct 2, 2013
66f1672
[#2971] Minor language tweak to be consistent with the other areas
weaverryanOct 2, 2013
d4f9478
Merge branch '2.3'
weaverryanOct 2, 2013
e52ac5c
fix versionadded directive
xabbuhOct 4, 2013
4732a76
[#2728] Fixing typo thanks to @xabbuh
weaverryanOct 5, 2013
022763a
Merge pull request #3036 from xabbuh/fix-build-errors-master
weaverryanOct 5, 2013
adcef55
Merge branch '2.3'
weaverryanOct 5, 2013
5aa3a19
Merge pull request #3021 from fabpot/request-factory
weaverryanOct 6, 2013
1d94f34
[#3021] Minor tweaks thanks to @WouterJ and @GromNaN
weaverryanOct 6, 2013
cab5c89
Creates Expression Language chapter
wouterjOct 6, 2013
27822ff
Bootstraps intro
wouterjOct 6, 2013
efe349e
use literal for class name
xabbuhOct 6, 2013
6631f70
Added operators
wouterjOct 6, 2013
4ff9fae
Added another operator
wouterjOct 6, 2013
f98fa24
Register Commands in the Service Container
lyrixxOct 4, 2013
cfee7b8
Merge pull request #3043 from xabbuh/patch-1
weaverryanOct 7, 2013
b1478f3
Merge branch '2.3'
weaverryanOct 7, 2013
9b04e53
Merge branch 'issue2480' of github.com:bschussek/symfony-docs into bs…
weaverryanOct 8, 2013
b94e3f7
[#3012] Tweaks to Callback changes - most thanks to the careful eye o…
weaverryanOct 8, 2013
3efd179
[Form] Add a 'submitted' attribute to the form view
GeLoLabsOct 3, 2013
ca83f6a
Documents Output::*Verbose methods
lyrixxOct 8, 2013
9268e3a
Merge pull request #3025 from fabpot/console-compact-layout
weaverryanOct 10, 2013
26b2e9f
Merge branch '2.3'
weaverryanOct 10, 2013
22a270e
Merge pull request #3017 from adrienbrault/session-metadata
weaverryanOct 10, 2013
bdd37ba
[#3017] Very minor tweaks
weaverryanOct 10, 2013
ce45928
make target name unique that is used as a reference
xabbuhOct 10, 2013
808319d
Merge pull request #3029 from egeloen/f-valid-form-view
weaverryanOct 14, 2013
7e7425c
Merge pull request #3031 from lyrixx/command-in-the-DIC
weaverryanOct 14, 2013
0925090
[#3031] Adding some details as to why you may or may not want to regi…
weaverryanOct 14, 2013
4009c51
Merge branch '2.3'
weaverryanOct 14, 2013
0c34aa1
Merge pull request #3048 from lyrixx/console-ouput-verbosity
weaverryanOct 15, 2013
a53c8ad
[#3048] Adding intro paragraph about the semantic verbosity methods
weaverryanOct 15, 2013
72b690f
[#3031] Fixing typo thanks to @xabbuh
weaverryanOct 15, 2013
b944124
Added documentation about disabling internal validation of DomCrawler…
pylebecqOct 20, 2013
b02bc8c
add note about not passing the command argument with Symfony 2.4
xabbuhOct 22, 2013
8fe9fd6
Fixed comments and splitted in intro and syntax
wouterjOct 26, 2013
85fce13
Merge pull request #3058 from xabbuh/fix-build-errors
weaverryanOct 26, 2013
e874269
Merge branch '2.3'
weaverryanOct 26, 2013
31fb5b8
update framework csrf configuration
TobionOct 28, 2013
f3e9d17
Merge pull request #3087 from xabbuh/issue-2870-master
weaverryanOct 28, 2013
2a50493
switch argument to key to be more precise
cordovalOct 28, 2013
fda51ee
fix introducing typo
cordovalOct 28, 2013
02d6a71
Merge pull request #3075 from pylebecq/dom-crawler-disable-internal-v…
weaverryanNov 2, 2013
8a91f15
Merge branch '2.3'
weaverryanNov 2, 2013
ae03fdb
[#3075] Moving new Form::disableValidation DomCrawler details into th…
weaverryanNov 2, 2013
957bca4
Merge branch '2.3'
weaverryanNov 2, 2013
10fe8a4
Removed 2.2 references as it reached eom
wouterjNov 2, 2013
67b4d21
Merge branch '2.3'
weaverryanNov 3, 2013
3943d8f
[#3084] Putting back message that was incorrect in 2.3, but correct i…
weaverryanNov 3, 2013
4644e2b
Merge branch '2.3'
weaverryanNov 3, 2013
6829df3
Removing versionadded 2.1 that leaked in from a merge up
weaverryanNov 3, 2013
8a71cdf
Merge pull request #3114 from Tobion/patch-2
weaverryanNov 3, 2013
f65f1d0
[#3114] Lining up spaces
weaverryanNov 3, 2013
a516f61
Merge pull request #3119 from cordoval/patch-17
weaverryanNov 3, 2013
9660455
use verbose HTTP status code constants
xabbuhNov 3, 2013
e094853
Merge pull request #3148 from xabbuh/http-status-code-constants
weaverryanNov 6, 2013
b9b60d7
Merge branch '2.3'
weaverryanNov 6, 2013
4dfdb36
Merge branch '2.3'
weaverryanNov 7, 2013
87962e3
Bumped version number
peterrehmNov 9, 2013
f4975fd
Merge pull request #3175 from peterrehm/patch-5
weaverryanNov 9, 2013
c5ae3dd
[#2956] Refactoring the scopes entry entirely to not talk about the r…
weaverryanSep 12, 2013
d417f7b
[#2972] Many small tweaks - thanks very much to @WouterJ and @xabbuh
weaverryanNov 12, 2013
3dcbbc2
[#2972] Clarifying how to use the request_stack with an example
weaverryanNov 12, 2013
941a5cc
Merge pull request #2972 from symfony/scope-refactoring
weaverryanNov 12, 2013
80a3643
some tweaks and fixes to d417f7b and 3dcbbc2
xabbuhNov 12, 2013
ba413f4
Merge branch '2.3'
weaverryanNov 13, 2013
343a59e
Removing some 2.1 references that were merged up
weaverryanNov 13, 2013
2f4479d
Merge pull request #3179 from xabbuh/master-tweaks
weaverryanNov 16, 2013
4754401
Merge branch '2.3'
weaverryanNov 16, 2013
ff4a44e
[#2906][#3190] Removing versionadded:: 2.1 tags after merge
weaverryanNov 16, 2013
2e91170
Merge branch '2.3'
weaverryanNov 16, 2013
799b2c6
Merge pull request #3044 from WouterJ/document_expressionlanguage
weaverryanNov 16, 2013
fb61db9
Merge branch '2.3'
weaverryanNov 23, 2013
55a2de4
Removing a versionadded:: 2.1 that came from the merge
weaverryanNov 23, 2013
2b97bbe
Merge branch '2.3' into 2.4
weaverryanNov 27, 2013
12621a9
Merge branch '2.3' into 2.4
weaverryanNov 27, 2013
70b475b
Merge branch '2.3' into 2.4
weaverryanNov 27, 2013
e9a81bf
[#3044] Furthering @WouterJ's work on the ExpressionLanguage component
weaverryanNov 17, 2013
a14c39d
[#3191] Many tweaks to expression language component thanks to @Woute…
weaverryanNov 28, 2013
cd98a63
[#3191] Fixing semicolon thanks to @WouterJ
weaverryanNov 28, 2013
6f0694c
Merge branch '2.3' into 2.4
weaverryanNov 28, 2013
aea6533
documentation for the regex based exclusion of 404 errors with Monolo…
xabbuhNov 17, 2013
6ec097d
[#3203] Minor tweaks to new 404 logging entry
weaverryanNov 28, 2013
112d16b
Merge branch '2.3' into 2.4
weaverryanNov 28, 2013
fe0571a
Merge branch '2.3' into 2.4
weaverryanNov 28, 2013
22b3776
[#3205] Tweaking versionadded
weaverryanNov 28, 2013
08de8b2
Merge branch '2.3' into 2.4
weaverryanNov 28, 2013
4dba1ac
Changed parameter container to requestStack (2.4+)
maks-rafalkoNov 22, 2013
2198c86
Merge branch '2.3' into 2.4
weaverryanNov 28, 2013
77b84ea
executable permission unset
petkNov 28, 2013
0675b56
Removed assignment operator
wouterjNov 29, 2013
e506f01
Added example of range operator
wouterjNov 29, 2013
0725a8b
Added docs for using functions
wouterjNov 29, 2013
6e2e583
Added article about custom functions
wouterjNov 29, 2013
78baee9
Merge pull request #3233 from peterkokot/patch-2.4
weaverryanNov 29, 2013
4d50f34
[#3022] Adding service container expression language details
weaverryanNov 28, 2013
22c9404
[#3232][#3022] Making many small tweaks thanks to @WouterJ and @xabbuh
weaverryanNov 29, 2013
4147ad4
Merge pull request #3232 from symfony/expression-framework-container
weaverryanNov 29, 2013
240df84
Merge pull request #3241 from WouterJ/expression-furthering-component
weaverryanNov 29, 2013
667d590
[#3241] Minor tweaks to new expression language functions
weaverryanNov 29, 2013
4738c75
[#3232] Fixing note about expressions with parameters thanks to @WouterJ
weaverryanDec 1, 2013
93e8cd2
Merge branch '2.3' into 2.4
weaverryanDec 1, 2013
ac15bf5
[#3022] Adding framework documentation for routing expressions
weaverryanDec 1, 2013
be86fef
[#3022] Adding new Expression validation constraint
weaverryanDec 1, 2013
d72759a
[#3022] Adding all of the security-related expression functionality docs
weaverryanDec 1, 2013
33676dc
[#3022] Adding a quick cookbook entry to highlight where the expressi…
weaverryanDec 1, 2013
0cf1828
[#3022][#3258] Tweaks thanks to @cordoval
weaverryanDec 1, 2013
bc22f16
[#3022][#3258] Enhancing example at @ggam's suggestion
weaverryanDec 2, 2013
0000250
[#3258] A bunch of fixes thanks to @WouterJ
weaverryanDec 2, 2013
816c06b
Merge pull request #3258 from symfony/expression-language-framework
weaverryanDec 2, 2013
a9e0e66
Added Caching article
wouterjDec 2, 2013
d6b3a14
[Cookbook] Fixes a link to the Request class
zczapranDec 2, 2013
0a59f6d
Added doctrine note
wouterjDec 2, 2013
d1bbdc4
Merge pull request #3261 from zczapran/2.4
weaverryanDec 2, 2013
180fc13
Merge pull request #3260 from WouterJ/component_expression_caching
weaverryanDec 3, 2013
be60602
[#3260] Minor tweaks when proofreading
weaverryanDec 3, 2013
821a1b4
Merge branch '2.3' into 2.4
weaverryanDec 3, 2013
a2ec22b
Update Callback.rst
berny46Dec 3, 2013
1f385da
[Components][HttpKernel] Add FINISH_REQUEST to events table
bicpiDec 4, 2013
986e876
Updated install page to v2.4.*
h4ccDec 5, 2013
a7f2c98
Change symfony version on composer.json
paumasDec 7, 2013
9d4a138
Merge branch 'master' into eom-2-2
weaverryanDec 8, 2013
7e1e4a2
some tweaks to the Expression Language cache chapter
xabbuhDec 8, 2013
7bf21c2
changed create-project example
luebbert42Dec 7, 2013
6212968
changed version in create project example to 2.4.* and remove the hin…
luebbert42Dec 8, 2013
6e610bf
[Components] [ExpressionLanguage] Fix missing quote
willdurandDec 12, 2013
a45464f
Added missing argument to the evaluator function
jakzalDec 12, 2013
2f486ce
[Security][Acl] Documentation for the new updateUserSecurityIdentity …
lemoinemDec 12, 2013
37deaa7
document the new authentication customization options
xabbuhAug 19, 2013
1bd187f
fixes thanks to @WouterJ
xabbuhAug 19, 2013
8ddb26b
clarify the authenticator type
xabbuhSep 13, 2013
afdb708
add example on how to use the new SimplePreAuthenticatorInterface
xabbuhSep 13, 2013
a7b80a6
[Form] added multiple option to file type doc
bamarniDec 17, 2013
bf98517
fixed spaces
bamarniDec 17, 2013
827014e
Documented xml namespace autodiscovery.
jakzalSep 13, 2013
47bc7dc
Documented changing of default namespace prefix.
jakzalSep 18, 2013
68fa18e
Documented explicit namespace registration.
jakzalSep 22, 2013
baec6de
Added a note about removing the default namespace.
jakzalDec 16, 2013
daf5d3c
[#2979] Minor tweaks
weaverryanDec 17, 2013
14c5382
document how to restrict a firewall to a specific host
xabbuhSep 15, 2013
0a9241d
[#2953][#2986] Tweaks to firewall hostname
weaverryanDec 17, 2013
7f7d7a5
Merge branch '2.3' into 2.4
weaverryanDec 17, 2013
cc5c9a3
Merge branch '2.4'
weaverryanDec 17, 2013
77455c9
[#2986] Fix thanks to @WouterJ
weaverryanDec 17, 2013
cefdd6c
Merge pull request #3271 from berny46/patch-1
weaverryanDec 18, 2013
c83cca8
Merge pull request #3274 from bicpi/document_finish_request_event
weaverryanDec 18, 2013
d62f19b
Merge pull request #3287 from h4cc/patch-1
weaverryanDec 19, 2013
134a7e3
Merge pull request #3298 from pauliusmasiliunas/patch-1
weaverryanDec 19, 2013
876994a
Merge pull request #3300 from xabbuh/expression-component-cache-tweaks
weaverryanDec 19, 2013
abe419b
Merge pull request #3315 from jakzal/patch-1
weaverryanDec 19, 2013
d86e542
[#3315] Adding a little bit more information about the $arguments arg…
weaverryanDec 19, 2013
fb781dd
Merge pull request #3318 from willdurand/patch-1
weaverryanDec 23, 2013
06f2f74
Merge pull request #3319 from lemoinem/features/acl-update-security-id
weaverryanDec 23, 2013
2a10a46
[#3319] Linking to the whole method
weaverryanDec 23, 2013
6f286e1
Merge branch '2.3' into 2.4
weaverryanDec 23, 2013
2cbca5f
Removing versionadded 2.1 from merge
weaverryanDec 23, 2013
14b0c47
Merge branch '2.3' into 2.4
weaverryanDec 23, 2013
1401372
Merge branch '2.4'
weaverryanDec 23, 2013
34551d2
[#3319] Fixing typos thanks to @xabbuh
weaverryanDec 26, 2013
69f8a88
Merge branch '2.3' into 2.4
weaverryanDec 26, 2013
4834b77
How to Configure Monolog to display Console messages
tvlooyDec 14, 2013
3945d5f
[#3340] Tweaks to console logging:
weaverryanDec 26, 2013
7c1b2c3
Merge branch '2.3' into 2.4
weaverryanDec 26, 2013
d31465b
Merge branch '2.4'
weaverryanDec 26, 2013
6bdcdb1
Merge pull request #3354 from bamarni/patch-6
weaverryanDec 26, 2013
4ef1a71
Synchronized setter injection occurs on Container::set() not on Conta…
Dec 17, 2013
0dfffff
Update PHP example to include synthetic attribute.
Dec 17, 2013
479ec86
Merge branch '2.3' into 2.4
weaverryanDec 26, 2013
6b7d307
Merge branch '2.4'
weaverryanDec 26, 2013
bade680
Merge branch '2.3' into 2.4
fabpotDec 27, 2013
6c3d9eb
Merge branch '2.4'
fabpotDec 27, 2013
f76369e
Removed duplicated DQL documentation
wouterjJan 18, 2014
9da5986
Minor tweaks to Repository section
wouterjJan 18, 2014
d751011
Minor tweak to configuration section
wouterjJan 18, 2014
8be18a3
Removed some duplicated Livecycle docs
wouterjJan 18, 2014
f1c6e94
Removed "Doctrine Extensions" section
wouterjJan 18, 2014
9d03b69
Removed types list
wouterjJan 18, 2014
7c2ad29
Moved commands to cookbook
wouterjJan 18, 2014
36df975
Small tweaks to summary
wouterjJan 18, 2014
86719ee
Clean up reference pointers list
wouterjJan 18, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletionsbook/controller.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -392,8 +392,13 @@ itself.

Extending the base class is *optional* in Symfony; it contains useful
shortcuts but nothing mandatory. You can also extend
:class:`Symfony\\Component\\DependencyInjection\\ContainerAware`. The service
container object will then be accessible via the ``container`` property.
:class:`Symfony\\Component\\DependencyInjection\\ContainerAware` or use
the class:`Symfony\\Component\\DependencyInjection\\ContainerAwareTrait` trait
(if you have PHP 5.4). The service container object will then be accessible
via the ``container`` property.

.. versionadded:: 2.4
The ``ContainerAwareTrait`` is new in Symfony 2.4.

.. note::

Expand DownExpand Up@@ -750,12 +755,15 @@ headers and content that's sent back to the client::
use Symfony\Component\HttpFoundation\Response;

// create a simple Response with a 200 status code (the default)
$response = new Response('Hello '.$name,200);
$response = new Response('Hello '.$name,Response::HTTP_OK);

// create a JSON-response with a 200 status code
$response = new Response(json_encode(array('name' => $name)));
$response->headers->set('Content-Type', 'application/json');

.. versionadded:: 2.4
Support for HTTP status code constants was added in Symfony 2.4.

.. tip::

The ``headers`` property is a
Expand Down
263 changes: 17 additions & 246 deletionsbook/doctrine.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -728,65 +728,18 @@ a controller, do the following::

$products = $query->getResult();

The ``getResult()`` method returns an array of results.

If you're comfortable with SQL, then DQL should feel very natural. The biggest
difference is that you need to think in terms of "objects" instead of rows
in a database. For this reason, you select *from* ``AcmeStoreBundle:Product``
and then alias it as ``p``.

The ``getResult()`` method returns an array of results. If you're querying
for just one object, you can use the ``getSingleResult()`` method instead::

$product = $query->getSingleResult();

.. caution::

The ``getSingleResult()`` method throws a ``Doctrine\ORM\NoResultException``
exception if no results are returned and a ``Doctrine\ORM\NonUniqueResultException``
if *more* than one result is returned. If you use this method, you may
need to wrap it in a try-catch block and ensure that only one result is
returned (if you're querying on something that could feasibly return
more than one result)::

$query = $em->createQuery('SELECT ...')
->setMaxResults(1);

try {
$product = $query->getSingleResult();
} catch (\Doctrine\Orm\NoResultException $e) {
$product = null;
}
// ...
in a database. For this reason, you select *from* the ``AcmeStoreBundle:Product``
*object* and then alias it as ``p``.

The DQL syntax is incredibly powerful, allowing you to easily join between
entities (the topic of :ref:`relations <book-doctrine-relations>` will be
covered later), group, etc. For more information, see the official Doctrine
`Doctrine Query Language`_ documentation.

.. sidebar:: Setting Parameters

Take note of the ``setParameter()`` method. When working with Doctrine,
it's always a good idea to set any external values as "placeholders",
which was done in the above query:

.. code-block:: text

... WHERE p.price > :price ...

You can then set the value of the ``price`` placeholder by calling the
``setParameter()`` method::

->setParameter('price', '19.99')

Using parameters instead of placing values directly in the query string
is done to prevent SQL injection attacks and should *always* be done.
If you're using multiple parameters, you can set their values at once
using the ``setParameters()`` method::

->setParameters(array(
'price' => '19.99',
'name' => 'Foo',
))

Using Doctrine's Query Builder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand DownExpand Up@@ -819,10 +772,10 @@ Custom Repository Classes

In the previous sections, you began constructing and using more complex queries
from inside a controller. In order to isolate, test and reuse these queries,
it's a goodidea to create a custom repository class for your entity and
it's a goodpractise to create a custom repository class for your entity and
add methods with your query logic there.

To do this, add the name of the repository class to your mapping definition.
To do this, add the name of the repository class to your mapping definition:

.. configuration-block::

Expand DownExpand Up@@ -1300,7 +1253,7 @@ Configuration

Doctrine is highly configurable, though you probably won't ever need to worry
about most of its options. To find out more about configuring Doctrine, see
the Doctrine section of the :doc:`reference manual </reference/configuration/doctrine>`.
the Doctrine section of the :doc:`config reference </reference/configuration/doctrine>`.

Lifecycle Callbacks
-------------------
Expand All@@ -1312,7 +1265,7 @@ stages of the lifecycle of an entity (e.g. the entity is inserted, updated,
deleted, etc).

If you're using annotations for your metadata, start by enabling the lifecycle
callbacks. This is not necessary if you're using YAML or XML for your mapping:
callbacks. This is not necessary if you're using YAML or XML for your mapping.

.. code-block:: php-annotations

Expand DownExpand Up@@ -1375,20 +1328,8 @@ the current date, only when the entity is first persisted (i.e. inserted):

Now, right before the entity is first persisted, Doctrine will automatically
call this method and the ``createdAt`` field will be set to the current date.

This can be repeated for any of the other lifecycle events, which include:

* ``preRemove``
* ``postRemove``
* ``prePersist``
* ``postPersist``
* ``preUpdate``
* ``postUpdate``
* ``postLoad``
* ``loadClassMetadata``

For more information on what these lifecycle events mean and lifecycle callbacks
in general, see Doctrine's `Lifecycle Events documentation`_
For more information on other lifecycle events and lifecycle callbacks in
general, see Doctrine's `Lifecycle Events documentation`_.

.. sidebar:: Lifecycle Callbacks and Event Listeners

Expand All@@ -1403,185 +1344,15 @@ in general, see Doctrine's `Lifecycle Events documentation`_
or subscriber and give it access to whatever resources you need. For
more information, see :doc:`/cookbook/doctrine/event_listeners_subscribers`.

Doctrine Extensions: Timestampable, Sluggable, etc.
---------------------------------------------------

Doctrine is quite flexible, and a number of third-party extensions are available
that allow you to easily perform repeated and common tasks on your entities.
These include thing such as *Sluggable*, *Timestampable*, *Loggable*, *Translatable*,
and *Tree*.

For more information on how to find and use these extensions, see the cookbook
article about :doc:`using common Doctrine extensions </cookbook/doctrine/common_extensions>`.

.. _book-doctrine-field-types:

Doctrine Field Types Reference
------------------------------

Doctrine comes with a large number of field types available. Each of these
maps a PHP data type to a specific column type in whatever database you're
using. The following types are supported in Doctrine:

* **Strings**

* ``string`` (used for shorter strings)
* ``text`` (used for larger strings)

* **Numbers**

* ``integer``
* ``smallint``
* ``bigint``
* ``decimal``
* ``float``

* **Dates and Times** (use a `DateTime`_ object for these fields in PHP)

* ``date``
* ``time``
* ``datetime``
* ``datetimetz``

* **Other Types**

* ``boolean``
* ``object`` (serialized and stored in a ``CLOB`` field)
* ``array`` (serialized and stored in a ``CLOB`` field)
* ``blob`` (mapped to a resource stream)
* ``simple_array`` (serialized using :phpfunction:`implode()` and :phpfunction:`explode()`,
with a comma as delimiter, and stored in a ``CLOB`` field)
* ``json_array`` (serialized using :phpfunction:`json_encode()` and :phpfunction:`json_decode()`,
and stored in a ``CLOB`` field)
* ``guid``

For more information, see Doctrine's `Mapping Types documentation`_.

Field Options
~~~~~~~~~~~~~

Each field can have a set of options applied to it. The available options
include ``type`` (defaults to ``string``), ``name``, ``length``, ``unique``
and ``nullable``. Take a few examples:

.. configuration-block::

.. code-block:: php-annotations

/**
* A string field with length 255 that cannot be null
* (reflecting the default values for the "type", "length"
* and *nullable* options)
*
* @ORM\Column()
*/
protected $name;

/**
* A string field of length 150 that persists to an "email_address" column
* and has a unique index.
*
* @ORM\Column(name="email_address", unique=true, length=150)
*/
protected $email;

.. code-block:: yaml

fields:
# A string field length 255 that cannot be null
# (reflecting the default values for the "length" and *nullable* options)
# type attribute is necessary in YAML definitions
name:
type: string

# A string field of length 150 that persists to an "email_address" column
# and has a unique index.
email:
type: string
column: email_address
length: 150
unique: true

.. code-block:: xml

<!--
A string field length 255 that cannot be null
(reflecting the default values for the "length" and *nullable* options)
type attribute is necessary in XML definitions
-->
<field name="name" type="string" />
<field name="email"
type="string"
column="email_address"
length="150"
unique="true"
/>

.. note::

There are a few more options not listed here. For more details, see
Doctrine's `Property Mapping documentation`_

.. index::
single: Doctrine; ORM console commands
single: CLI; Doctrine ORM

Console Commands
----------------

The Doctrine2 ORM integration offers several console commands under the
``doctrine`` namespace. To view the command list you can run the console
without any arguments:

.. code-block:: bash

$ php app/console

A list of available commands will print out, many of which start with the
``doctrine:`` prefix. You can find out more information about any of these
commands (or any Symfony command) by running the ``help`` command. For example,
to get details about the ``doctrine:database:create`` task, run:

.. code-block:: bash

$ php app/console help doctrine:database:create

Some notable or interesting tasks include:

* ``doctrine:ensure-production-settings`` - checks to see if the current
environment is configured efficiently for production. This should always
be run in the ``prod`` environment:

.. code-block:: bash

$ php app/console doctrine:ensure-production-settings --env=prod

* ``doctrine:mapping:import`` - allows Doctrine to introspect an existing
database and create mapping information. For more information, see
:doc:`/cookbook/doctrine/reverse_engineering`.

* ``doctrine:mapping:info`` - tells you all of the entities that Doctrine
is aware of and whether or not there are any basic errors with the mapping.

* ``doctrine:query:dql`` and ``doctrine:query:sql`` - allow you to execute
DQL or SQL queries directly from the command line.

.. note::

To be able to load data fixtures to your database, you will need to have
the DoctrineFixturesBundle bundle installed. To learn how to do it,
read the ":doc:`/bundles/DoctrineFixturesBundle/index`" entry of the
documentation.

.. tip::

This page shows working with Doctrine within a controller. You may also
want to work with Doctrine elsewhere in your application. The
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getDoctrine`
method of the controller returns the ``doctrine`` service, you can work with
this in the same way elsewhere by injecting this into your own
services. See :doc:`/book/service_container` for more on creating
your own services.
using. To see a list of all available types and more information, see
Doctrine's `Mapping Types documentation`_.

Summary
-------
Expand All@@ -1598,21 +1369,21 @@ that allow you to take different actions as objects go through their persistence
lifecycle.

For more information about Doctrine, see the *Doctrine* section of the
:doc:`cookbook </cookbook/index>`, which includes the following articles:
:doc:`cookbook </cookbook/index>`. Some usefull articles might be:

* :doc:`/bundles/DoctrineFixturesBundle/index`
* :doc:`/cookbook/doctrine/common_extensions`
* :doc:`/cookbook/doctrine/console`
* :doc:`/bundles/DoctrineFixturesBundle/index`
* :doc:`/bundles/DoctrineMongoDBBundle/index`

.. _`Doctrine`: http://www.doctrine-project.org/
.. _`MongoDB`: http://www.mongodb.org/
.. _`Basic Mapping Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html
.. _`Query Builder`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/query-builder.html
.. _`Doctrine Query Language`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html
.. _`Association Mapping Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html
.. _`DateTime`: http://php.net/manual/en/class.datetime.php
.. _`Mapping Types Documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#doctrine-mapping-types
.. _`Property Mapping documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#property-mapping
.. _`Property Mapping`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#property-mapping
.. _`Lifecycle Events documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#lifecycle-events
.. _`Reserved SQL keywords documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words
.. _`Persistent classes`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#persistent-classes
.. _`Property Mapping`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#property-mapping
11 changes: 3 additions & 8 deletionsbook/forms.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1831,11 +1831,6 @@ The answer is to setup the constraints yourself, and attach them to the individu
fields. The overall approach is covered a bit more in the :ref:`validation chapter <book-validation-raw-values>`,
but here's a short example:

.. versionadded:: 2.1
The ``constraints`` option, which accepts a single constraint or an array
of constraints (before 2.1, the option was called ``validation_constraint``,
and only accepted a single constraint) is new to Symfony 2.1.

.. code-block:: php

use Symfony\Component\Validator\Constraints\Length;
Expand DownExpand Up@@ -1893,7 +1888,7 @@ Learn more from the Cookbook

.. _`Symfony2 Form component`: https://github.com/symfony/Form
.. _`DateTime`: http://php.net/manual/en/class.datetime.php
.. _`Twig Bridge`: https://github.com/symfony/symfony/tree/2.2/src/Symfony/Bridge/Twig
.. _`form_div_layout.html.twig`: https://github.com/symfony/symfony/blob/2.2/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
.. _`Twig Bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/Twig
.. _`form_div_layout.html.twig`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
.. _`Cross-site request forgery`: http://en.wikipedia.org/wiki/Cross-site_request_forgery
.. _`view on GitHub`: https://github.com/symfony/symfony/tree/2.2/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form
.. _`view on GitHub`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form
Loading

[8]ページ先頭

©2009-2025 Movatter.jp