public function setUp()
 {
     $this->controller = $controller = new ResourceController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch(array()));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new Plugin\HalLinks();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $pluginManager->setService('HalLinks', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
示例#2
0
 public function setUp()
 {
     $routerClass = class_exists(V2TreeRouteStack::class) ? V2TreeRouteStack::class : TreeRouteStack::class;
     $routeClass = class_exists(V2Segment::class) ? V2Segment::class : Segment::class;
     $this->router = $router = new $routerClass();
     $route = new $routeClass('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $route2 = new $routeClass('/help');
     $router->addRoute('docs', $route2);
     $router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]'], 'may_terminate' => true, 'child_routes' => ['children' => ['type' => 'literal', 'options' => ['route' => '/children']]]], 'users' => ['type' => 'segment', 'options' => ['route' => '/users[/:id]']], 'contacts' => ['type' => 'segment', 'options' => ['route' => '/contacts[/:id]']], 'embedded' => ['type' => 'segment', 'options' => ['route' => '/embedded[/:id]']], 'embedded_custom' => ['type' => 'segment', 'options' => ['route' => '/embedded_custom[/:custom_id]']]]]);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $router->setRequestUri(new Http('http://localhost.localdomain/resource'));
     $controller = $this->controller = $this->prophesize(AbstractRestfulController::class);
     $controller->getEvent()->willReturn($event);
     $this->urlHelper = $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $this->serverUrlHelper = $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->plugin = $plugin = new HalHelper();
     $plugin->setController($controller->reveal());
     $linkUrlBuilder = new LinkUrlBuilder($serverUrlHelper, $urlHelper);
     $plugin->setLinkUrlBuilder($linkUrlBuilder);
     $linkExtractor = new LinkExtractor($linkUrlBuilder);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $plugin->setLinkCollectionExtractor($linkCollectionExtractor);
 }
示例#3
0
 public function setUp()
 {
     $this->router = $router = new TreeRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $route2 = new Segment('/help');
     $router->addRoute('docs', $route2);
     $router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]'], 'may_terminate' => true, 'child_routes' => ['children' => ['type' => 'literal', 'options' => ['route' => '/children']]]], 'users' => ['type' => 'segment', 'options' => ['route' => '/users[/:id]']], 'contacts' => ['type' => 'segment', 'options' => ['route' => '/contacts[/:id]']], 'embedded' => ['type' => 'segment', 'options' => ['route' => '/embedded[/:id]']], 'embedded_custom' => ['type' => 'segment', 'options' => ['route' => '/embedded_custom[/:custom_id]']]]]);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $router->setRequestUri(new Http('http://localhost.localdomain/resource'));
     $controller = $this->controller = $this->getMock('Zend\\Mvc\\Controller\\AbstractRestfulController');
     $controller->expects($this->any())->method('getEvent')->will($this->returnValue($event));
     $this->urlHelper = $urlHelper = new UrlHelper();
     $urlHelper->setRouter($router);
     $this->serverUrlHelper = $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->plugin = $plugin = new HalHelper();
     $plugin->setController($controller);
     $plugin->setUrlHelper($urlHelper);
     $plugin->setServerUrlHelper($serverUrlHelper);
     $linkExtractor = new LinkExtractor($serverUrlHelper, $urlHelper);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $plugin->setLinkCollectionExtractor($linkCollectionExtractor);
 }
 public function setUp()
 {
     $this->controller = $controller = new RestController();
     $this->router = $router = new SimpleRouteStack();
     $route = new Segment('/resource[/[:id]]');
     $router->addRoute('resource', $route);
     $this->event = $event = new MvcEvent();
     $event->setRouter($router);
     $event->setRouteMatch(new RouteMatch([]));
     $controller->setEvent($event);
     $controller->setRoute('resource');
     $pluginManager = new PluginManager();
     $pluginManager->setService('bodyParams', new BodyParams());
     $controller->setPluginManager($pluginManager);
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $linksHelper = new HalHelper();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $linkExtractor = new LinkExtractor($serverUrlHelper, $urlHelper);
     $linkCollectionExtractor = new LinkCollectionExtractor($linkExtractor);
     $linksHelper->setLinkCollectionExtractor($linkCollectionExtractor);
     $pluginManager->setService('Hal', $linksHelper);
     $linksHelper->setController($controller);
     $this->resource = $resource = new Resource();
     $controller->setResource($resource);
 }
    public function setupHelpers()
    {
        if (!$this->router) {
            $this->setupRouter();
        }

        $urlHelper = new UrlHelper();
        $urlHelper->setRouter($this->router);

        $serverUrlHelper = new ServerUrlHelper();
        $serverUrlHelper->setScheme('http');
        $serverUrlHelper->setHost('localhost.localdomain');

        $linksHelper = new HalHelper();
        $linksHelper->setUrlHelper($urlHelper);
        $linksHelper->setServerUrlHelper($serverUrlHelper);

        $this->helpers = $helpers = new HelperPluginManager();
        $helpers->setService('url', $urlHelper);
        $helpers->setService('serverUrl', $serverUrlHelper);
        $helpers->setService('hal', $linksHelper);

        $this->plugins = $plugins = new ControllerPluginManager();
        $plugins->setService('hal', $linksHelper);
    }
 public function setUpHelpers()
 {
     if (isset($this->helpers)) {
         return;
     }
     $this->setupRouter();
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $this->linksHelper = $linksHelper = new HalHelper();
     $linksHelper->setUrlHelper($urlHelper);
     $linksHelper->setServerUrlHelper($serverUrlHelper);
     $this->helpers = $helpers = new HelperPluginManager();
     $helpers->setService('url', $urlHelper);
     $helpers->setService('serverUrl', $serverUrlHelper);
     $helpers->setService('hal', $linksHelper);
 }
 public function setupHelpers()
 {
     if (!$this->router) {
         $this->setupRouter();
     }
     $urlHelper = new UrlHelper();
     $urlHelper->setRouter($this->router);
     $serverUrlHelper = new ServerUrlHelper();
     $serverUrlHelper->setScheme('http');
     $serverUrlHelper->setHost('localhost.localdomain');
     $propertiesHelper = new JsonLDHelper();
     $propertiesHelper->setUrlHelper($urlHelper);
     $propertiesHelper->setServerUrlHelper($serverUrlHelper);
     $propertyExtractor = new PropertyExtractor($serverUrlHelper, $urlHelper);
     $propertyCollectionExtractor = new PropertyCollectionExtractor($propertyExtractor);
     $propertiesHelper->setPropertyCollectionExtractor($propertyCollectionExtractor);
     $this->helpers = $helpers = new HelperPluginManager();
     $helpers->setService('url', $urlHelper);
     $helpers->setService('serverUrl', $serverUrlHelper);
     $helpers->setService('JsonLD', $propertiesHelper);
     $this->plugins = $plugins = new ControllerPluginManager();
     $plugins->setService('JsonLD', $propertiesHelper);
 }
示例#8
0
 /**
  * @param ServerUrl     $serverUrlHelper
  * @param ModuleOptions $moduleOptions
  */
 protected function injectServerUrl(ServerUrl $serverUrlHelper, ModuleOptions $moduleOptions)
 {
     $options = parse_url($moduleOptions->getLocation());
     $serverUrlHelper->setScheme($options['scheme']);
     $serverUrlHelper->setHost($options['host']);
 }