8000 [Console] Command Lifecycle explications by 94noni · Pull Request #5319 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Console] Command Lifecycle explications #5319

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix style
  • Loading branch information
94noni committed Jun 1, 2015
commit 6abe3b1b70f9b4e6864e1d87c307d069f60c9075
35 changes: 14 additions & 21 deletions components/console/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,34 +113,27 @@ This prints::
Command Lifecycle
~~~~~~~~~~~~~~~~~

Commands have 3 lifecycle methods:
Commands have three lifecycle methods:

1. initialize($input, $output)
2. interact($input, $output)
3. execute($input, $output)
:method:`Symfony\\Component\\Console\\Command\\Command::initialize`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this empty line between term and definition is not allowed

Explanations:
This method is executed before the ``interact()`` and the ``execute()``
methods. It's main purpose is to initialize the variables used in the
rest of the command methods.

initialize($input, $output)
:method:`Symfony\\Component\\Console\\Command\\Command::interact`

This method is executed before the interact() and the execute() methods.
It's main purpose is to initialize the variables used in the rest of
the command methods.
This method is executed after ``initialize()`` and before ``execute()``.
Its purpose is to check if some of the options/arguments are missing
and interactively ask the 8000 user for those values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add that this method is executed before the input definition is validated. This means that this is the only place where you can ask for missing options, otherwise the command throw an error about missing options.


interact($input, $output)
:method:`Symfony\\Component\\Console\\Command\\Command::execute`

This method is executed after initialize() and before execute(). Its purpose
is to check if some of the options/arguments are missing and interactively
ask the user for those values.
This method is executed after ``interact()`` and ``initialize()``. It
usually contains the logic to execute to complete this command task.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remove "to complete" to make this readable I guess.

Copy link
Contributor Author
8000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok of course,
but It usually contains the logic to execute this command task. seems not good
What about It contains the logic you want the command executes ?


execute($input, $output)

This method is executed after interact() and initialize(). It usually
contains the logic to execute to complete this command task.

Note that ``execute($input, $output)`` is the only required method of the three.
``initialize($input, $output)`` and ``interact($input, $output)``
methods are completely optional.
Note that ``execute()`` is the only required method of the three. The
``initialize()`` and ``interact()`` methods are completely optional.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this as a normal paragraph again (without indentation)


.. _components-console-coloring:

Expand Down
0