/** * @dataProvider providePublishWorkflowChecker */ public function testPublishWorkflowChecker($expected, $attributes, $content, $isMenuPusblishable, $isContentPublishable) { $attributes = (array) $attributes; $menuNode = $this->getMock('Symfony\\Cmf\\Bundle\\MenuBundle\\Model\\MenuNode'); $menuNode->expects($this->any())->method('getContent')->will($this->returnValue($content)); $this->pwfc->expects($this->any())->method('isGranted')->will($this->returnValue($isContentPublishable)); $this->assertEquals($expected, $this->voter->vote($this->token, $menuNode, $attributes)); }
/** * Handling the request event. * * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); $route = $request->attributes->get(DynamicRouter::ROUTE_KEY); if ($route && !$this->publishWorkflowChecker->isGranted($this->getPublishWorkflowPermission(), $route)) { throw new NotFoundHttpException('Route not found at: ' . $request->getPathInfo()); } $content = $request->attributes->get(DynamicRouter::CONTENT_KEY); if ($content && !$this->publishWorkflowChecker->isGranted($this->getPublishWorkflowPermission(), $content)) { throw new NotFoundHttpException('Content not found for: ' . $request->getPathInfo()); } }
/** * {@inheritdoc} * * @param object $object */ public function vote(TokenInterface $token, $object, array $attributes) { if (!$this->supportsClass(get_class($object))) { return self::ACCESS_ABSTAIN; } foreach ($attributes as $attribute) { if (!$this->supportsAttribute($attribute)) { return self::ACCESS_ABSTAIN; } } if ($this->publishWorkflowChecker->isGranted($attributes, $object)) { return self::ACCESS_GRANTED; } return self::ACCESS_DENIED; }
public function testSupportsClass() { $class = 'Test\\Class'; $this->adm->shouldReceive('supportsClass')->once()->with($class)->andReturn(true); $this->assertTrue($this->pwfc->supportsClass($class)); }
public function testSupportsClass() { $class = 'Test\\Class'; $this->adm->expects($this->once())->method('supportsClass')->with($class)->will($this->returnValue(true)); $this->assertTrue($this->pwfc->supportsClass($class)); }
/** * {@inheritdoc} */ public function exposeOnSitemap($content, $sitemap) { return $this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $content); }