Example #1
0
 /**
  * @test
  */
 public function renderCallsIconFactoryWithGivenOverlayAndReturnsResult()
 {
     $iconFactoryProphecy = $this->prophesize(IconFactory::class);
     GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
     $iconProphecy = $this->prophesize(Icon::class);
     $iconFactoryProphecy->getIcon('myIdentifier', Argument::any(), 'overlayString', IconState::cast(IconState::STATE_DEFAULT))->shouldBeCalled()->willReturn($iconProphecy->reveal());
     $iconProphecy->render(NULL)->shouldBeCalled()->willReturn('htmlFoo');
     $this->assertSame('htmlFoo', $this->viewHelper->render('myIdentifier', Icon::SIZE_LARGE, 'overlayString'));
 }
 /**
  * Print icon html for $identifier key
  *
  * @param array $arguments
  * @param \Closure $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  * @return string
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     $identifier = $arguments['identifier'];
     $size = $arguments['size'];
     $overlay = $arguments['overlay'];
     $state = IconState::cast($arguments['state']);
     $alternativeMarkupIdentifier = $arguments['alternativeMarkupIdentifier'];
     /** @var IconFactory $iconFactory */
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     return $iconFactory->getIcon($identifier, $size, $overlay, $state)->render($alternativeMarkupIdentifier);
 }
Example #3
0
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return string
  * @internal
  */
 public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     $parsedBody = $request->getParsedBody();
     $queryParams = $request->getQueryParams();
     $requestedIcon = json_decode(isset($parsedBody['icon']) ? $parsedBody['icon'] : $queryParams['icon'], true);
     list($identifier, $size, $overlayIdentifier, $iconState) = $requestedIcon;
     if (empty($overlayIdentifier)) {
         $overlayIdentifier = null;
     }
     $iconState = IconState::cast($iconState);
     $response->getBody()->write($this->getIcon($identifier, $size, $overlayIdentifier, $iconState)->render());
     $response = $response->withHeader('Content-Type', 'text/html; charset=utf-8');
     return $response;
 }
Example #4
0
 /**
  * Set up
  *
  * @return void
  */
 protected function setUp()
 {
     $iconFactory = new IconFactory();
     $this->subject = $iconFactory->getIcon($this->iconIdentifier, Icon::SIZE_SMALL, $this->overlayIdentifier, IconState::cast(IconState::STATE_DISABLED));
 }