getContent() public method

Used directly by {% setcontent %} but also in other parts. This code has been split into multiple methods in the spirit of separation of concerns, but the situation is still far from ideal. Where applicable each 'concern' notes the coupling in the local documentation.
public getContent ( string $textquery, string $parameters = '', array &$pager = [], array $whereparameters = [] ) : array
$textquery string
$parameters string
$pager array
$whereparameters array
return array
コード例 #1
0
ファイル: NotFoundListener.php プロジェクト: bolt/bolt
 /**
  * Render the not found page if on frontend and http exception
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     if (!$exception instanceof HttpExceptionInterface || Zone::isBackend($event->getRequest())) {
         return;
     }
     if ($exception->getStatusCode() !== Response::HTTP_NOT_FOUND) {
         return;
     }
     // If $notFoundPage is referencing a template, render it and be done.
     if ($this->render->hasTemplate($this->notFoundPage)) {
         try {
             $this->renderNotFound($event, $this->notFoundPage, []);
         } catch (TwigErrorLoader $e) {
             // Template not found, fall though to see if we can render a
             // record, failing that let the exception handler take over
         }
     }
     // Next try for referencing DB content.
     $content = $this->storage->getContent($this->notFoundPage, ['returnsingle' => true]);
     if (!$content instanceof Content || empty($content->id)) {
         return;
     }
     $template = $this->templateChooser->record($content);
     $this->renderNotFound($event, $template, $content->getTemplateContext());
 }
コード例 #2
0
ファイル: NotFoundListener.php プロジェクト: nuffer/bolt
 /**
  * Render the not found page if on frontend and http exception
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     if (!$event->getException() instanceof HttpExceptionInterface || Zone::isBackend($event->getRequest())) {
         return;
     }
     $content = $this->storage->getContent($this->notFoundPage, ['returnsingle' => true]);
     if (!$content instanceof Content || empty($content->id)) {
         return;
     }
     $template = $this->templateChooser->record($content);
     $response = $this->render->render($template, $content->getTemplateContext());
     $event->setResponse($response);
 }
コード例 #3
0
ファイル: FieldLoadTest.php プロジェクト: somekoala/bolt
 protected function addSomeContent()
 {
     $app = $this->getApp();
     $app['request'] = Request::create('/');
     $app['config']->set('taxonomy/categories/options', ['news']);
     $prefillMock = new LoripsumMock();
     $app['prefill'] = $prefillMock;
     $storage = new Storage($app);
     $storage->prefill(['showcases', 'entries', 'pages']);
     // We also set some relations between showcases and entries
     $showcases = $storage->getContent('showcases');
     $randEntries = $storage->getContent('entries/random/2');
     foreach ($showcases as $show) {
         foreach (array_keys($randEntries) as $key) {
             $show->setRelation('entries', $key);
             $storage->saveContent($show);
         }
     }
 }
コード例 #4
0
ファイル: NotFoundListener.php プロジェクト: d-m-/bolt
 /**
  * Render the not found page if on frontend and http exception
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     if (!$event->getException() instanceof HttpExceptionInterface || Zone::isBackend($event->getRequest())) {
         return;
     }
     // If $notFoundPage is referencing a template, render it and be done.
     if ($this->render->hasTemplate($this->notFoundPage)) {
         $response = $this->render->render($this->notFoundPage);
         $event->setResponse($response);
         return;
     }
     // Next try for referencing DB content.
     $content = $this->storage->getContent($this->notFoundPage, ['returnsingle' => true]);
     if (!$content instanceof Content || empty($content->id)) {
         return;
     }
     $template = $this->templateChooser->record($content);
     $response = $this->render->render($template, [], $content->getTemplateContext());
     $event->setResponse($response);
 }
コード例 #5
0
ファイル: ChangeLogTest.php プロジェクト: bolt/bolt
 public function testGetNextChangeLogEntry()
 {
     $app = $this->getApp();
     $app['config']->set('general/changelog/enabled', true);
     $storage = new Storage($app);
     // To generate an extra changelog we fetch and save a content item
     // For now we need to mock the request object.
     $app['request'] = Request::create('/');
     $content = $storage->getContent('pages/1');
     $this->assertInstanceOf('\\Bolt\\Legacy\\Content', $content);
     $content->setValues(['status' => 'draft', 'ownerid' => 99]);
     $storage->saveContent($content, 'Test Suite Update');
     $content->setValues(['status' => 'published', 'ownerid' => 1]);
     $storage->saveContent($content, 'Test Suite Update');
     $log = $this->getLogChangeRepository()->getChangeLogEntry('pages', 1, 1, '>');
     $this->assertAttributeEquals(1, 'contentid', $log);
 }
コード例 #6
0
 public function getContent($textquery, $parameters = '', &$pager = [], $whereparameters = [])
 {
     $result = parent::getContent($textquery, $parameters, $pager, $whereparameters);
     if ($result) {
         $reflection = new \ReflectionClass($this);
         $prop = $reflection->getParentClass()->getProperty('app');
         $prop->setAccessible(true);
         $app = $prop->getValue($this);
         if (is_array($result)) {
             foreach ($result as &$record) {
                 $this->repeaterHydrate($record, $app);
             }
         } else {
             $this->repeaterHydrate($result, $app);
         }
     }
     return $result;
 }
コード例 #7
0
ファイル: StorageTest.php プロジェクト: gandalf3/bolt
 public function testUpdateSingleValue()
 {
     $app = $this->getApp();
     $app['request'] = Request::create('/');
     $storage = new Storage($app);
     $fetch1 = $storage->getContent('showcases/2');
     $this->assertEquals(1, $fetch1->get('ownerid'));
     $result = $storage->updateSingleValue('showcases', 2, 'ownerid', '10');
     $this->assertEquals(2, $result);
     $fetch2 = $storage->getContent('showcases/2');
     $this->assertEquals('10', $fetch2->get('ownerid'));
     // Test invalid column fails
     $shouldError = $storage->updateSingleValue('showcases', 2, 'nonexistent', '10');
     $this->assertFalse($shouldError);
 }