Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> MVC - czy to jest zgodne z paradygmatem?
Vomit
post
Post #1





Grupa: Zarejestrowani
Postów: 122
Pomógł: 0
Dołączył: 23.01.2006

Ostrzeżenie: (0%)
-----


Ucze sie pisac w MVC, chce to robic jak najbardziej poprawnie. Spogladajac na framework hwao, ktory niedawno zaprezentował, skleiłem cos takiego:


  1. <?php
  2.  
  3. abstract class Model
  4. {
  5. abstract public function Show();
  6.  
  7. }
  8.  
  9. class Index extends Model
  10. {
  11. public function __construct() {}
  12. public function Show()
  13. {
  14. try
  15. {
  16.  define('OPT_DIR', './opt/');
  17. require(OPT_DIR . 'opt.class.php');
  18.  
  19.  $tpl = new optClass;
  20. $tpl -> root = 'templates/';
  21. $tpl -> compile = 'templates_c/';
  22. $tpl -> assign('index','hahahaha');
  23. $tpl -> parse('index.tpl'); 
  24. }
  25. catch(optException $exception)
  26. { 
  27. optErrorHandler($exception); 
  28. }
  29. }
  30.  
  31. }
  32.  
  33. class Controller
  34. {
  35. private $action;
  36.  
  37. public function __construct() {}
  38.  
  39. public function setAction( $action = 'Index' )
  40. {
  41. $this->action = $action;
  42. }
  43.  
  44. public function Display()
  45. {
  46. $view = new $this->action();
  47. $view->Show();
  48. }
  49.  
  50. }
  51.  
  52.  
  53. $web = new Controller;
  54. $web->setAction();
  55. $web->Display();
  56.  
  57.  
  58. ?>


Czy zachowuje to załozenia MVC? Co powinienem dodac? Czego mi tu brakuje?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 09:10