Пример #1
0
 protected function before()
 {
     $this->links = new LinkRegistry();
     $this->actions = new ActionRegistry();
     $printer = new LinkPrinter(Url::fromString('http://example.com/base'), $this->links, $this->actions, new WebCommentParser());
     $this->renderer = new IdentifierRenderer($printer);
 }
Пример #2
0
 function __construct()
 {
     $this->headers = new Map();
     $this->arguments = new Map();
     $this->target = new Path();
     $this->context = Url::fromString('http://example.com');
 }
Пример #3
0
 protected function before()
 {
     $this->renderers = new RendererRegistry();
     $this->links = new LinkRegistry();
     $this->actions = new ActionRegistry();
     $this->renderer = new ObjectRenderer($this->renderers, new TypeFactory(), new LinkPrinter(Url::fromString('baser/url'), $this->links, $this->actions, new WebCommentParser()));
 }
Пример #4
0
 /**
  * @param WebRequest $request
  * @return Url
  */
 private function getAbsoluteTarget(WebRequest $request)
 {
     $target = $this->getTarget();
     if ($target->isAbsolute()) {
         return $target;
     }
     return Url::fromString($request->getContext() . '/' . $target);
 }
Пример #5
0
 protected function before()
 {
     $this->renderers = new RendererRegistry();
     $this->types = new TypeFactory();
     $this->links = new LinkRegistry();
     $this->actions = new ActionRegistry();
     $parser = new WebCommentParser();
     $this->printer = new LinkPrinter(Url::fromString('http://example.com/base'), $this->links, $this->actions, $parser);
     $this->tableRenderer = new TableRenderer($this->renderers, $this->printer);
 }
Пример #6
0
 public function before()
 {
     $this->calendar = Mockster::of(Calendar::class);
     $this->store = new EventStore();
     $this->uid = new FakeUidGenerator();
     $this->baseUrl = Url::fromString('http://example.com/ucdi');
     $this->givenNowIs('now');
     Mockster::stub($this->calendar->insertEvent(Arg::any(), Arg::any(), Arg::any(), Arg::any(), Arg::any()))->will()->call(function ($args) {
         return 'Event-' . $args['summary'];
     });
 }
Пример #7
0
 private function makeRequest($parameters = [])
 {
     return new WebRequest(Url::fromString('http://example.com/base'), new Path(), null, new Map($parameters));
 }
Пример #8
0
 protected function assembleAction(ActionLink $action)
 {
     $representer = $this->registry->getActionRepresenter($action->getClass());
     $target = Url::fromString($representer->getResourceUrl())->withParameter('action', $action->getClass())->withParameter('args', $action->getArguments());
     return ['caption' => $representer->render(), 'link' => ['href' => $target->toString(), 'onclick' => $representer->requiresConfirmation() ? "return confirm('" . $representer->requiresConfirmation() . "');" : 'return true;']];
 }
Пример #9
0
 protected function determineContext($server)
 {
     $scheme = "http" . (!empty($server['HTTPS']) ? "s" : "");
     if (isset($server['HTTP_HOST'])) {
         $host = $server['HTTP_HOST'];
     } else {
         $host = $server['SERVER_NAME'] . ($server['SERVER_PORT'] != 80 ? ':' . $server['SERVER_PORT'] : '');
     }
     list($context, ) = $this->splitContextAndTarget($server);
     return Url::fromString($scheme . "://" . $host . rtrim($context, '/'));
 }
Пример #10
0
 public function givenTheContextIs($string)
 {
     $this->request->setContext(Url::fromString($string));
 }
Пример #11
0
 private function whenIRenderTheMenu()
 {
     $this->rendered = (string) $this->menu->render(new WebRequest(Url::fromString('http://example.com/base'), new Path()));
 }
Пример #12
0
 private function wrapAsset(Element $element, $attributeName)
 {
     $attribute = $element->getAttribute($attributeName);
     if (!$attribute) {
         return;
     }
     $url = Url::fromString($attribute->getValue());
     if ($url->isAbsolute()) {
         return;
     }
     $path = $url->getPath();
     $path->insertAll($this->path->slice(0, -1), 0);
     $url->setPath($path);
     $element->setAttribute($attributeName, $url->toString());
 }
Пример #13
0
 /**
  * @return Url
  */
 public function getResourceUrl()
 {
     return Url::fromString('execute');
 }
Пример #14
0
 public function givenTheContextIs($string)
 {
     $this->environment->context = Url::fromString($string);
 }
Пример #15
0
 private function wrapTarget($target, $name, $next, WebRequest $request)
 {
     $targetUrl = Url::fromString($target);
     if ($targetUrl->isAbsolute()) {
         $context = $request->getContext()->toString();
         $target = ltrim(substr($target, strlen($context)), '/');
     }
     $model = '<a href="' . $target . '"/>';
     $wrapped = $this->wrap($name, $model, $next, $request);
     $wrappedTarget = Url::fromString(substr($wrapped, 9, -3));
     foreach ($request->getArguments() as $key => $value) {
         if ($key != Wrapper::$PREFIX . $name) {
             $wrappedTarget->getParameters()->set($key, $value);
         }
     }
     return $wrappedTarget->toString();
 }
Пример #16
0
 /**
  * @param null|string|Url $url
  */
 public function setResourceUrl($url)
 {
     if (is_string($url)) {
         $url = Url::fromString($url);
     }
     $this->resourceUrl = $url;
 }
Пример #17
0
 public function before()
 {
     $this->request = new WebRequest(Url::fromString('http://example.com/base'), Path::fromString(''), 'get', new Map(), new Liste(['null']));
     $this->factory = WebDelivery::init();
 }
Пример #18
0
}
if (isset($_GET['code'])) {
    $client->authenticate($_GET['code']);
    $_SESSION['token'] = $client->getAccessToken();
    header('Location: ' . ($_SESSION['targetUrl'] ?: '/'));
    exit;
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
$redirectToAuthUrl = function () use($client) {
    $_SESSION['targetUrl'] = (string) Url::fromString($_SERVER['REQUEST_URI'])->withParameters(Collection::toCollections($_REQUEST));
    $authUrl = $client->createAuthUrl();
    header('Location: ' . $authUrl);
    exit;
};
if (!$client->getAccessToken()) {
    $redirectToAuthUrl();
}
$cal = new Google_Service_Calendar($client);
$info = new Google_Service_Oauth2($client);
try {
    $userId = $info->userinfo->get()->email;
    $userDir = __DIR__ . '/user/' . $userId;
    $settingsStore = new SettingsStore($userDir);
    $calendar = new GoogleCalendar($cal, $settingsStore->read()->calendarId);
    (new Bootstrapper($userDir, $userId, Url::fromString(dirname($baseUrl)), $calendar, $settingsStore))->runWebApp();
} catch (Google_Auth_Exception $e) {
    unset($_SESSION['token']);
    $redirectToAuthUrl();
}
Пример #19
0
 public function whenICreateTheResponse()
 {
     $request = new WebRequest(Url::fromString('curir'), new Path(), null, null, new Liste($this->formats));
     $this->response = $this->responder->createResponse($request);
 }