Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2059609

Browse filesBrowse files
committed
bug #24519 [Validator] [Twig] added magic method __isset() to File Constraint class (loru88)
This PR was submitted for the 3.4 branch but it was merged into the 2.7 branch instead (closes #24519). Discussion ---------- [Validator] [Twig] added magic method __isset() to File Constraint class | Q | A | ------------- | --- | Branch? | 3.4 or master / 2.7, 2.8 or 3.3 <!-- see comment below --> | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #24512 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> In my project I get assert constraints from one of my entity and I use this value in my front end via Twig. I faced a problem with the property $maxSize of the File Constraint. As this property is protected I cannot access it via Twig because the magic method __isset is missing, as I read in twig documentation. <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the 3.4, legacy code removals go to the master branch. - Please fill in this template according to the PR you're about to submit. - Replace this comment by a description of what your PR is solving. --> Commits ------- 9efb765 [Validator] added magic method __isset() to File Constraint class
2 parents 262b4f3 + 9efb765 commit 2059609
Copy full SHA for 2059609

File tree

Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed
Filter options
  • src/Symfony/Component/Validator/Constraints
Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed

‎src/Symfony/Component/Validator/Constraints/File.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/File.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ public function __get($option)
8888
return parent::__get($option);
8989
}
9090

91+
public function __isset($option)
92+
{
93+
if ('maxSize' === $option) {
94+
return true;
95+
}
96+
97+
return parent::__isset($option);
98+
}
99+
91100
private function normalizeBinaryFormat($maxSize)
92101
{
93102
$sizeInt = (int) $maxSize;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.