Esempio n. 1
0
 public static function run($action, $parameters = array())
 {
     $command = CommandFactory::getCommand($action);
     $context = new CommandContext();
     foreach ($parameters as $key => $value) {
         $context->addParam($key, $value);
     }
     $command->execute($context);
     return $context;
 }
Esempio n. 2
0
 function execute(CommandContext $context)
 {
     $manager = Registry::getAccessManager();
     $user = $context->get('username');
     $pass = $context->get('pass');
     $user_obj = $manager->login($user, $pass);
     if (is_null($user_obj)) {
         $context->setError($manager->getError());
         return false;
     }
     $context->addParam("user", $user_obj);
     return true;
 }
Esempio n. 3
0
 function execute(CommandContext $context)
 {
     $manager = ReceiverFactory::getAccessManager();
     $user = $context->get('username');
     $pass = $context->get('pass');
     $user = $manager->login($user, $pass);
     if (!$user) {
         $this->context->setError($manager->getError());
         return false;
     }
     $context->addParam("user", $user);
     return true;
 }
Esempio n. 4
0
 function execute(CommandContext $context)
 {
     $msgSystem = ReceiverFactory::getMessageSystem();
     $email = $context->get('email');
     $msg = $context->get('pass');
     $topic = $context->get('topic');
     $result = $msgSystem->despatch($email, $msg, $topic);
     if (!$user) {
         $this->context->setError($msgSystem->getError());
         return false;
     }
     $context->addParam("user", $user);
     return true;
 }
Esempio n. 5
0
 function execute(CommandContext $context)
 {
     $pageMapper = RequestRegistry::getPageMapper();
     $page = null;
     if ($context->get('page-id') != null) {
         $page = $pageMapper->find($context->get('page-id'));
     }
     if ($context->get('page-slug') != null) {
         $page = $pageMapper->findBySlug($context->get('page-slug'));
     }
     if ($page === null) {
         die("need either 'page-slug' or 'page-id' in the command context please!");
     }
     $context->addParam('page', $page);
     return;
 }
Esempio n. 6
0
 function execute(CommandContext $context)
 {
     $albumMapper = RequestRegistry::getAlbumMapper();
     $album = null;
     if ($context->get('album-id') != null) {
         $album = $albumMapper->find($context->get('album-id'));
     }
     if ($context->get('album-slug') != null) {
         $album = $albumMapper->findBySlug($context->get('album-slug'));
     }
     if ($album === null) {
         $error = "Album Not Found, Check that you've sent 'album-id' or 'album-slug' in the command context, and that it's a valid slug/id";
         throw new Exception($error);
     }
     $context->addParam('album', $album);
     return;
 }
 function execute(CommandContext $context)
 {
     $news = RequestRegistry::getNewsEventMapper()->findAllNewsForArchive($context->get('period'));
     $context->addParam('news', $news);
 }
 function execute(CommandContext $context)
 {
     $month = $context->get('month') === null ? date('n') : $context->get('month');
     $year = $context->get('year') === null ? date('Y') : $context->get('year');
     $context->addParam('events', RequestRegistry::getNewsEventMapper()->findAllEventsForMonth($month, $year));
 }
 function execute(CommandContext $context)
 {
     $month = $context->get('month');
     $year = $context->get('year');
     $context->addParam('news', RequestRegistry::getNewsEventMapper()->findAllLiveNewsForMonth($month, $year));
 }
 function execute(CommandContext $context)
 {
     $context->addParam('albums', RequestRegistry::getAlbumMapper()->findAllAlbumsForIndex());
 }
 function execute(CommandContext $context)
 {
     $context->addParam('newsevent', RequestRegistry::getNewsEventMapper()->findMostRecentNews());
 }
 function execute(CommandContext $context)
 {
     $newsevent = RequestRegistry::getNewsEventMapper()->find($context->get('newsevent-id'));
     $context->addParam('newsevent', $newsevent);
 }
Esempio n. 13
0
<?php

require_once "command/LoginCommand.php";
require_once "command/CommandContext.php";
$context = new CommandContext();
$context->addParam("username", "bob");
$context->addParam("pass", "tiddles");
$cmd = new LoginCommand(new AccessManager());
if (!$cmd->execute($context)) {
    print "an error occurred: " . $context->getError();
} else {
    print "successful login\n";
    $user_obj = $context->get("user");
}
 function execute(CommandContext $context)
 {
     $count = $context->get('count') === null ? 5 : $context->get('count');
     $context->addParam('events', RequestRegistry::getNewsEventMapper()->findRecentlyModifiedEvents($count));
 }
Esempio n. 15
0
 function execute(CommandContext $context)
 {
     $context->addParam('news', RequestRegistry::getNewsEventMapper()->findAllNews());
     return;
 }
 function execute(CommandContext $context)
 {
     $year = $context->get('year') === null ? date('Y') : $context->get('year');
     $news = RequestRegistry::getNewsEventMapper()->findAllNewsForYear($year);
     $context->addParam('news', $news);
 }
 function execute(CommandContext $context)
 {
     $news = RequestRegistry::getNewsEventMapper()->findAllRecentNews();
     $context->addParam('news', $news);
 }
 function execute(CommandContext $context)
 {
     $year = $context->get('year') === null ? time('Y') : $context->get('year');
     $context->addParam('events', RequestRegistry::getNewsEventMapper()->findEventsForYear($year));
 }