Skip to content

Remove abstract class and use Interface+Trait #12595

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 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

namespace Symfony\Bundle\FrameworkBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
Expand All @@ -34,8 +35,10 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class Controller extends ContainerAware
class Controller implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* Generates a URL from the given parameters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -23,8 +24,10 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class RedirectController extends ContainerAware
class RedirectController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* Redirects to another route with the given name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

namespace Symfony\Bundle\FrameworkBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Response;

/**
* TemplateController.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class TemplateController extends ContainerAware
class TemplateController implements ContainerAwareInterface
{
use ContainerAwareTrait;

/**
* Renders a template.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;

class FragmentController extends ContainerAware
class FragmentController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function indexAction(Request $request)
{
return $this->container->get('templating')->renderResponse('fragment.html.php', array('bar' => new Bar()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;

class ProfilerController extends ContainerAware
class ProfilerController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function indexAction()
{
return new Response('Hello');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\DependencyInjection\ContainerAware;

class SessionController extends ContainerAware
class SessionController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function welcomeAction(Request $request, $name = null)
{
$session = $request->getSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Controller\ControllerReference;

class SubRequestController extends ContainerAware
class SubRequestController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function indexAction()
{
$handler = $this->container->get('fragment.handler');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class LoginController extends ContainerAware
class LoginController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function loginAction()
{
$form = $this->container->get('form.factory')->create('Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginType');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;

class LocalizedController extends ContainerAware
class LocalizedController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function loginAction(Request $request)
{
// get the login error if there is one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@

namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FormLoginBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\DependencyInjection\ContainerAware;

class LoginController extends ContainerAware
class LoginController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function loginAction(Request $request)
{
// get the login error if there is one
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
-----

* removed all deprecated codes from 2.x versions
* removed ContainerAware class in favor of ContainerAwareInterface + ContainerAwareTrait

2.8.0
-----
Expand Down
41 changes: 0 additions & 41 deletions src/Symfony/Component/DependencyInjection/ContainerAware.php

This file was deleted.

6 changes: 4 additions & 2 deletions src/Symfony/Component/HttpKernel/Bundle/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\HttpKernel\Bundle;

use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Console\Application;
Expand All @@ -26,8 +26,10 @@
*
* @api
*/
abstract class Bundle extends ContainerAware implements BundleInterface
abstract class Bundle implements BundleInterface
Copy link
Member

Choose a reason for hiding this comment

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

missing ContainerAwareInterface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not needed because interface BundleInterface extends ContainerAwareInterface

{
use ContainerAwareTrait;

protected $name;
protected $extension;
protected $path;
Expand Down