Skip to content

[Form] Add $useDefaultThemes flag to the interfaces #24628

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 1 commit into from
Oct 19, 2017
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
[Form] Add useDefaultThemes flag to the interfaces
  • Loading branch information
emodric committed Oct 19, 2017
commit c22d783696d65f36384f166b6d1a56c426517ac4
2 changes: 2 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ Form
}
```

* `FormRendererInterface::setTheme` and `FormRendererEngineInterface::setTheme` have a new optional argument `$useDefaultThemes` with a default value set to `true`.

FrameworkBundle
---------------

Expand Down
6 changes: 2 additions & 4 deletions src/Symfony/Component/Form/AbstractRendererEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ public function __construct(array $defaultThemes = array())
/**
* {@inheritdoc}
*/
public function setTheme(FormView $view, $themes /*, $useDefaultThemes = true */)
public function setTheme(FormView $view, $themes, $useDefaultThemes = true)
{
$cacheKey = $view->vars[self::CACHE_KEY_VAR];

// Do not cast, as casting turns objects into arrays of properties
$this->themes[$cacheKey] = is_array($themes) ? $themes : array($themes);

$args = func_get_args();
$this->useDefaultThemes[$cacheKey] = isset($args[2]) ? (bool) $args[2] : true;
$this->useDefaultThemes[$cacheKey] = (bool) $useDefaultThemes;

// Unset instead of resetting to an empty array, in order to allow
// implementations (like TwigRendererEngine) to check whether $cacheKey
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Form/FormRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ public function getEngine()
/**
* {@inheritdoc}
*/
public function setTheme(FormView $view, $themes /*, $useDefaultThemes = true */)
public function setTheme(FormView $view, $themes, $useDefaultThemes = true)
{
$args = func_get_args();
$this->engine->setTheme($view, $themes, isset($args[2]) ? (bool) $args[2] : true);
$this->engine->setTheme($view, $themes, $useDefaultThemes);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/FormRendererEngineInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ interface FormRendererEngineInterface
* @param mixed $themes The theme(s). The type of these themes
* is open to the implementation.
* @param bool $useDefaultThemes If true, will use default themes specified
* in the engine, will be added to the interface in 4.0
* in the engine
*/
public function setTheme(FormView $view, $themes /*, $useDefaultThemes = true */);
public function setTheme(FormView $view, $themes, $useDefaultThemes = true);

/**
* Returns the resource for a block name.
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/FormRendererInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function getEngine();
* @param mixed $themes The theme(s). The type of these themes
* is open to the implementation.
* @param bool $useDefaultThemes If true, will use default themes specified
* in the renderer, will be added to the interface in 4.0
* in the renderer
*/
public function setTheme(FormView $view, $themes /*, $useDefaultThemes = true */);
public function setTheme(FormView $view, $themes, $useDefaultThemes = true);

/**
* Renders a named block of the form theme.
Expand Down