Jump to content

Recommended Posts

Hi all,

 

have constructed a blog through some tutorials which will add and delete messages.  I wish to add some form of confirmation  box with a yes/no button before deleting but am not sure where to begin. 

 

Thanks for any help

 

<?php
// Command_BlogDelete.php

//############################################################################
// SearchVenueCommand class
//############################################################################
class Command_BlogDelete extends Command
{
  //############################################################################
  // doExecute
  //############################################################################ 
  function doExecute(Request $request)
  {
    // Get data from request
    $id = $request->getProperty('id');
    
    // Create manager object
    $manager = new ManagerMessage();    
    
    // Add to database
    $manager->deleteMessage($id);
    
    // Redirect to index
    header("location:index.php");
  }
}

?>

Link to comment
https://forums.phpfreaks.com/topic/216807-object-oriented-php/
Share on other sites

Why you used the Command pattern in a web environment to handle your requests is beyond me, MVC is much better suited.

 

I wish to add some form of confirmation  box with a yes/no button before deleting but am not sure where to begin.

 

Well this is application logic and as such should be handled in the application, that is in your Controller (or in your case the Command). It could be something like:

 

function doExecute(DeleteRequest $request) {
    if($request->isConfirmed()) {
        ..
    }
}

Link to comment
https://forums.phpfreaks.com/topic/216807-object-oriented-php/#findComment-1126335
Share on other sites

Cheers for that,  this was just the way we were required to code it.

 

so i am guessing that the yes/no buttons will be generated in the views/index.php and the result POST'd back?

 

Yup. It should be noted that views are only present in a Model-View-Controller (MVC) architecture, so why you are required to mix patterns is also beyond me. Is this for class?

Link to comment
https://forums.phpfreaks.com/topic/216807-object-oriented-php/#findComment-1126357
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.