Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
rabauss committed May 10, 2023
1 parent a92b26d commit 078ef54
Show file tree
Hide file tree
Showing 14 changed files with 525 additions and 525 deletions.
28 changes: 14 additions & 14 deletions src/Controller/ContentElement/ColumnStartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
class ColumnStartController extends AbstractContentElementController
{
private ScopeMatcher $scopeMatcher;
private Studio $studio;
private Studio $studio;

public function __construct(ScopeMatcher $scopeMatcher, Studio $studio)
public function __construct(ScopeMatcher $scopeMatcher, Studio $studio)
{
$this->scopeMatcher = $scopeMatcher;
$this->studio = $studio;
}
$this->studio = $studio;
}

protected function getResponse(Template $template, ContentModel $model, Request $request): ?Response
{
Expand Down Expand Up @@ -79,16 +79,16 @@ protected function getResponse(Template $template, ContentModel $model, Request
}

if (trim($model->rs_column_background_image)) {
$figure = $this->studio
->createFigureBuilder()
->fromUuid($model->rs_column_background_image ?: '')
->setSize($model->rs_column_background_image_size)
->enableLightbox(false)
->buildIfResourceExists()
;
if (null !== $figure) {
$styles[] = 'background-image: url("' . $figure->getImage()->getImageSrc(true) . '");';
}
$figure = $this->studio
->createFigureBuilder()
->fromUuid($model->rs_column_background_image ?: '')
->setSize($model->rs_column_background_image_size)
->enableLightbox(false)
->buildIfResourceExists()
;
if (null !== $figure) {
$styles[] = 'background-image: url("' . $figure->getImage()->getImageSrc(true) . '");';
}
}

if ($model->rs_column_background_size) {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ContentElement/ColumnsStartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function getResponse(Template $template, ContentModel $model, Request
* Generate the columns configuration
*
* @param array $data Data array
* @return array Columns configuration
* @return array Columns configuration
*/
public static function getColumnsConfiguration(array $data): array
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public static function getColumnsConfiguration(array $data): array
* Generate the wrapper class name
*
* @param array $data Data array
* @return string Wrapper class name
* @return string Wrapper class name
*/
public static function getWrapperClassName(array $data): string
{
Expand Down
12 changes: 6 additions & 6 deletions src/DependencyInjection/RockSolidColumnsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

final class RockSolidColumnsExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
(new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')))
->load('services.yaml')
;
}
public function load(array $configs, ContainerBuilder $container): void
{
(new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')))
->load('services.yaml')
;
}
}
48 changes: 24 additions & 24 deletions src/EventListener/AddColumnsClassesToContentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@
*/
class AddColumnsClassesToContentListener
{
public function __invoke(ContentModel $contentModel, string $buffer, $element): string
{
$parentKey = ($contentModel->ptable ?: 'tl_article').'__'.$contentModel->pid;
$excludeElements = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop'];
public function __invoke(ContentModel $contentModel, string $buffer, $element): string
{
$parentKey = ($contentModel->ptable ?: 'tl_article').'__'.$contentModel->pid;
$excludeElements = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop'];

if (
isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])
&& $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']
&& !\in_array($contentModel->type, $excludeElements, true)
) {
if (
isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])
&& $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']
&& !\in_array($contentModel->type, $excludeElements, true)
) {

$GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++;
$count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count'];
$GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++;
$count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count'];

if ($count) {
if ($count) {

$classes = array('rs-column');
foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) {
$classes = array_merge($classes, $media[($count - 1) % count($media)]);
if ($count - 1 < count($media)) {
$classes[] = '-'.$name.'-first-row';
}
}
$classes = array('rs-column');
foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) {
$classes = array_merge($classes, $media[($count - 1) % count($media)]);
if ($count - 1 < count($media)) {
$classes[] = '-'.$name.'-first-row';
}
}

return '<div class="'.implode(' ', $classes).'">'.$buffer.'</div>';
return '<div class="'.implode(' ', $classes).'">'.$buffer.'</div>';

}
}

}
}

return $buffer;
}
return $buffer;
}
}
66 changes: 33 additions & 33 deletions src/EventListener/AddColumnsClassesToFormListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@
*/
class AddColumnsClassesToFormListener
{
public function __invoke(Widget $widget, string $formId, array $data, Form $form): Widget
{
$parentKey = 'tl_form__'.$widget->pid;
$excludeWidgets = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop'];

if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])
&& $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']
&& !\in_array($widget->type, $excludeWidgets, true)
) {

$GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++;
$count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count'];

if ($count) {

$classes = array('rs-column');
foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) {
$classes = array_merge($classes, $media[($count - 1) % count($media)]);
if ($count - 1 < count($media)) {
$classes[] = '-'.$name.'-first-row';
}
}

if ('fieldsetStart' === $widget->type || 'submit' === $widget->type) {
$widget->class .= ' '.implode(' ', $classes);
} else {
$widget->prefix .= ' '.implode(' ', $classes);
}
}
}

