Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Translate to Portuguese#1
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
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
14 commits Select commitHold shift + click to select a range
2b4fc95
updated for PR3
fabpot0a9a1ab
Merge branch 'master' into PR3
fabpoted07bf1
Merge branch 'master' into PR3
fabpot5bb596a
[DoctrineMongoDBBundle] Updating documentation for recent changes.
jwagebfeb5d9
removed old file
fabpot2c67ad1
Merge branch 'master' into PR3
fabpotef47cfd
Adicionado a tradução para o quick tour
adell69d2279
Traduzindo o the_architecture.rst
adell686213f
first commit
skipp3aaab6f
Merge branch 'master' of http://github.com/skipp/symfony-docs into sk…
adell7d9e98e
Seguindo a tradução do arquivo the_architecture
adellde0b2b7
Resolvendo osconflitos
adell6184344
adicionados novos arquivos e atualizado a tradução do arquivo the_arc…
adell0bfdda0
Terminada a pagina the_architecture.rst
adellFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
17 changes: 16 additions & 1 deletionguides/doctrine/configuration.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletionsguides/pt_BR/Twig.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
.. index:: | ||
single: Twig | ||
single: View; Twig | ||
Twig & Symfony2 | ||
=============== | ||
`Twig`_ is a flexible, fast, and secure template language for PHP. Symfony2 | ||
has native support for Twig through ``TwigBundle``. | ||
.. index:: | ||
single: Twig; Installation | ||
single: Twig; Configuration | ||
Installation & Configuration | ||
---------------------------- | ||
Enable the ``TwigBundle`` in your kernel:: | ||
public function registerBundles() | ||
{ | ||
$bundles = array( | ||
// ... | ||
new Symfony\Framework\TwigBundle\Bundle(), | ||
); | ||
// ... | ||
} | ||
Then, configure it: | ||
.. code-block:: yaml | ||
# config/config.yml | ||
twig.config: ~ | ||
# config/config_dev.yml | ||
twig.config: | ||
auto_reload: true | ||
.. tip:: | ||
The configuration options are the same as the ones you pass to the | ||
``Twig_Environment`` `constructor`_. | ||
Usage | ||
----- | ||
To render a Twig template instead of a PHP one, add the ``:twig`` suffix at the | ||
end of the template name. The controller below renders the ``index.twig`` | ||
template:: | ||
public function indexAction($name) | ||
{ | ||
return $this->render('HelloBundle:Hello:index:twig', array('name' => $name)); | ||
} | ||
The ``:twig`` suffix is only needed when there is no context, like in a | ||
controller. But when you extend or include a template from a Twig template, | ||
Symfony2 automatically switches the default engine to Twig: | ||
.. code-block:: jinja | ||
{# index.twig #} | ||
{# no need to add :twig as this is the default #} | ||
{% extends 'HelloBundle::layout' %} | ||
{% block content %} | ||
Hello {{ name }} | ||
{# use the special render tag to render a template #} | ||
{% render 'HelloBundle:Hello:sidebar' %} | ||
{% endblock %} | ||
To embed a PHP template in a Twig one, add the ``:php`` suffix to the template | ||
name: | ||
.. code-block:: jinja | ||
{# index.twig #} | ||
{% render 'HelloBundle:Hello:sidebar:php' %} | ||
And the opposite is also true:: | ||
{# index.php #} | ||
<?php $view->render('HelloBundle:Hello:sidebar:twig') ?> | ||
.. index:: | ||
single: Twig; Helpers | ||
Helpers | ||
------- | ||
The default Symfony2 helpers are available within a Twig template via | ||
specialized tags: | ||
.. code-block:: jinja | ||
{# add a javascript #} | ||
{% javascript 'bundles/blog/js/blog.js' %} | ||
{# add a stylesheet #} | ||
{% stylesheet 'bundles/blog/css/blog.css' with ['media': 'screen'] %} | ||
{# output the javascripts and stylesheets in the layout #} | ||
{% javascripts %} | ||
{% stylesheets %} | ||
{# generate a URL for an asset #} | ||
{% asset 'css/blog.css' %} | ||
{% asset 'images/logo.png' %} | ||
{# generate a route #} | ||
{% route 'blog_post' with ['id': post.id] %} | ||
{# render a template #} | ||
{% include 'BlogBundle:Post:list' %} | ||
{# embed another controller response #} | ||
{% render 'BlogBundle:Post:list' with ['path': ['limit': 2], 'alt': 'BlogBundle:Post:error'] %} | ||
.. _twig_extensions:: | ||
Enabling Custom Extensions | ||
-------------------------- | ||
To enable a Twig extension, add it as a regular service in one of your | ||
configuration, and add a ``twig.extension`` annotation: | ||
.. code-block:: yaml | ||
services: | ||
twig.extension.your_extension_name: | ||
class: Fully\Qualified\Extension\Class\Name | ||
annotation: { name: twig.extension } | ||
.. _Twig: http://www.twig-project.org/ | ||
.. _constructor: http://www.twig-project.org/book/03-Twig-for-Developers |
175 changes: 175 additions & 0 deletionsguides/pt_BR/bundles/best_practices.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
.. index:: | ||
single: Bundles; Best Practices | ||
Bundle Best Practices | ||
===================== | ||
A bundle is a directory that has a well-defined structure and can host | ||
anything from classes to controllers and web resources. Even if bundles are | ||
very flexible, you should follow some best practices if you want to distribute | ||
them. | ||
.. index:: | ||
pair: Bundles; Naming Conventions | ||
Bundle Name | ||
----------- | ||
A bundle is also a PHP namespace, composed of several segments: | ||
* The **main namespace**: either ``Bundle``, for reusable bundles, or | ||
``Application`` for application specific bundles; | ||
* The **vendor namespace** (optional for ``Application`` bundles): something | ||
unique to you or your company (like ``Sensio``); | ||
* *(optional)* The **category namespace(s)** to better organize a large set of | ||
bundles; | ||
* The **bundle name**. | ||
.. caution:: | ||
The vendor namespace and the category namespaces are only possible as of | ||
Symfony2 PR3. | ||
The bundle name must follow the following rules: | ||
* Use only alphanumeric characters and underscores; | ||
* Use a CamelCased name; | ||
* Use a descriptive and short name (no more than 2 words); | ||
* Prefix the name with the concatenation of the vendor and category | ||
namespaces; | ||
* Suffix the name with ``Bundle``. | ||
Some good bundle names: | ||
=================================== ========================== | ||
Namespace Bundle Name | ||
=================================== ========================== | ||
``Bundle\Sensio\BlogBundle`` ``SensioBlogBundle`` | ||
``Bundle\Sensio\Social\BlogBundle`` ``SensioSocialBlogBundle`` | ||
``Application\BlogBundle`` ``BlogBundle`` | ||
=================================== ========================== | ||
Directory Structure | ||
------------------- | ||
The basic directory structure of a ``HelloBundle`` bundle must read as | ||
follows:: | ||
XXX/... | ||
HelloBundle/ | ||
HelloBundle.php | ||
Controller/ | ||
Resources/ | ||
meta/ | ||
LICENSE | ||
config/ | ||
doc/ | ||
index.rst | ||
views/ | ||
web/ | ||
Tests/ | ||
The ``XXX`` directory(ies) reflects the namespace structure of the bundle. | ||
The following files are mandatory: | ||
* ``HelloBundle.php``; | ||
* ``Resources/meta/LICENSE``: The full license for the code; | ||
* ``Resources/doc/index.rst``: The root file for the Bundle documentation. | ||
.. note:: | ||
These conventions ensure that automated tools can rely on this default | ||
structure to work. | ||
The depth of sub-directories should be kept to the minimal for most used | ||
classes and files (2 levels at a maximum). More levels can be defined for | ||
non-strategic, less-used files. | ||
The bundle directory is read-only. If you need to write temporary files, store | ||
them under the ``cache/`` or ``log/`` directory of the host application. Tools can | ||
generate files in the bundle directory structure, but only if the generated | ||
files are going to be part of the repository. | ||
The following classes and files have specific emplacements: | ||
========================= ===================== | ||
Type Directory | ||
========================= ===================== | ||
Controllers ``Controller/`` | ||
Templates ``Resources/views/`` | ||
Unit and Functional Tests ``Tests/`` | ||
Web Resources ``Resources/web/`` | ||
Configuration ``Resources/config/`` | ||
Commands ``Command/`` | ||
========================= ===================== | ||
Classes | ||
------- | ||
The bundle directory structure is used as the namespace hierarchy. For | ||
instance, a ``HelloController`` controller is stored in | ||
``Bundle/HelloBundle/Controller/HelloController.php`` and the fully qualified | ||
class name is ``Bundle\HelloBundle\Controller\HelloController``. | ||
All classes and files must follow the Symfony2 coding `standards`_. | ||
Some classes should be seen as facades and should be as short as possible, | ||
like Commands, Helpers, Listeners, and Controllers. | ||
Classes that connects to the Event Dispatcher should have a name that ends | ||
with ``Listener``. | ||
Exceptions classes should be stored in an ``Exception`` sub-namespace. | ||
Vendors | ||
------- | ||
A bundle must not embed third-party PHP libraries. It should rely on the | ||
standard Symfony2 autoloading instead. | ||
A bundle should not embed third-party libraries written in JavaScript, CSS, or | ||
any other language. | ||
Tests | ||
----- | ||
A bundle should come with a test suite written with PHPUnit and stored under | ||
the ``Tests/`` directory. Tests should follow the following principles: | ||
* The test suite must be executable with a simple ``phpunit`` command run from | ||
a sample application; | ||
* The functional tests should only be used to test the response output and | ||
some profiling information if you have some; | ||
* The code coverage should at least covers 95% of the code base. | ||
.. note:: | ||
A test suite must not contain ``AllTests.php`` scripts, but must rely on the | ||
existence of a ``phpunit.xml.dist`` file. | ||
Documentation | ||
------------- | ||
All classes and functions must come with full PHPDoc. | ||
Extensive documentation should also be provided in the :doc:`reStructuredText | ||
</contributing/documentation/format>` format, under the ``Resources/doc/`` | ||
directory; the ``Resources/doc/index.rst`` file is the only mandatory file. | ||
Templates | ||
--------- | ||
If a bundle provides templates, they should be defined in plain PHP. A bundle | ||
must not provide a main layout, but extends a default ``base`` template (which | ||
must provide two slots: ``content`` and ``head``). | ||
.. note:: | ||
The only other template engine supported is Twig, but only for specific | ||
cases. | ||
Configuration | ||
------------- | ||
Configuration must be done via the Symfony2 built-in `mechanism`_. A bundle | ||
should provide all its default configurations in XML. | ||
.. _standards: http://www.symfony-reloaded.org/contributing/Code/Standards | ||
.. _mechanism: http://www.symfony-reloaded.org/guides/Bundles/Configuration |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.