Skip to content

Commit

Permalink
Deprecate exporter class and service
Browse files Browse the repository at this point in the history
The class was already marked as deprecated, but only in its phpdoc.
Let's schedule its deletion.
  • Loading branch information
greg0ire committed Jul 30, 2016
1 parent 7386ec0 commit b51fb4b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,12 @@ public function exportAction(Request $request)
$format
);

return $this->get('sonata.admin.exporter')->getResponse(
// NEXT_MAJOR : require sonata-project/exporter ^1.6 and remove this
$exporter = $this->has('sonata.exporter.exporter') ?
$this->get('sonata.exporter.exporter') :
$this->get('sonata.admin.exporter');

return $exporter->getResponse(
$format,
$filename,
$this->admin->getDataSourceIterator()
Expand Down
8 changes: 7 additions & 1 deletion DependencyInjection/SonataAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('block.xml');
$loader->load('menu.xml');

if (method_exists('Symfony\Component\DependencyInjection\Definition', 'setDeprecated')) {
// NEXT_MAJOR : remove this block
$container->getDefinition('sonata.admin.exporter')->setDeprecated(
'The service "%service_id%" is deprecated in favor of the "sonata.exporter.exporter" service'
);
}

// TODO: Go back on xml configuration when bumping requirements to SF 2.6+
$sidebarMenu = $container->getDefinition('sonata.admin.sidebar_menu');
if (method_exists($sidebarMenu, 'setFactory')) {
Expand Down Expand Up @@ -248,7 +255,6 @@ public function configureClassesToCompile()
'Sonata\\AdminBundle\\Datagrid\\ProxyQueryInterface',
'Sonata\\AdminBundle\\Exception\\ModelManagerException',
'Sonata\\AdminBundle\\Exception\\NoValueException',
'Sonata\\AdminBundle\\Export\\Exporter',
'Sonata\\AdminBundle\\Filter\\Filter',
'Sonata\\AdminBundle\\Filter\\FilterFactory',
'Sonata\\AdminBundle\\Filter\\FilterFactoryInterface',
Expand Down
8 changes: 8 additions & 0 deletions Export/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@

use Sonata\CoreBundle\Exporter\Exporter as BaseExporter;

@trigger_error(
'The '.__NAMESPACE__.'\Exporter class is deprecated since version 3.x and will be removed in 4.0.'.
' Use Exporter\Exporter instead',
E_USER_DEPRECATED
);

/**
* NEXT_MAJOR: remove this class.
*
* @deprecated
*/
class Exporter extends BaseExporter
Expand Down
1 change: 1 addition & 0 deletions Resources/config/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<service id="sonata.admin.audit.manager" class="Sonata\AdminBundle\Model\AuditManager">
<argument type="service" id="service_container"/>
</service>
<!-- NEXT_MAJOR : remove this service -->
<service id="sonata.admin.exporter" class="Sonata\AdminBundle\Export\Exporter"/>
<service id="sonata.admin.search.handler" class="Sonata\AdminBundle\Search\SearchHandler">
<argument type="service" id="sonata.admin.pool"/>
Expand Down
4 changes: 4 additions & 0 deletions Tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* Test for CRUDController.
*
* @author Andrej Hudec <pulzarraider@gmail.com>
*
* @group legacy
*/
class CRUDControllerTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -178,6 +180,8 @@ protected function setUp()
}
}));

/* NEXT_MAJOR: mock the class from the sonata-project/exporter package
and remove this test from the legacy group */
$exporter = $this->getMock('Sonata\AdminBundle\Export\Exporter');

$exporter->expects($this->any())
Expand Down
5 changes: 5 additions & 0 deletions Tests/Export/ExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
use Exporter\Source\ArraySourceIterator;
use Sonata\AdminBundle\Export\Exporter;

/**
* NEXT_MAJOR: remove this class.
*
* @group legacy
*/
class ExporterTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down
6 changes: 6 additions & 0 deletions UPGRADE-3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ All files under the ``Tests`` directory are now correctly handled as internal te
You can't extend them anymore, because they are only loaded when running internal tests.
More information can be found in the [composer docs](https://getcomposer.org/doc/04-schema.md#autoload-dev).

### Exporter service and class

The `sonata.admin.exporter` is deprecated in favor of the `sonata.exporter.exporter` service.
To make this service available, you have to install `sonata-project.exporter` ^1.6
and enable the bundle as described in the documentation.

UPGRADE FROM 3.2 to 3.3
=======================

Expand Down

0 comments on commit b51fb4b

Please sign in to comment.