| 1 | <?php  | 
            ||
| 8 | trait DisplayRule  | 
            ||
| 9 | { | 
            ||
| 10 | /**  | 
            ||
| 11 | * @var bool|callable  | 
            ||
| 12 | */  | 
            ||
| 13 | protected $displayRule = true;  | 
            ||
| 14 | |||
| 15 | /**  | 
            ||
| 16 | * Set boolean or callback, witch return boolean to determine whether to display or not this item.  | 
            ||
| 17 | * Callback will be called each time rendering item.  | 
            ||
| 18 | *  | 
            ||
| 19 | * @param bool|callable $rule  | 
            ||
| 20 | */  | 
            ||
| 21 | 27 | public function setDisplayRule($rule)  | 
            |
| 22 |     { | 
            ||
| 23 | 27 | $this->displayRule = $rule;  | 
            |
| 24 | 27 | }  | 
            |
| 25 | |||
| 26 | /**  | 
            ||
| 27 | * The element should be rendered?  | 
            ||
| 28 | *  | 
            ||
| 29 | * @return bool  | 
            ||
| 30 | */  | 
            ||
| 31 | 13 | public function canDisplay()  | 
            |
| 39 | }  |