On Wed, Jan 6, 2010 at 15:40, Moacir de Oliveira <moacirdeoliveira....@gmail.com> wrote: > 2010/1/6 Hannes Magnusson <hannes.magnus...@gmail.com> >> >> Out of curiosity, why does the ::PI section in Render.php not do the >> same as all the others? >> All other handlers do similar to: >> foreach($this as $format) { >> $parsed_value = $format->doStuff($with, $value); >> if ($parsed_value === false) { >> $format->appendData($orginal_value); >> } else { >> $format->appendData($parsed_value); >> } >> } >> But with PI, you have to manually call $this->format->appendData() >> from the PI handler.. it seems wrong. >> > > The PI section is different because is not possible to know what the PI will > do. In case of dbhtml you can modify the file name for chunks, set the > directory to write files etc. so it's not just to append data. But is > possible to use the structure of the other handlers and just return false > when there is no data to append.
Just for consistency, and readability, I think thats a wise choice. The PI handler can manipulate metadata (like filenames) directly and return false when there is nothing todo. However, we need some way of throwing notices when encountering unknown PIs, maybe with checking if the return value is NULL? Or adding PI handlers in the same we as we do element maps, if there is a PI handler for "name" then call that function, otherwise call transformFromPIMap() which eventually does trigger error if it isn't implement? That would improve overall consistency and easier to figure out how everything works for firstimers. -Hannes