अपने MVC फ्रेमवर्क के लिए renderLayout विधि

आइए अब renderLayout विधि बनाएं। यह विधि लेआउट फ़ाइल लेगी और इसमें चर $title और $content का मान प्रतिस्थापित करेगी (यह विधि का पैरामीटर के रूप में पास की जाएगी और renderView विधि के कार्य के परिणाम का प्रतिनिधित्व करेगी):

/core/View.php<?php
  private function renderLayout(Page $page, $content) {
    $layoutPath = $_SERVER['DOCUMENT_ROOT'] . "/project/layouts/{$page->layout}.php";
    
    if (file_exists($layoutPath)) {
      ob_start();
        $title = $page->title;
        include $layoutPath; // यहाँ $title और $content चर उपलब्ध होंगे
      return ob_get_clean();
    }
  }
?>