Edit via SFTP
<?php namespace ferret\layout;
/*
  USAGE:
    * Descendent classes should use namespace ferret\page\html.
  HISTORY:
    2021-11-28 added ferret\page\html namespace; renamed fcHTMLPage to ferret\page\html\cPage
    2021-12-01 moved some XML-specific stuff from ferret\page\caPage to ferret\page\html\caPage
      * Yes, some of this is more generally XML, but for now I'm equating the two. We can split off
        XML-rendering later if there's a use-case for it.
      * Yes, I wish I could think of a better/diffrent name for either "page" the namespace folder
        or "Page" the class, but everything I've come up with so far seems more likely to confuse.
*/
 
use ferret as F;
use ferret\layout\html\tag AS F_TAG;
 
use ferret\layout\html\tag\cDocType;
use ferret\layout\html\tag\cBody;
 
// DOCS: 
abstract class caHypertextPage extends caWebPage {
 
    // ++ SETUP ++ //
 
    protected function OnBuild(cEventNodeBuild $oe) : void {
      #echo 'BUILDING '.get_class($this).' in '.__CLASS__.'<br>';
        #echo get_called_class().' OnFigure: pre-parent<br>';
        if (method_exists($this,'parent::OnBuild')) {
            parent::OnBuild($oe);
        }
        #echo get_called_class().' OnFigure: post-parent<br>';
        // add <!DOCTYPE> and set its value
        $this->SetDocType('HTML');
        // add <html>
        $this->AddTagNode_html();
        #echo ' :: TWIG COUNT: '.$this->Twigs()->CellCount().'<br>';
    }
 
    // -- SETUP -- //
    // ++ CONFIG ++ //
 
    protected function DocTypeClass() : string { return cDocType::class; }
    abstract protected function Class_forTagHTML() : string;
 
    // -- CONFIG -- //
    // ++ TWIGLETS ++ //
 
    protected function DocTypeNode() : cDocType { return $this->MakeTwig($this->DocTypeClass(),'html.doctype'); }
    // USAGE: only call at initialization
    protected function AddTagNode_html() : void { $this->MakeTwig($this->Class_forTagHTML(),'html'); }
    // ASSUMES: HTML tag node has already been created
    protected function GetTagNode_html() : F_TAG\caHtml { return $this->Twigs()->GetCell('html'); }
    // ASSUMES: HTML tag node has been created and has a GetTagNode_body() method
    protected function GetTagNode_body() : cBody { return $this->GetTagNode_html()->GetTagNode_body(); }
 
    // -- TWIGLETS -- //
}