-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Remove dependency on symfony/templating #476
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,22 +17,12 @@ | |
use Sonata\BlockBundle\Model\BlockInterface; | ||
use Sonata\CoreBundle\Model\Metadata; | ||
use Sonata\CoreBundle\Validator\ErrorElement; | ||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | ||
|
||
/** | ||
* @author Christian Gripp <[email protected]> | ||
*/ | ||
abstract class AbstractAdminBlockService extends AbstractBlockService implements AdminBlockServiceInterface | ||
{ | ||
/** | ||
* @param string $name | ||
* @param EngineInterface $templating | ||
*/ | ||
public function __construct($name, EngineInterface $templating) | ||
{ | ||
parent::__construct($name, $templating); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,10 @@ | |
|
||
use Sonata\BlockBundle\Block\BlockContextInterface; | ||
use Sonata\BlockBundle\Model\BlockInterface; | ||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
use Twig\Environment; | ||
|
||
/** | ||
* @author Sullivan Senechal <[email protected]> | ||
|
@@ -31,25 +31,14 @@ abstract class AbstractBlockService implements BlockServiceInterface | |
protected $name; | ||
|
||
/** | ||
* @var EngineInterface|null | ||
* @var Environment | ||
*/ | ||
protected $templating; | ||
private $twig; | ||
|
||
/** | ||
* @param string $name | ||
* @param EngineInterface $templating | ||
*/ | ||
public function __construct($name = null, EngineInterface $templating = null) | ||
public function __construct(string $name, Environment $twig) | ||
{ | ||
if (null === $name || null === $templating) { | ||
@trigger_error( | ||
'The $name and $templating parameters will be required fields with the 4.0 release.', | ||
E_USER_DEPRECATED | ||
); | ||
} | ||
|
||
$this->name = $name; | ||
$this->templating = $templating; | ||
$this->twig = $twig; | ||
} | ||
|
||
/** | ||
|
@@ -63,7 +52,11 @@ public function __construct($name = null, EngineInterface $templating = null) | |
*/ | ||
public function renderResponse($view, array $parameters = [], Response $response = null) | ||
{ | ||
return $this->getTemplating()->renderResponse($view, $parameters, $response); | ||
$response = $response ?? new Response(); | ||
|
||
$response->setContent($this->twig->render($view, $parameters)); | ||
|
||
return $response; | ||
} | ||
|
||
/** | ||
|
@@ -157,8 +150,8 @@ public function getName() | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTemplating() | ||
public function getTwig() | ||
{ | ||
return $this->templating; | ||
return $this->twig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,13 @@ | |
use Sonata\CoreBundle\Form\Type\ImmutableArrayType; | ||
use Sonata\CoreBundle\Model\Metadata; | ||
use Sonata\CoreBundle\Validator\ErrorElement; | ||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | ||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | ||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormTypeInterface; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Twig\Environment; | ||
|
||
/** | ||
* @author Hugo Briand <[email protected]> | ||
|
@@ -56,14 +56,11 @@ class MenuBlockService extends AbstractAdminBlockService | |
protected $menuRegistry; | ||
|
||
/** | ||
* @param string $name | ||
* @param EngineInterface $templating | ||
* @param MenuProviderInterface $menuProvider | ||
* @param MenuRegistryInterface|null $menuRegistry | ||
*/ | ||
public function __construct($name, EngineInterface $templating, MenuProviderInterface $menuProvider, $menuRegistry = null) | ||
public function __construct(string $name, Environment $twig, MenuProviderInterface $menuProvider, $menuRegistry = null) | ||
{ | ||
parent::__construct($name, $templating); | ||
parent::__construct($name, $twig); | ||
|
||
$this->menuProvider = $menuProvider; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if we can get rid of framework-bundle also? AFAIK it was used for the EngineInterface, not sure if we need it for anything else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symfony/framework-bundle
is used only inSonata\BlockBundle\Command\BaseCommand
:To remove dependency
extends ContainerAwareCommand
could be replaced withimplements \Symfony\Component\DependencyInjection\ContainerAwareInterface
here