Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PostMethodProvider extends Nette\Object
- {
- const RUSSIA = 1;
- private static $methodClasses = array(
- self::RUSSIA => 'RussiaPostMethod',
- ...
- );
- private $db;
- public function __construct($db)
- {
- $this->db = $db;
- }
- public function get($id)
- {
- $package = $this->db->table('packages')->get($id);
- if (isset(self::$methodClasses[$package->postMethod])) {
- $class = self::$methodClasses[$package->postMethod];
- return new $class($this->db, $package);
- }
- throw new InvalidArgumentException('Unknown post method');
- }
- }
- interface PostMethod
- {
- function getDocuments();
- }
- class RussiaPostMethod extends Nette\Object implements PostMethod
- {
- public function getDocuments()
- {
- // russian folder, create template, fill in, generate PDF. ...
- // nebo muzes jenom vrati nejaky array(soubor, parametry)
- // ktery predas jinemu objektu na zpracovani a vyflusne ti to PDFko
- }
- }
- ////// ......
- $postMethodProvider = new PostMethodProvider($db);
- $postMethod = $postMethodProvider->get($idZodkazu);
- $pdfGenerator = new PdfGenerator(...);
- $pdfResponse = $pdfGenerator->generate($postMethod->getDocuments());
- $this->sendResponse($pdfResponse);
Advertisement
Add Comment
Please, Sign In to add comment