Skip to content

[3.0] use ContainerAwareTrait #16411

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

Merged
merged 5 commits into from
Nov 5, 2015
Merged
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
15 changes: 2 additions & 13 deletions src/Symfony/Bridge/Doctrine/ManagerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Bridge\Doctrine;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Doctrine\Common\Persistence\AbstractManagerRegistry;

/**
Expand All @@ -22,10 +22,7 @@
*/
abstract class ManagerRegistry extends AbstractManagerRegistry implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
protected $container;
use ContainerAwareTrait;

/**
* {@inheritdoc}
Expand All @@ -42,12 +39,4 @@ protected function resetService($name)
{
$this->container->set($name, null);
}

/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}
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 @@ -35,8 +36,10 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class Controller extends ContainerAware
abstract 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
17 changes: 3 additions & 14 deletions src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,17 @@
namespace Symfony\Bundle\TwigBundle\Command;

use Symfony\Bridge\Twig\Command\DebugCommand as BaseDebugCommand;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

/**
* Lists twig functions, filters, globals and tests present in the current project.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class DebugCommand extends BaseDebugCommand implements ContainerAwareInterface
final class DebugCommand extends BaseDebugCommand implements ContainerAwareInterface
{
/**
* @var ContainerInterface|null
*/
private $container;

/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
use ContainerAwareTrait;

/**
* {@inheritdoc}
Expand Down
17 changes: 3 additions & 14 deletions src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\Bundle\TwigBundle\Command;

use Symfony\Bridge\Twig\Command\LintCommand as BaseLintCommand;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Finder\Finder;

/**
Expand All @@ -22,20 +22,9 @@
* @author Marc Weistroff <marc.weistroff@sensiolabs.com>
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
class LintCommand extends BaseLintCommand implements ContainerAwareInterface
final class LintCommand extends BaseLintCommand implements ContainerAwareInterface
{
/**
* @var ContainerInterface|null
*/
private $container;

/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
use ContainerAwareTrait;

/**
* {@inheritdoc}
Expand Down
37 changes: 0 additions & 37 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 @@ -24,8 +24,10 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class Bundle extends ContainerAware implements BundleInterface
abstract class Bundle implements BundleInterface
{
use ContainerAwareTrait;

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