return $widget;
}
public function __invoke(Widget $widget, string $formId, array $data, Form $form): Widget
{
$parentKey = 'tl_form__'.$widget->pid;
$excludeWidgets = ['rs_columns_start', 'rs_columns_stop', 'rs_column_start', 'rs_column_stop'];

if (isset($GLOBALS['TL_RS_COLUMNS'][$parentKey])
&& $GLOBALS['TL_RS_COLUMNS'][$parentKey]['active']
&& !\in_array($widget->type, $excludeWidgets, true)
) {

$GLOBALS['TL_RS_COLUMNS'][$parentKey]['count']++;
$count = $GLOBALS['TL_RS_COLUMNS'][$parentKey]['count'];

if ($count) {

$classes = array('rs-column');
foreach ($GLOBALS['TL_RS_COLUMNS'][$parentKey]['config'] as $name => $media) {
$classes = array_merge($classes, $media[($count - 1) % count($media)]);
if ($count - 1 < count($media)) {
$classes[] = '-'.$name.'-first-row';
}
}

if ('fieldsetStart' === $widget->type || 'submit' === $widget->type) {
$widget->class .= ' '.implode(' ', $classes);
} else {
$widget->prefix .= ' '.implode(' ', $classes);
}
}
}

return $widget;
}
}
12 changes: 6 additions & 6 deletions src/EventListener/AddFrontendAssetsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
class AddFrontendAssetsListener
{
public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void
{
if ($layout->rs_columns_load_css) {
$GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/columns.css||static';
}
}
public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular $pageRegular): void
{
if ($layout->rs_columns_load_css) {
$GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/columns.css||static';
}
}
}
42 changes: 21 additions & 21 deletions src/EventListener/DataContainer/AddBackendAssetsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
*/
class AddBackendAssetsListener
{
private RequestStack $requestStack;
private ScopeMatcher $scopeMatcher;
private RequestStack $requestStack;
private ScopeMatcher $scopeMatcher;

public function __construct(RequestStack $requestStack, ScopeMatcher $scopeMatcher)
{
$this->requestStack = $requestStack;
$this->scopeMatcher = $scopeMatcher;
}
public function __construct(RequestStack $requestStack, ScopeMatcher $scopeMatcher)
{
$this->requestStack = $requestStack;
$this->scopeMatcher = $scopeMatcher;
}

public function __invoke(string $table): void
{
if ('tl_content' !== $table && 'tl_form_field' !== $table) {
return;
}
public function __invoke(string $table): void
{
if ('tl_content' !== $table && 'tl_form_field' !== $table) {
return;
}

$request = $this->requestStack->getCurrentRequest();
$request = $this->requestStack->getCurrentRequest();

if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) {
return;
}
if (null === $request || !$this->scopeMatcher->isBackendRequest($request)) {
return;
}

$GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css';
$GLOBALS['TL_CSS'][] = 'bundles/rocksolidcolumns/css/be_main.css';

if ('tl_form_field' === $table) {
System::loadLanguageFile('tl_content');
}
}
if ('tl_form_field' === $table) {
System::loadLanguageFile('tl_content');
}
}
}
Loading

0 comments on commit 078ef54

Please sign in to comment.