コード例 #1
0
 /**
  * @param Request $request
  * @param RenderingContext $renderingContext
  * @return array
  */
 protected function resolveRenderingConfiguration(Request $request, RenderingContext $renderingContext)
 {
     $configuration = array();
     if ($request->hasArgument('path')) {
         $renderingPath = $request->getArgument('path');
     }
     if ($request->hasArgument('record')) {
         if (strpos($request->getArgument('record'), '_') !== FALSE) {
             list($table, $id) = GeneralUtility::revExplode('_', $request->getArgument('record'), 2);
         } else {
             $id = $request->getArgument('record');
         }
     }
     if ($request->hasArgument('table')) {
         $table = $request->getArgument('table');
     }
     if (empty($table) && empty($id)) {
         $table = 'pages';
         $id = $renderingContext->getFrontendController()->id;
         if (!empty($id) && $renderingContext->getFrontendController()->page['pid'] === '0') {
             // Allow rendering of a root page which has pid === 0 and will be denied otherwise
             $configuration['dontCheckPid'] = '1';
         }
     }
     if (!empty($id) && empty($table)) {
         $table = 'tt_content';
     }
     $configuration['source'] = $table . '_' . $id;
     $configuration['tables'] = $table;
     if (!empty($renderingPath)) {
         $configuration['conf.'][$table] = '< ' . $renderingPath;
     }
     return $configuration;
 }
コード例 #2
0
 /**
  * @param Request $request
  * @param RenderingContext $renderingContext
  * @return array
  */
 protected function resolveRenderingConfiguration(Request $request, RenderingContext $renderingContext)
 {
     $configuration = array();
     if ($request->hasArgument('path')) {
         $renderingPath = $request->getArgument('path');
     }
     if ($request->hasArgument('record')) {
         if (strpos($request->getArgument('record'), '_') !== FALSE) {
             list($table, $id) = GeneralUtility::revExplode('_', $request->getArgument('record'), 2);
         } else {
             $id = $request->getArgument('record');
         }
     }
     if ($request->hasArgument('table')) {
         $table = $request->getArgument('table');
     }
     if (empty($table) && empty($id)) {
         $table = 'pages';
         $id = $renderingContext->getFrontendController()->id;
     }
     if (!empty($id) && empty($table)) {
         $table = 'tt_content';
     }
     if ($table === 'pages') {
         // Allow rendering of a root page which has pid === 0 and would be denied otherwise
         $rootLine = $renderingContext->getFrontendController()->sys_page->getRootLine($id);
         // $rootLine[0] is the root page. Check if the page we're going to render is a root page.
         // We explicitly ignore the case where the to be rendered id is in another root line (multi domain setup)
         // as this would require an additional record lookup. The use case for this is very limited anyway
         // and should be implemented in a different renderer instead of covering that here.
         if ($rootLine[0]['uid'] === (string) $id) {
             $configuration['dontCheckPid'] = '1';
         }
     }
     $configuration['source'] = $table . '_' . $id;
     $configuration['tables'] = $table;
     if (!empty($renderingPath)) {
         $configuration['conf.'][$table] = '< ' . $renderingPath;
     }
     return $configuration;
 }
コード例 #3
0
 /**
  * @param Request $request
  * @return RenderingInterface
  * @throws Exception
  */
 protected function resolveRenderer(Request $request)
 {
     /** @var RenderingInterface $renderer */
     if ($request->hasArgument('renderer') && isset($this->renderer[$request->getArgument('renderer')])) {
         $rendererClassName = $this->renderer[$request->getArgument('renderer')];
         $renderer = new $rendererClassName();
         if ($renderer->canRender($request)) {
             return $renderer;
         }
     }
     foreach ($this->renderer as $rendererClassName) {
         $renderer = new $rendererClassName();
         if ($renderer->canRender($request)) {
             return $renderer;
         }
     }
     throw new Exception('No renderer found for this request!', 1403628294);
 }
コード例 #4
0
 /**
  * Whether the required arguments for rendering are present or not
  *
  * @param Request $request
  * @return bool
  */
 public function canRender(Request $request)
 {
     return $request->hasArgument('renderer') && $request->getArgument('renderer') === 'hello';
 }