gyro/modules/status/behaviour/commands/generics/status.cmd.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Command to set status 00004 * 00005 * Expects new status as param. 00006 * 00007 * Creates delegate, a command named Status[Newstatus][Object]Command, located in a file named 00008 * status.[newstatus].cmd.php. 00009 * 00010 * If no such command is found, it falls back to 00011 * 00012 * - StatusAny[Object]Command 00013 * - StatusAnyCommand in commands/generics 00014 * 00015 * If an application or module provides an overload, the command should be derived from the 00016 * generic StatusAnyCommand. 00017 00018 * Example: Given a model users that has states UNCONFIRMED and ACTIVE and you want to do 00019 * something special, if status becomes ACTIVE. Create a class StatusActiveUsersCommand in file 00020 * behaviour/commands/users/status.active.cmd.php, derive it from generic StatusAnyCommand and overload 00021 * do_execute(). 00022 * 00023 * @author Gerd Riesselmann 00024 * @ingroup Status 00025 */ 00026 class StatusCommand extends CommandDelegate { 00027 /** 00028 * Constructor 00029 * 00030 * @param unknown_type $obj 00031 * @param unknown_type $params 00032 */ 00033 public function __construct($obj, $params) { 00034 $params = Arr::force($params); 00035 $new_status = String::to_lower(Arr::get_item($params, 0, '')); 00036 if ($new_status == '') { 00037 throw new Exception(tr('Status command called with empty status', 'status')); 00038 exit; 00039 } 00040 $action = 'status.' . $new_status; 00041 $delegate = CommandsFactory::create_command($obj, $action, $params); 00042 if (empty($delegate)) { 00043 $delegate = CommandsFactory::create_command($obj, 'status.any', $params); 00044 } 00045 parent::__construct($delegate); 00046 } 00047 }