Jump to content

serious dilema about MVC architecture


raslin

Recommended Posts

hello guys, i'm building mvc framework just for study,

 

any way, i got this dilema,

 

lets say the controller gets data, and i have to validate it,

 

i have 2 classes (in the model folder)

validation class

send class

 

in the conntroller i can do like that:

 

<?
$data = $_POST['data'];
$valid = new validate;
$data = $valid->validate($data);
$send = new send;
$send->sendit($data);
?>

 

 

and the second option is calling the validate class from the send class like that

 

<?
class send{
var $valid;
var $data
function __donstruct($data){
$this->data = $data;
$valid = new validate;
}

public function sendit(){
$this->valid->validate($this->date)
return $data;
}
}
?>

 

its of course not my MVC i just invented somethid for the demonstration of my architecture dilema.

 

hope to get help, thanks alot!

Link to comment
https://forums.phpfreaks.com/topic/216693-serious-dilema-about-mvc-architecture/
Share on other sites

Use a framework instead of rolling your own. Send makes no sense and Validate is too general.

 

class SomeController extends Zend_Controller_Action {
    function someAction() {
        $form = new SomeForm();
        if($this->_request->isPost()) {
            if($form->isValid()) {
                $form->process();
            }
        }
        $this->view->form = $form;
    }
}

 

An example in Zend framework

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.