-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the ProvidesOrderClause interface to allow ordering of query results. Refactored the article renderer creation into a trait (CreateArticleRender) to reuse it in the page reference,.
- Loading branch information
Showing
6 changed files
with
66 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hofff\Contao\Content\Reference; | ||
|
||
use Contao\ArticleModel; | ||
use Contao\CoreBundle\Security\Authentication\Token\TokenChecker; | ||
use Contao\Model\Registry; | ||
use Hofff\Contao\Content\Renderer\ArticleRenderer; | ||
use Hofff\Contao\Content\Renderer\Renderer; | ||
|
||
trait CreateArticleRender | ||
{ | ||
use ConfigureRenderer; | ||
|
||
private readonly TokenChecker $tokenChecker; | ||
|
||
/** {@inheritDoc} */ | ||
public function createRenderer(array $reference, array $config): Renderer | ||
{ | ||
$model = Registry::getInstance()->fetch('tl_article', $reference['id']); | ||
if (! $model instanceof ArticleModel) { | ||
$model = new ArticleModel(); | ||
$model->setRow($reference); | ||
} | ||
|
||
$renderer = new ArticleRenderer($this->tokenChecker); | ||
$renderer->setArticle($model); | ||
$renderer->setRenderContainer($config['render_container']); | ||
|
||
$this->configureRenderer($renderer, $config); | ||
|
||
return $renderer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hofff\Contao\Content\Reference; | ||
|
||
interface ProvidesOrderClause | ||
{ | ||
public function orderClause(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters