Пример #1
0
 protected function before()
 {
     $this->factory = new Factory();
     $this->factory->setSingleton($this->action->registry);
     $this->access = $this->factory->setSingleton(new AccessControl());
     $this->app = $this->factory->getInstance(WebApplication::class);
     $this->app->prepare();
 }
Пример #2
0
 /**
  * @param Request|WebRequest $request
  * @return \watoki\curir\delivery\WebResponse
  */
 public function respond(Request $request)
 {
     $this->app->prepare($request);
     if (!$this->isContainerTarget($request)) {
         $request = $request->withTarget(Path::fromString('execute'))->withArgument(ExecuteResource::ACTION_ARG, $request->getTarget()->toString());
     }
     return parent::respond($request);
 }
Пример #3
0
 protected function before()
 {
     $factory = new Factory();
     $this->app = $factory->getInstance(WebApplication::class);
     $this->app->prepare();
     $this->app->fields->add(new ActionField($this->app->fields, $this->app->actions));
     $this->app->renderers->add(new PrimitiveRenderer());
     $this->app->fields->add(new StringField());
 }
Пример #4
0
 public function runWebApp()
 {
     WebDelivery::quickResponse(IndexResource::class, WebApplication::init(function (WebApplication $app) {
         $app->name = 'ucdi';
         $app->defaultAction = 'ShowDashboard';
         $this->configureMenu($app);
         $this->registerActions($app);
         $this->registerLinks($app);
     }, WebDelivery::init()));
 }
Пример #5
0
 function restrictAccess()
 {
     $this->action->givenTheAction('foo');
     $this->action->givenTheAction('bar');
     $access = Mockster::of(AccessControl::class);
     Mockster::stub($access->isVisible('bar'))->will()->return_(true);
     WebApplication::init(function (WebApplication $application) use($access) {
         $application->restrictAccess(WebAccessControl::factory(Mockster::mock($access)));
     }, $this->web->factory);
     $this->whenIListTheActions();
     $this->thenThereShouldBe_Actions(1);
     $this->thenAction_ShouldBe(1, 'bar');
 }
Пример #6
0
 private function whenIExecute_With($id, $parameters)
 {
     $this->app->prepare();
     $reader = new FakeParameterReader($parameters);
     $execution = new ExecutionResource($this->app, $reader, new BreadCrumbsTrail($reader, []));
     $this->response = $execution->handleGet($id);
 }
Пример #7
0
<?php

use rtens\blog\Admin;
use rtens\blog\web\IndexResource;
use rtens\domin\delivery\web\WebApplication;
use watoki\curir\WebDelivery;
require_once __DIR__ . '/vendor/autoload.php';
WebDelivery::quickResponse(IndexResource::class, WebDelivery::init(null, WebApplication::init(function (WebApplication $app) {
    Admin::initWeb($app, __DIR__ . '/data');
})));
Пример #8
0
 function redirectToAcquirePermission()
 {
     $this->action->givenTheAction('foo');
     $access = Mockster::of(AccessControl::class);
     Mockster::stub($access->isVisible('foo'))->will()->return_(true);
     WebApplication::init(function (WebApplication $app) use($access) {
         $app->restrictAccess(WebAccessControl::factory(Mockster::mock($access), function (WebRequest $request) {
             return $request->getContext()->appended('acquire_this');
         }));
     }, $this->web->factory);
     $this->whenIExecute('foo');
     $this->assert($this->web->model['redirect'], 'http://example.com/base/acquire_this');
 }