svn: phd/trunk/phpdotnet/phd/Format/ Factory.php

From: Date: Fri, 17 Jul 2009 04:32:17 +0000
Subject: svn: phd/trunk/phpdotnet/phd/Format/ Factory.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4468@lists.php.net to get a copy of this message
moacir Fri, 17 Jul 2009 04:32:17 +0000 URL: http://svn.php.net/viewvc?view=revision&revision=284233 Changed paths: U phd/trunk/phpdotnet/phd/Format/Factory.php Log: only one creational method Modified: phd/trunk/phpdotnet/phd/Format/Factory.php =================================================================== --- phd/trunk/phpdotnet/phd/Format/Factory.php 2009-07-17 04:26:33 UTC (rev 284232) +++ phd/trunk/phpdotnet/phd/Format/Factory.php 2009-07-17 04:32:17 UTC (rev 284233) @@ -1,36 +1,34 @@ <?php namespace phpdotnet\phd; -abstract class Format_Factory -{ - public function createXhtmlFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); +abstract class Format_Factory { + private $formats = array(); + + public final function getOutputFormats() { + return array_keys($this->formats); } - public function createBigXhtmlFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); + + public final function registerOutputFormats($formats) { + $this->formats = $formats; } - public function createPHPFormat() { + + public final function createFormat($format) { + if (isset($this->formats[$format]) && $this->formats[$format]) { + $classname = __NAMESPACE__ . "\\" . $this->formats[$format]; + + $obj = new $classname(); + if (!($obj instanceof Format)) { + throw new \Exception("All Formats must inherit Format"); + } + return $obj; + } trigger_error("This format is not supported by this package", E_USER_ERROR); } - public function createHowToFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); - } - public function createManpageFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); - } - public function createKDevelopFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); - } - public function createPDFFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); - } - public function createBigPDFFormat() { - trigger_error("This format is not supported by this package", E_USER_ERROR); - } - public static final function createFactory() - { - $package = Config::package(); + public static final function createFactory($package = null) { + if ($package === null) { + $package = Config::package(); + } $classname = __NAMESPACE__ . "\\Package_" . $package . "_Factory"; $factory = new $classname();

« previous php.doc.cvs (#4468) next »