File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1111class Field implements SourceFieldInterface
1212{
1313 private $ hide = true ;
14+ /**
15+ * @var bool
16+ */
17+ private $ logged = false ;
18+ /**
19+ * @var string
20+ */
1421 private $ right ;
1522 /**
1623 * @var string
@@ -60,6 +67,18 @@ public function isHidden(): bool
6067 return $ this ->hide ;
6168 }
6269
70+ /**
71+ * The user must be logged to access this field.
72+ */
73+ public function logged (): self
74+ {
75+ $ this ->logged = true ;
76+ return $ this ;
77+ }
78+
79+ /**
80+ * The user must have right $right to access this field.
81+ */
6382 public function requiresRight (string $ right ): self
6483 {
6584 $ this ->right = $ right ;
@@ -103,7 +122,7 @@ public function getName(): ?string
103122 */
104123 public function isLogged (): bool
105124 {
106- return false ;
125+ return $ this -> logged ;
107126 }
108127
109128 /**
Original file line number Diff line number Diff line change @@ -32,4 +32,12 @@ public function testFailWith()
3232 $ this ->assertTrue ($ field ->canFailWith ());
3333 $ this ->assertSame ('foo ' , $ field ->getFailWith ());
3434 }
35+
36+ public function testLogged ()
37+ {
38+ $ field = new Field ('test ' );
39+ $ this ->assertFalse ($ field ->isLogged ());
40+ $ field ->logged ();
41+ $ this ->assertTrue ($ field ->isLogged ());
42+ }
3543}
You can’t perform that action at this time.
0 commit comments