1 | <?php |
||
35 | class PageLayoutRenderer |
||
36 | { |
||
37 | /** |
||
38 | * @var bool Whether to force (or not force) embedding the content in the layout |
||
39 | */ |
||
40 | protected $use_layout; |
||
41 | |||
42 | /** |
||
43 | * @var Renderer |
||
44 | */ |
||
45 | protected $view_renderer; |
||
46 | |||
47 | /** |
||
48 | * @var \Request |
||
49 | */ |
||
50 | protected $current_request; |
||
51 | |||
52 | public function __construct(Renderer $view_renderer, \Request $current_request = NULL) |
||
57 | |||
58 | /** |
||
59 | * @param PageContentView $content_view |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function render(PageContentView $content_view) |
||
72 | |||
73 | /** |
||
74 | * @return bool |
||
75 | */ |
||
76 | protected function shouldUseLayout() |
||
88 | |||
89 | /** |
||
90 | * @param PageLayoutView $layout |
||
91 | * @param string $content |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function renderInLayout(PageLayoutView $layout, $content) |
||
101 | |||
102 | /** |
||
103 | * Configure whether to always wrap the content in the layout (TRUE), never (FALSE) or automatically for |
||
104 | * non-AJAX requests (NULL) |
||
105 | * |
||
106 | * @param bool $use_layout |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | public function setUseLayout($use_layout) |
||
114 | |||
115 | } |
||
116 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.