logo       

[PHP-DOC] PhD Processing Instructions Design: msg#00135

phpdoc

Subject: [PHP-DOC] PhD Processing Instructions Design

Hey guys,

The first design of the PhD Processing Instructions Handler.
The idea is choose the correct PIHandler class for each target you want.

ex:
    In the Package_Default_XHTML class we have:
    $pihandlers = array(
        "dbhtml"        => "PI_DBHTMLHandler",
    );

    In your own package:
    $pihandlers = array(
        "dbhtml"        => "MyOwnDBHTMLHandler",
    );
  
    Also we can write a class to handler all targets:
    $pihandlers = array(
        "dbhtml"        => "PIHandler",
        "dbman"         => "PIHandler",
        "tdg-purp"      => "PIHandler",
    );


The Render class will only know the parsePI method:
    case \XMLReader::PI:
    $target = $r->name;
    $data = "">     foreach ($this as $format) {
        $format->parsePI($target, $data);
    }
    break;
 
The parsePI method will act like a factory to instanciate the PIHandler class:
    public final function parsePI($target, $data) {
        if (isset($this->pihandlers[$target])) {
            //I'm thinking in a way to not have to create a new instance here
            //every time. Maybe a singleton?
            $classname = __NAMESPACE__ . "\\" . $this->pihandlers[$target];
            $pihandler = new $classname($this);
            return $pihandler->parse($data);
        }
    }

The PIHandler classes will have to parse and process the data in the PI.


Sugestions?

--Moacir

Attachment: dbhtmlhandler.diff.txt
Description: Text document

Attachment: defaultxhtml.diff.txt
Description: Text document

Attachment: format.diff.txt
Description: Text document

Attachment: pihandler.diff.txt
Description: Text document

Attachment: render.diff.txt
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise