Commit Graph
13 Commits
Author SHA1 Message Date
Vitalii Korotun 6ff0b0a6b5 Merge remote-tracking branch 'pub/develop' into MAGETWO-66403 2017-04-01 15:06:30 +03:00
Vitalii Korotun 85abb94bed MAGETWO-66403: API annotations in Theme, Ui and Framework View
- Magento\Theme
- Magento\Ui
- Magento\Framework\View
2017-03-30 13:37:08 +03:00
James Halsall a31f4a35c0 Remove the copyright year from file headers 2017-02-22 09:09:36 +00:00
Sergii Kovalenko eb30343a09 MAGETWO-62855: Copyright Year Update 2017 2017-01-05 13:01:45 +02:00
Stanislav Idolov e282fb4fc2 MAGETWO-51858: Convert literal class names to \Namespace\Classname::class 2016-04-29 12:24:47 +03:00
Joan He 2d368d0134 MAGETWO-48081: Copyright Year Update 2016-03-17 15:49:11 -05:00
Nathan McBride 148bae13d7 Issue #2361: Allow AbstractAction to handle _isAllowed() logic
Now `AbstractAction::_isAllowed()` is using a static binding, we
can simply define the `ADMIN_RESOURCE` constant in our controllers.
2016-02-16 14:42:13 +00:00
Vinai Kopp f8c8f556ba Add abstract method execute() to \Magento\Framework\App\Action\Action
Purpose
==

Make implementing Actions more developer friendly via self-documenting code.

Background
==

The existing method `\Magento\Framework\App\Action\Action::dispatch()` calls
an `execute()` method without actually implementing it.

```php
$result = $this->execute();
```

Any subclass actions simply need to implement that method and it will be
called automatically when the superclass method is `dispatch()` is called.

Without the changes in this PR, the `execute()` method in effect was part
of an implicit interface exposed by the `Action` class.

Because of this the `Action` class could never be instantiated and used (that
is, dispatched), without first subclassing it.
This in turn makes the `Action` class an implicitly abstract class.

All this PR does it that it makes the class interface explicit by adding the
execute method as an abstract method to `\Magento\Framework\App\Action\Action`.

All the other changes in this PR are just follow-up changes to accommodate
for this one update.

Follow up changes
--

Because concrete classes can't have abstract methods, the `Action` class
itself also had to be made abstract.

A number of subclasses of `Action` that did not implement `execute()`,
because they themselves also needed to be extended, had to be declared as
abstract classes now, too, because they inherit the abstract method from
the `Action` superclass.

There where some tests that instantiated these implicitly abstract classes.
This PR adds stub implementations for each of these.

* `Magento\Checkout\Test\Unit\Controller\OnepageTest`
  in app/code/Magento/Checkout/Test/Unit/Controller/
* `Magento\Contact\Test\Unit\Controller\IndexTest`
  in app/code/Magento/Contact/Test/Unit/Controller/
* `Magento\Tax\Test\Unit\App\Action\ContextPluginTest`
  in app/code/Magento/Tax/Test/Unit/App/Action/
* `Magento\Catalog\Helper\Product\ViewTest`
  in dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/
* `Magento\Cms\Helper\PageTest`
  in dev/tests/integration/testsuite/Magento/Cms/Helper/Stub/
* `Magento\Sales\Controller\Adminhtml\Order\CreateTest`
  in dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/

Finally, the `Magento\Ui\Controller\UiActionInterface` class, which was
implemented by an abstract subclass of `Action`, namely
`\Magento\Ui\Controller\Adminhtml\AbstractAction`, contained a
`public function execute();` itself.
This explicit interface contract was in conflict with the implicit interface
of the `Action` class, which did defined the same method, but implicitly.

To resolve this conflict this PR changes the method exposed by the
`UiActionInterface` to `public function executeAjaxRequest();`. This
seemed the most fitting when looking at the code implementing the interface
method. Internally it only calls the now explicit `execute()` method inherited
from the `Action` interface.

Also, it seems as if the `UiActionInterface::execute()` method was only called
by a single test. However, I realize the method might be used a lot more in the
non-public EE code, which will also need to be adjusted to be compatible with
this PR.

Reasons for this PR
==

As stated above, the purpose of this PR is to make the developer experience
better. This is done by making an implicit interface explicit. This has
a whole number of benefits, besides being good OOP practice:

* It is clear which classes should be instantiated and which should not
* It is clear which method needs to be implemented when subclassing `Action`
* The expected return type of `execute()` is documented in the phpdoc block
* When subclassing `Action` the IDE can be used to quickly a method stub

Allover the changes lead to more self-documenting code that tells developers
to they should use it.

Potential issues
==

The explicit abstract `execute()` method added in this PR is declared with
protected visibility.
This basically removes it as a valid extension point for plugins. However,
since the method was not declared as public previously (in fact, is wasn't
declared at all), it should not have been used as an extension point for
plugins anyway.

So the main reason against this PR I can think of is that the EE code will
need to be adjusted (plus, I might be missing many obvious reasons).
Of course I'd be happy to make the required updates, but I realize that is
problematic due to the commercial licenced, non-open code.
I've got a bunch of hacky shell scripts to find and update any controllers
needed to be declared abstract, but I'd rather not share them as they are just
one-time hacks.
All the other changes - updating the ui action interface and the test stubs -
where done manually and didn't take long.
2015-06-26 16:04:15 +02:00
Dmytro Poperechnyy eda7bae1cd MAGETWO-34989: Implement getDefaultRedirect() method
- DocBlocks updated;
- Protected variable context removed from AbstractAction;
2015-03-20 16:19:35 +02:00
Yuri Kovsher 1dbe484cee Merge remote-tracking branch 'tango-ce/MAGETWO-34382' into MAGETWO-34878
Conflicts:
	app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php
2015-03-10 16:57:05 +02:00
Joan He 582070c625 MAGETWO-33707: Moved Magento\Core\Model\Variable.php to Magento_Variable and update tests 2015-02-13 15:23:11 -06:00
Joan He 74aa15913f MAGETWO-33717: Moved configuration files to Magento_Variable and update tests 2015-02-12 08:40:11 -06:00
Joan He 674af11f16 MAGETWO-33714: Moved controllers and layout files to Magento_Variable and update tests 2015-02-11 16:03:38 -06:00