I would like to include a stylesheet and other documents only if they are present in the presentation layer. How is it recommended to handle it? I show the two alternatives I see now in their respective layers:
Presentation:
<?php
$internalpath = "/internal/path/style.css";
if (!file_exists($internalpath))
throw new Exception("Couldn't find style.css in " . $internalpath);
else {
?>
<link href="/external/path/style.css" rel="stylesheet" type="text/css">
<?php } ?>
Problem: it is bloating the view with business logic
Business logic:
<?php
$internalpath = "/internal/path/style.css";
if (!file_exists($internalpath))
throw new Exception("Couldn't find style.css in " . $internalpath);
else
$style = '<link href="/external/path/style.css" rel="stylesheet" type="text/css">';
// ...
?>
Problem: it is bloating the business logic with part of the view.
How can I separate these concerns properly? Is there any other simple alternative I'm not seeing?