Skip to content

Commit

Permalink
minor #24628 [Form] Add $useDefaultThemes flag to the interfaces (emo…
Browse files Browse the repository at this point in the history
…dric)

This PR was merged into the 4.0-dev branch.

Discussion
----------

[Form] Add $useDefaultThemes flag to the interfaces

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

Followup to #22610 to add `$useDefaultThemes` to the interfaces as discussed in the issue.

Commits
-------

c22d783 [Form] Add useDefaultThemes flag to the interfaces
  • Loading branch information
fabpot committed Oct 19, 2017
2 parents b935b93 + c22d783 commit b2a4acf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions UPGRADE-4.0.md
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
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
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
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
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

0 comments on commit b2a4acf

Please sign in to comment.