Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
'oops mixed composer.json between project'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Dec 21, 2020
1 parent 1bbb9c1 commit a1607fe
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 53,564 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ yarn.lock
/Skeleton/media/*.webp
Draft.md
coverage
coverage.xml
coverage.xml
/Skeleton/var/test_database.sqlite
56 changes: 51 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,57 @@
{
"name": "piedweb/cms-theme-skeleton",
"name": "piedweb/cms-bundle",
"type": "symfony-bundle",
"description": "Default Theme for Pied Web CMS... Skeleton by the way.",
"description": "CMS built on top of Symfony (Admin, Front, Page Management, Media Management, Static Generator,...).",
"keywords": [],
"homepage": "https://piedweb.com",
"license": "MIT",
"require": {},
"require": {
"php": "^7.4",
"caseyamcl/toc": "^3.0",
"cocur/slugify": "^3.0|^4.0",
"doctrine/annotations": "^1.11",
"doctrine/doctrine-bundle": "^2.2.2",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.8.1",
"dpolac/twig-lambda": "^1.0",
"knplabs/knp-markdown-bundle": "^1.8",
"league/color-extractor": "^0.3.2",
"liip/imagine-bundle": "^2.3",
"piedweb/linksimprover": "^0.0.7",
"piedweb/render-html-attributes": "^1.0",
"piedweb/url-harvester": "^0.0.24",
"rosell-dk/webp-convert": "^2.4",
"sensio/framework-extra-bundle": "^5.6",
"sonata-project/admin-bundle": "^3.83",
"sonata-project/doctrine-orm-admin-bundle": "^3.26",
"spatie/async": "^1.5",
"symfony/asset": "^5.2",
"symfony/cache": "^5.2",
"symfony/console": "^4.4.17",
"symfony/dotenv": "^5.2",
"symfony/expression-language": "^5.2",
"symfony/finder": "^5.2",
"symfony/form": "^4.4.17",
"symfony/framework-bundle": "^4.4.17",
"symfony/lock": "^5.2",
"symfony/mailer": "^5.2",
"symfony/process": "^5.2",
"symfony/security-bundle": "^4.4.17",
"symfony/security-csrf": "^5.2",
"symfony/security-guard": "^4.4.17",
"symfony/translation": "^4.4.17",
"symfony/twig-bundle": "^4.4.17",
"symfony/validator": "^5.2",
"symfony/web-link": "^5.2",
"symfony/webpack-encore-bundle": "^1.8",
"symfony/yaml": "^5.2",
"twig/intl-extra": "^3.1",
"umpirsky/twig-php-function": "^0.2",
"vich/uploader-bundle": "^1.16",
"villfa/invert-color": "^0.5",
"wyrihaximus/html-compress": "^4.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17",
"friendsoftwig/twigcs": "^4.0",
Expand All @@ -21,13 +67,13 @@
},
"autoload": {
"psr-4": {
"PiedWeb\\CMSThemeSkeleton\\": "src/"
"PiedWeb\\CMSBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\": "Skeleton/src",
"PiedWeb\\CMSThemeSkeleton\\": "tests"
"PiedWeb\\CMSBundle\\": "tests"
}
},
"authors": [
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
"core-js": "^3.8.1",
"easymde": "^2.13.0",
"fslightbox": "^3.2.2",
"glob": "^7.1.6",
"glob-all": "^3.2.1",
"node-sass": "^5.0.0",
"postcss-import": "^14.0.0",
"postcss-loader": "^4.1",
"purgecss-webpack-plugin": "^3.1.3",
"sass-loader": "^10.1.0"
},
"license": "UNLICENSED",
Expand Down
45 changes: 27 additions & 18 deletions src/Extension/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PiedWeb\CMSBundle\Extension\Router;

use PiedWeb\CMSBundle\Entity\Page;
use PiedWeb\CMSBundle\Entity\PageInterface;
use PiedWeb\CMSBundle\Service\App;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -16,18 +17,18 @@ class Router implements RouterInterface
protected $useCustomHostPath = true; // TODO make it true on special request, same with absolute

/** @var App */
protected $app;
protected $apps;

/** @var string */
protected $currentHost;

public function __construct(
SfRouterInterface $router,
App $app,
App $apps,
RequestStack $requestStack
) {
$this->router = $router;
$this->app = $app;
$this->apps = $apps;
$this->currentHost = $requestStack->getCurrentRequest() ? $requestStack->getCurrentRequest()->getHost() : '';
}

Expand All @@ -36,37 +37,45 @@ public function __construct(
* and / for YY page home if your default language is YY
* X/Y may be en/fr/...
*/
public function generatePathForHomePage($page = null, $canonical = false): string
public function generatePathForHomePage(?PageInterface $page = null, $canonical = false): string
{
$slug = '';
$homepage = (new Page())->setSlug('');;

if (null !== $page && $page->getLocale() != $this->app->get()->getDefaultLocale()) {
$slug = $page->getLocale();
if (null !== $page) {
if ($page->getLocale() != $this->apps->get()->getDefaultLocale()) {
$homepage->setSlug($page->getLocale());
}
$homepage->setHost($page->getHost());
}

return $this->generate($slug, $canonical);
return $this->generate($homepage, $canonical);
}

public function generate($slug = 'homepage', $canonical = false): string
{
$page = null;

if ($slug instanceof PageInterface) {
/** @var $page PageInterface */
$page = $slug;
$slug = $slug->getRealSlug();
} elseif ('homepage' == $slug) {
$slug = '';
$page = null;
}

if (! $canonical && $this->mayUseCustomPath()) {
return $this->router->generate(self::CUSTOM_HOST_PATH, [
'host' => $this->app->getCurrentPage()->getHost(),
'slug' => $slug,
]);
if (! $canonical) {
if ($this->mayUseCustomPath()) {
return $this->router->generate(self::CUSTOM_HOST_PATH, [
'host' => $this->apps->getCurrentPage()->getHost(),
'slug' => $slug,
]);
} elseif ($page && !$this->apps->sameHost($page->getHost())) { // maybe we force canonical - useful for views
$canonical = true;
}
}

if ($canonical && $page) {
$baseUrl = $this->app->switchCurrentApp($page->getHost())->get()->getBaseUrl();
$baseUrl = $this->apps->getApp('baseUrl', $page->getHost());
}

return ($baseUrl ?? '').$this->router->generate(self::PATH, ['slug' => $slug]);
Expand All @@ -76,9 +85,9 @@ protected function mayUseCustomPath()
{
return $this->useCustomHostPath
&& $this->currentHost // we have a request
&& $this->app->getCurrentPage() // a page is loaded
&& $this->app->getCurrentPage()->getHost()
&& ! $this->app->get()->isMainHost($this->currentHost);
&& $this->apps->getCurrentPage() // a page is loaded
&& $this->apps->getCurrentPage()->getHost()
&& ! $this->apps->get()->isMainHost($this->currentHost);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Extension/Router/RouterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface RouterInterface

const CUSTOM_HOST_PATH = 'custom_host_piedweb_cms_page';

public function generatePathForHomePage($page = null): string;
public function generatePathForHomePage(?PageInterface $page = null): string;

/**
* @param string|PageInterface $slug
Expand Down
Loading

0 comments on commit a1607fe

Please sign in to comment.