The Command Class

Command objects enable your framework to grow flexibly. You can simply drop a class that derives from the Command parent class into a command directory and it automatically becomes available to the system. Listing 24.6 demonstrates the Command class.

Listing 24.6. The Command Class
 1: <? 2: // command/Command.php 3: // qframe license: http://resources.corrosive.co.uk/pkg/qframe/license.txt 4: 5: abstract class Command { 6: const CMD_SUCCESS = 200; 7: const CMD_UNPROCESSED = 400; 8: const CMD_ERROR = 500; 9: 10: final function execute( RequestHelper $requestHelper ) { 11: $status = $this->doExecute( $requestHelper ); 12: $requestHelper->registerCommand( get_class( $this ), $status ); 13: return $status; 14: } 15: 16: abstract ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.