Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enahncement/renamed request analyzer methods #749

Merged
merged 1 commit into from
Feb 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ anything else. See the [HTTP cache
documentation](http://sulu.readthedocs.org/en/latest/reference/bundles/http_cache.html)
for more information.

### Renamed RequestAnalyzerInterface methods

The text "Current" has been removed from all of the request analyzer methods.
If you used the request analyzer service then you will probably need to update
your code, see: https://github.com/sulu-cmf/sulu/pull/749/files#diff-23

## 0.14.0

* Role name is now unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ protected function getRepository()
public function getSecurityContext()
{
$requestAnalyzer = $this->get('sulu_core.webspace.request_analyzer.admin');
$webspace = $requestAnalyzer->getCurrentWebspace();
$webspace = $requestAnalyzer->getWebspace();

if ($webspace) {
return 'sulu.webspaces.' . $webspace->getKey();
Expand Down
2 changes: 1 addition & 1 deletion src/Sulu/Bundle/SearchBundle/EventListener/HitListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function onHit(HitEvent $event)
$document = $event->getHit()->getDocument();
$url = sprintf(
'%s/%s',
rtrim($this->requestAnalyzer->getCurrentResourceLocatorPrefix(), '/'),
rtrim($this->requestAnalyzer->getResourceLocatorPrefix(), '/'),
ltrim($document->getUrl(), '/')
);
$document->setUrl($url);
Expand Down
6 changes: 3 additions & 3 deletions src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ protected function getSystem()
$system = $this->suluSystem;
if (
$this->requestAnalyzer != null &&
$this->requestAnalyzer->getCurrentWebspace() !== null &&
$this->requestAnalyzer->getCurrentWebspace()->getSecurity() !== null
$this->requestAnalyzer->getWebspace() !== null &&
$this->requestAnalyzer->getWebspace()->getSecurity() !== null
) {
// if the request analyzer is available, overwrite the system
$system = $this->requestAnalyzer->getCurrentWebspace()->getSecurity()->getSystem();
$system = $this->requestAnalyzer->getWebspace()->getSecurity()->getSystem();
}

return $system;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testFindBySystem()
// $repo = $em->getRepository('Sulu\Bundle\SecurityBundle\Entity\User');
// $employees = $repo->getUserInSystem();
//
// // FIXME alternative would be to get the container via the factory but there following in the repo is null $this->requestAnalyzer->getCurrentWebspace()
// // FIXME alternative would be to get the container via the factory but there following in the repo is null $this->requestAnalyzer->getWebspace()
// $repo = $client->getContainer()->get('sulu_security.user_repository_factory')->getRepository();
//
// $this->assertEquals(1, count($employees));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function loadSnippet($uuid, $locale = null)
$locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization();
}

$snippet = $this->contentMapper->load($uuid, $this->requestAnalyzer->getCurrentWebspace()->getKey(), $locale);
$snippet = $this->contentMapper->load($uuid, $this->requestAnalyzer->getWebspace()->getKey(), $locale);

return $this->structureResolver->resolve($snippet);
}
Expand Down
18 changes: 9 additions & 9 deletions src/Sulu/Bundle/WebsiteBundle/Controller/ExceptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public function showAction(
'ClientWebsiteBundle:views:error404.html.twig',
array(
'request' => array(
'webspaceKey' => $this->requestAnalyzer->getCurrentWebspace()->getKey(),
'locale' => $this->requestAnalyzer->getCurrentLocalization()->getLocalization(),
'portalUrl' => $this->requestAnalyzer->getCurrentPortalUrl(),
'resourceLocatorPrefix' => $this->requestAnalyzer->getCurrentResourceLocatorPrefix(),
'resourceLocator' => $this->requestAnalyzer->getCurrentResourceLocator(),
'get' => $this->requestAnalyzer->getCurrentGetParameter(),
'post' => $this->requestAnalyzer->getCurrentPostParameter(),
'analyticsKey' => $this->requestAnalyzer->getCurrentAnalyticsKey(),
'webspaceKey' => $this->requestAnalyzer->getWebspace()->getKey(),
'locale' => $this->requestAnalyzer->getCurrentLocalization(),
'portalUrl' => $this->requestAnalyzer->getPortalUrl(),
'resourceLocatorPrefix' => $this->requestAnalyzer->getResourceLocatorPrefix(),
'resourceLocator' => $this->requestAnalyzer->getResourceLocator(),
'get' => $this->requestAnalyzer->getGetParameters(),
'post' => $this->requestAnalyzer->getPostParameters()
'analyticsKey' => $this->requestAnalyzer->getAnalyticsKey(),
),
'path' => $request->getPathInfo()
)
Expand All @@ -80,7 +80,7 @@ public function showAction(
'exception' => $exception,
'currentContent' => $currentContent,
'request' => array(
'webspaceKey' => $this->requestAnalyzer->getCurrentWebspace()->getKey(),
'webspaceKey' => $this->requestAnalyzer->getWebspace()->getKey(),
'locale' => $this->requestAnalyzer->getCurrentLocalization()->getLocalization()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function indexAction()
/** @var SitemapGeneratorInterface $sitemapGenerator */
$sitemapGenerator = $this->get('sulu_website.sitemap');

$webspace = $requestAnalyzer->getCurrentWebspace();
$currentPortal = $requestAnalyzer->getCurrentPortal();
$webspace = $requestAnalyzer->getWebspace();
$currentPortal = $requestAnalyzer->getPortal();
$defaultLocale = null;
if ($currentPortal !== null && ($defaultLocale = $currentPortal->getDefaultLocalization()) !== null) {
$defaultLocale = $defaultLocale->getLocalization();
Expand All @@ -47,7 +47,7 @@ public function indexAction()
$response->headers->set('Content-Type', 'text/xml');

$localizations = array();
foreach ($requestAnalyzer->getCurrentPortal()->getLocalizations() as $localization) {
foreach ($requestAnalyzer->getPortal()->getLocalizations() as $localization) {
$localizations[] = $localization->getLocalization();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ protected function getAttributes($attributes, StructureInterface $structure = nu
->resolveForPreview($structure->getWebspaceKey(), $structure->getLanguageCode());
}

if (null !== ($portal = $requestAnalyzer->getCurrentPortal())) {
if (null !== ($portal = $requestAnalyzer->getPortal())) {
$allLocalizations = $portal->getLocalizations();
} else {
$allLocalizations = $requestAnalyzer->getCurrentWebspace()->getLocalizations();
$allLocalizations = $requestAnalyzer->getWebspace()->getLocalizations();
}

$urls = array_key_exists('urls', $structureData) ? $structureData['urls'] : array();
Expand Down
16 changes: 8 additions & 8 deletions src/Sulu/Bundle/WebsiteBundle/DataCollector/SuluCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public function collect(Request $request, Response $response, \Exception $except
{
$requestAnalyzer = $this->requestAnalyzer;

$webspace = $requestAnalyzer->getCurrentWebspace();
$portal = $requestAnalyzer->getCurrentPortal();
$segment = $requestAnalyzer->getCurrentSegment();
$webspace = $requestAnalyzer->getWebspace();
$portal = $requestAnalyzer->getPortal();
$segment = $requestAnalyzer->getSegment();

$this->data['match_type'] = $requestAnalyzer->getCurrentMatchType();
$this->data['redirect'] = $requestAnalyzer->getCurrentRedirect();
$this->data['portal_url'] = $requestAnalyzer->getCurrentPortalUrl();
$this->data['match_type'] = $requestAnalyzer->getMatchType();
$this->data['redirect'] = $requestAnalyzer->getRedirect();
$this->data['portal_url'] = $requestAnalyzer->getPortalUrl();

if ($webspace) {
$this->data['webspace'] = $webspace->toArray();
Expand All @@ -55,8 +55,8 @@ public function collect(Request $request, Response $response, \Exception $except
}

$this->data['localization'] = $requestAnalyzer->getCurrentLocalization();
$this->data['resource_locator'] = $requestAnalyzer->getCurrentResourceLocator();
$this->data['resource_locator_prefix'] = $requestAnalyzer->getCurrentResourceLocatorPrefix();
$this->data['resource_locator'] = $requestAnalyzer->getResourceLocator();
$this->data['resource_locator_prefix'] = $requestAnalyzer->getResourceLocatorPrefix();

$structure = null;
if ($request->attributes->has('_route_params')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
*/
public function onKernelRequest(GetResponseEvent $event)
{
$portal = $this->requestAnalyzer->getCurrentPortal();
$portal = $this->requestAnalyzer->getPortal();

if (null === $portal) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ public function __construct(WebspaceManagerInterface $webspaceManager, $environm
public function resolve(RequestAnalyzerInterface $requestAnalyzer)
{
// determine default locale (if one exists)
$defaultLocalization = $requestAnalyzer->getCurrentPortal()->getDefaultLocalization();
$defaultLocalization = $requestAnalyzer->getPortal()->getDefaultLocalization();
$defaultLocale = $defaultLocalization ? $defaultLocalization->getLocalization() : null;

return array(
'request' => array(
'webspaceKey' => $requestAnalyzer->getCurrentWebspace()->getKey(),
'webspaceKey' => $requestAnalyzer->getWebspace()->getKey(),
'defaultLocale' => $defaultLocale,
'locale' => $requestAnalyzer->getCurrentLocalization()->getLocalization(),
'portalUrl' => $requestAnalyzer->getCurrentPortalUrl(),
'resourceLocatorPrefix' => $requestAnalyzer->getCurrentResourceLocatorPrefix(),
'resourceLocator' => $requestAnalyzer->getCurrentResourceLocator(),
'get' => $requestAnalyzer->getCurrentGetParameter(),
'post' => $requestAnalyzer->getCurrentPostParameter(),
'analyticsKey' => $requestAnalyzer->getCurrentAnalyticsKey(),
'portalUrl' => $requestAnalyzer->getPortalUrl(),
'resourceLocatorPrefix' => $requestAnalyzer->getResourceLocatorPrefix(),
'resourceLocator' => $requestAnalyzer->getResourceLocator(),
'get' => $requestAnalyzer->getGetParameters(),
'post' => $requestAnalyzer->getPostParameters(),
'analyticsKey' => $requestAnalyzer->getAnalyticsKey(),
)
);
}
Expand Down
22 changes: 11 additions & 11 deletions src/Sulu/Bundle/WebsiteBundle/Routing/ContentRouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ public function getRouteCollectionForRequest(Request $request)
$collection = new RouteCollection();

$htmlExtension = '.html';
$resourceLocator = $this->requestAnalyzer->getCurrentResourceLocator();
$resourceLocator = $this->requestAnalyzer->getResourceLocator();

if ($this->requestAnalyzer->getCurrentMatchType() == RequestAnalyzerInterface::MATCH_TYPE_REDIRECT
|| $this->requestAnalyzer->getCurrentMatchType() == RequestAnalyzerInterface::MATCH_TYPE_PARTIAL
if ($this->requestAnalyzer->getMatchType() == RequestAnalyzerInterface::MATCH_TYPE_REDIRECT
|| $this->requestAnalyzer->getMatchType() == RequestAnalyzerInterface::MATCH_TYPE_PARTIAL
) {
// redirect by information from webspace config
$route = new Route(
$request->getRequestUri(), array(
'_controller' => 'SuluWebsiteBundle:Default:redirectWebspace',
'url' => $this->requestAnalyzer->getCurrentPortalUrl(),
'redirect' => $this->requestAnalyzer->getCurrentRedirect()
'url' => $this->requestAnalyzer->getPortalUrl(),
'redirect' => $this->requestAnalyzer->getRedirect()
)
);

Expand All @@ -82,7 +82,7 @@ public function getRouteCollectionForRequest(Request $request)
substr($request->getPathInfo(), -strlen($htmlExtension)) === $htmlExtension
) {
$url = rtrim(
$this->requestAnalyzer->getCurrentResourceLocatorPrefix() . ($resourceLocator ? $resourceLocator : '/'),
$this->requestAnalyzer->getResourceLocatorPrefix() . ($resourceLocator ? $resourceLocator : '/'),
'/'
);

Expand All @@ -97,7 +97,7 @@ public function getRouteCollectionForRequest(Request $request)
$collection->add('redirect_' . uniqid(), $route);
} else {
// just show the page
$portal = $this->requestAnalyzer->getCurrentPortal();
$portal = $this->requestAnalyzer->getPortal();
$language = $this->requestAnalyzer->getCurrentLocalization()->getLocalization();

try {
Expand All @@ -115,7 +115,7 @@ public function getRouteCollectionForRequest(Request $request)
$route = new Route(
$request->getRequestUri(), array(
'_controller' => 'SuluWebsiteBundle:Default:redirect',
'url' => $this->requestAnalyzer->getCurrentResourceLocatorPrefix() . $content->getResourceLocator()
'url' => $this->requestAnalyzer->getResourceLocatorPrefix() . $content->getResourceLocator()
)
);

Expand All @@ -139,7 +139,7 @@ public function getRouteCollectionForRequest(Request $request)
} catch (ResourceLocatorNotFoundException $exc) {
// just do not add any routes to the collection
} catch (ResourceLocatorMovedException $exc) {
$newUrl = $this->requestAnalyzer->getCurrentResourceLocatorPrefix() . $exc->getNewResourceLocator();
$newUrl = $this->requestAnalyzer->getResourceLocatorPrefix() . $exc->getNewResourceLocator();

// redirect to new url
$route = new Route(
Expand Down Expand Up @@ -208,7 +208,7 @@ public function getRoutesByNames($names, $parameters = array())
*/
private function checkResourceLocator()
{
return !($this->requestAnalyzer->getCurrentResourceLocator() === '/'
&& $this->requestAnalyzer->getCurrentResourceLocatorPrefix());
return !($this->requestAnalyzer->getResourceLocator() === '/'
&& $this->requestAnalyzer->getResourceLocatorPrefix());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public function testCollectorNoComplexObjects()

public function testCollector()
{
$this->requestAnalyzer->getCurrentPortal()->willReturn($this->portal);
$this->requestAnalyzer->getCurrentWebspace()->willReturn($this->webspace);
$this->requestAnalyzer->getCurrentSegment()->willReturn($this->segment);
$this->requestAnalyzer->getCurrentMatchType()->willReturn('match');
$this->requestAnalyzer->getCurrentRedirect()->willReturn('red');
$this->requestAnalyzer->getCurrentPortalUrl()->willReturn('/foo');
$this->requestAnalyzer->getPortal()->willReturn($this->portal);
$this->requestAnalyzer->getWebspace()->willReturn($this->webspace);
$this->requestAnalyzer->getSegment()->willReturn($this->segment);
$this->requestAnalyzer->getMatchType()->willReturn('match');
$this->requestAnalyzer->getRedirect()->willReturn('red');
$this->requestAnalyzer->getPortalUrl()->willReturn('/foo');

$this->requestAnalyzer->getCurrentLocalization()->willReturn('de_de');
$this->requestAnalyzer->getCurrentResourceLocator()->willReturn('/asd');
$this->requestAnalyzer->getCurrentResourceLocatorPrefix()->willReturn('/asd/');
$this->requestAnalyzer->getResourceLocator()->willReturn('/asd');
$this->requestAnalyzer->getResourceLocatorPrefix()->willReturn('/asd/');
$this->request->attributes->set('_route_params', array('structure' => $this->structure->reveal()));

$this->dataCollector->collect($this->request, $this->response->reveal());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function setUp()
public function testEventListener()
{
$this->requestAnalyzer->expects($this->once())
->method('getCurrentPortal')
->method('getPortal')
->will($this->returnValue($this->portal));
$this->portal->expects($this->once())
->method('getWebspace')
Expand All @@ -48,7 +48,7 @@ public function testEventListener()
public function testEventListenerNotMaster()
{
$this->requestAnalyzer->expects($this->once())
->method('getCurrentPortal')
->method('getPortal')
->willReturn(null);
$this->webspace->expects($this->never())
->method('getTheme');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ public function testResolve()
$localization->setCountry('at');

$requestAnalyzer = $this->prophesize('Sulu\Component\Webspace\Analyzer\WebsiteRequestAnalyzer');
$requestAnalyzer->getCurrentWebspace()->willReturn($webspace);
$requestAnalyzer->getWebspace()->willReturn($webspace);
$requestAnalyzer->getCurrentLocalization()->willReturn($localization);
$requestAnalyzer->getCurrentPortalUrl()->willReturn('sulu.io/de');
$requestAnalyzer->getCurrentResourceLocatorPrefix()->willReturn('/de');
$requestAnalyzer->getCurrentResourceLocator()->willReturn('/search');
$requestAnalyzer->getCurrentGetParameter()->willReturn(array('p' => 1));
$requestAnalyzer->getCurrentPostParameter()->willReturn(array());
$requestAnalyzer->getCurrentPortal()->willReturn($portal);
$requestAnalyzer->getCurrentAnalyticsKey()->willReturn('analyticsKey');
$requestAnalyzer->getPortalUrl()->willReturn('sulu.io/de');
$requestAnalyzer->getResourceLocatorPrefix()->willReturn('/de');
$requestAnalyzer->getResourceLocator()->willReturn('/search');
$requestAnalyzer->getGetParameters()->willReturn(array('p' => 1));
$requestAnalyzer->getPostParameters()->willReturn(array());
$requestAnalyzer->getPortal()->willReturn($portal);
$requestAnalyzer->getAnalyticsKey()->willReturn('analyticsKey');

$result = $this->resolver->resolve($requestAnalyzer->reveal());
$this->assertEquals(
Expand Down
Loading