Exemple #1
0
 protected function entry($dataContainer)
 {
     defined('_WEXEC') or die("Access denied");
     self::$uid = $_SESSION['uid'];
     $this->_smarty = $dataContainer->getSmarty();
     $this->_interface = new WebInterface($this->_smarty);
     $this->_userManager = new UserManager();
 }
Exemple #2
0
use AddressBook\Command\CreateContact;
use AddressBook\Command\ChangeContactEmail;
use AddressBook\Command\DeleteContact;
$app = new Application();
$queryDB = new SQLDriver();
$eventStore = new EventStore();
$eventity = Eventity::getInstance();
$denormaliser = new Denormaliser($queryDB);
$eventity->registerListener(new EventStoreListener($eventStore));
$eventity->registerListener($denormaliser);
$contactRepository = new ContactRepository($eventStore, $eventity);
$app->get('/contacts', function () use($queryDB) {
    $query = new ListContacts($queryDB);
    return $query->execute();
});
$app->get('/contacts/:id', function ($id) use($queryDB) {
    $query = new ViewContact($queryDB, $id);
    return $query->execute();
});
$app->post('/contacts', function (Request $request) use($eventity) {
    $command = new CreateContact($eventity->getFactoryFor(Contact::class), $request->getPost('name'), $request->getPost('email'));
    return $command->execute();
});
$app->post('/contacts/:id/change-email', function (Request $request, $id) use($contactRepository) {
    $command = new ChangeEmail($contactRepository, $id, $request->getPost('email'));
    return $command->execute();
});
$app->post('/contacts/:id/delete', function (Request $request, $id) use($contactRepository) {
    $command = new DeleteContact($contactRepository, $id);
    return $command->execute();
});