.

CreateVotesBaseCommand Class Reference

Comamdn to create a vote. More...

Inheritance diagram for CreateVotesBaseCommand:
CommandChain CommandBase ICommand IAction ISerializable CreateVotesCommand

List of all members.

Public Member Functions

  get_name ()
  Returns title of command.

Protected Member Functions

  aggregate (DAOVotes $vote, $params)
  Aggregates results and saves them.
  do_execute ()
  on_success (DAOVotes $vote)
  Called after vote was created.

Detailed Description

Comamdn to create a vote.

Definition at line 5 of file createvotes.cmd.php.


Member Function Documentation

CreateVotesBaseCommand::aggregate ( DAOVotes vote,
params  
) [protected]

Aggregates results and saves them.

Parameters:
DAOVotes  $vote
array  $params
Returns:
Status

Definition at line 47 of file createvotes.cmd.php.

00047                                                               {
00048                 $aggregate = VotesAggregates::get_for_instance($vote->instance);
00049                 if ($aggregate) {
00050                         // Update
00051                         $this->append(CommandsFactory::create_command($aggregate, 'update', $params));
00052                 }
00053                 else {
00054                         // Create
00055                         $this->append(CommandsFactory::create_command('votesaggregates', 'create', $params));
00056                 }
00057                 
00058                 return new Status();
00059         }
CreateVotesBaseCommand::do_execute (  )  [protected]

Reimplemented from CommandChain.

Definition at line 6 of file createvotes.cmd.php.

00006                                         {
00007                 $params = $this->get_params();
00008                 $ret = new Status();
00009                 
00010                 Load::commands('generics/create');
00011                 $create_cmd = new CreateCommand('votes', $params);
00012                 $ret->merge($create_cmd->execute());
00013                 /* @var $created_vote DAOVotes */
00014                 $created_vote = $create_cmd->get_result();
00015                 $this->set_result($created_vote);
00016                 
00017                 if ($ret->is_ok()) {
00018                         $ret->merge($this->on_success($created_vote));
00019                 }
00020                 if ($ret->is_ok()) {
00021                         $aggr_params = VotesAggregates::aggregate_for_instance($created_vote->instance);
00022                         $ret->merge($this->aggregate($created_vote, $aggr_params));
00023                 }
00024                 return $ret;
00025         }
CreateVotesBaseCommand::get_name (  ) 

Returns title of command.

Reimplemented from CommandBase.

Definition at line 64 of file createvotes.cmd.php.

00064                                    {
00065                 return 'create';
00066         }
CreateVotesBaseCommand::on_success ( DAOVotes vote  )  [protected]

Called after vote was created.

Parameters:
DAOVotes  $vote
Returns:
Status

Definition at line 33 of file createvotes.cmd.php.

00033                                                       {
00034                 Load::commands('generics/clearcache');
00035                 $this->append(new ClearCacheCommand($vote->instance));          
00036                 
00037                 return new Status();
00038         }

The documentation for this class was generated from the following file: