-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sylius:theme:assets:install not generating public/_themes directory #91
Comments
I'm in over my head at this point but basically, it is failing because of the path resolver. With 1.5.1, this call to the resolver is correctly building the The quickest band-aid fix for anyone using a single theme application would probably be to get rid of the |
Hi guys, i saw that the version 2.2.0 has been released but we are still having this issue |
v2.2.0 includes support for PHP 8 and the new public resources directory in bundles, I haven't got enough time to debug this one - I'll be happy to review any PR that helps to solve it though. |
Unfortunately, I reached the end of what I could do yesterday. What drives me bonkers is that Hopefully, someone can kind of work out where to go with the extra info I stumbled across. |
Hi, In my case, all assets stored in the public folder All URL are prefixed by When I run EDIT: In the administration, if I select a channel with the default theme, no prefix has been added on the assets path. Why? Symfony: 5.2.5 |
In my case, I don't have assets on my themes. To solve this issue, I have disabled assets on themes
|
This issue is really important I think. |
hi guys, what i thought to understand since this bundle's upgrade :
but this induces several disappointments during
so i think this is more a regression than a discovery, and btw in my opinion i'd rather delete the |
@pamil We really have an issue here 🙃. It's driving me crazy as well. Something is wrong and has to be fixed. Why is the theme used in admin? |
Here is a quick fix for those who can't wait: <?php
declare(strict_types=1);
namespace App\Sylius\Core\Theme;
use Exception;
use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface;
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Channel\Context\ChannelNotFoundException;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\HttpFoundation\RequestStack;
final class ChannelBasedThemeContext implements ThemeContextInterface
{
private RequestStack $requestStack;
private ChannelContextInterface $channelContext;
private ThemeRepositoryInterface $themeRepository;
public function __construct(
RequestStack $requestStack,
ChannelContextInterface $channelContext,
ThemeRepositoryInterface $themeRepository
) {
$this->requestStack = $requestStack;
$this->channelContext = $channelContext;
$this->themeRepository = $themeRepository;
}
public function getTheme(): ?ThemeInterface
{
if ($this->isAdmin()) {
return null;
}
try {
/** @var ChannelInterface $channel */
$channel = $this->channelContext->getChannel();
$themeName = $channel->getThemeName();
if (null === $themeName) {
return null;
}
return $this->themeRepository->findOneByName($themeName);
} catch (ChannelNotFoundException $exception) {
return null;
} catch (Exception $exception) {
return null;
}
}
private function isAdmin(): bool
{
if (null === $masterRequest = $this->requestStack->getMasterRequest()) {
return false;
}
$syliusParameters = $masterRequest->get('_sylius', []);
return array_key_exists('section', $syliusParameters) && 'admin' === $syliusParameters['section'];
}
} services:
# the class App\Sylius\Core\Theme\ChannelBasedThemeContext is autowired.
sylius.theme.context.channel_based: '@App\Sylius\Core\Theme\ChannelBasedThemeContext' |
@jacquesbh @pamil see #102 |
If it can help someone, we temporarily solved this by using this work around: composer.json
|
On a side-note if you're trying to debug this with docker-compose packed with Sylius 1.9 then add this to the php container to stall a bit and not shutdown while failing
|
Afaik this is still an issue for sylius 1.10. |
Here is another workaround : For background I use sylius 1.9, with a custom theme (extending the BootstrapTheme), in admin vendor assets are loaded from I checked First, create After that, vendor assets in admin are loading just fine. Hope that it can help someone. |
I'm trying to upgrade to Sylius v1.9, with a layered theme in this project (theme2 extends theme1 extends Sylius default theme), and running into the same issues. All kind of frontend dependencies are missing from the |
ping @Zales0123 @Tomanhez <3 |
Well, I wonder if theme for admin should not be selected independently from store theme.... right now it works really weird to me.... but it is more feature request :-) |
Because it is needed for each themes to run this fix we made a small bash script that should handle it correctly : #!/usr/bin/env bash
# Related issue : https://github.com/Sylius/SyliusThemeBundle/issues/91
#./bin/fix-theme-assets.sh
# Requirements:
# - jq ~= 1.6
set -o errexit;
set -o nounset;
set -o pipefail;
goToRoot() {
local currentDir;
currentDir=$( cd "$( dirname $0 )" && pwd )
cd "${currentDir}/../"
}
fix_theme() {
local themeName="${1:?}"
mkdir -p "public/_themes/${themeName}";
unlink "public/_themes/${themeName}/bundles" 2> /dev/null || true;
ln -s "../../../bundles" "public/_themes/${themeName}/bundles";
}
fix_themes() {
while IFS= read -r -d '' themeConfig
do
local themeName;
themeName=$(jq 'if .extra? | has("sylius-theme") then .name else null end' -r "${themeConfig}")
if [ "null" != "${themeName}" ]; then
fix_theme "${themeName}"
fi
done < <(find "./themes/"* -maxdepth 1 -name 'composer.json' -print0)
}
main() {
fix_themes
}
goToRoot
main hope it helps someone. |
To solve this problem, you just have to create an empty public directory in each of your themes. Maybe we should patch sylius/theme-bundle to create the /_themes/author/ theme-name/bundles directory, even though we don't have a public directory. |
@roromix is correct, but the files do not end up in I have the legacy mode enabled (from the upgrade guide) btw. |
Commands I used to run on a deployment: php bin/console --env=prod --no-debug --ansi assets:install public
php bin/console --env=prod --no-debug --ansi sylius:install:assets
php bin/console --env=prod --no-debug --ansi sylius:theme:assets:install public
yarn run build I would get a folder structure like: ls -lah public/bundles/
total 0
drwxr-xr-x 13 web web 286 Dec 24 10:48 .
drwxr-xr-x 11 web web 289 Dec 24 10:50 ..
drwxr-xr-x 3 web web 36 Dec 24 10:48 _themes
ls -lah public/bundles/_themes/
total 0
drwxr-xr-x 3 web web 36 Dec 24 10:48 .
drwxr-xr-x 13 web web 286 Dec 24 10:48 ..
drwxr-xr-x 4 web web 63 Dec 24 10:48 project
ls -lah public/bundles/_themes/project/
total 0
drwxr-xr-x 4 web web 63 Dec 24 10:48 .
drwxr-xr-x 3 web web 36 Dec 24 10:48 ..
drwxr-xr-x 13 web web 308 Dec 24 10:49 base-theme
drwxr-xr-x 11 web web 253 Dec 24 10:48 core-theme I could reference all my assets like this:
Which would rewrite into this:
Now I need to access them like:
Also I need to add another step in my build process BEFORE the cp -Rp public/_themes/ public/bundles Simply to just get a folder like it used to be. I'm using the Main issue is here probably that's not documented in the UPGRADE guide for version 2 that assets will be installed somewhere else and that referencing them in templates would also break. |
Hey folks, I've promised on a slack some time ago, that we will take care of this issue. However, as not a creator of this library it is hard to do deep dive into it. To help you, I need working, ready to use reproducer for your issue. It may be new test case in this project, it may be vanilla Sylius-Standard just with sample project. In addition, please point out the correct way to assert of your expected outcome. I'm aware, that you had to do the same, don't get me wrong. But I also have to help on other ends of Sylius and I won't commit to build reproducer at this moment. Nonetheless, I want to unblock(or just fix it on upstream) you. In test I trust :) |
I haven't done a deep dive on this in a long while, but in theory, this should be enough to make a reproducer:
When you run Symfony's |
By making a public folder inside all my themes with a .gitkeep inside only, the command is now able to write all files and folders in the public folder. |
Any new idea? |
The problem still exists, here is my solution because any other don't work.
If packge exists in default folder, dont play with other solutions.
|
With Sylius 1.9.0 and
sylius/theme-bundle
2.1.1, when I run thebin/console sylius:theme:assets:install
command (without symlinks due to #79), I am not getting a version of the assets in thepublic/_themes
directory.public/bundles
does generate correctly.For our client, we overloaded some admin field types to use CKEditor through
FOSCKEditorBundle
and are installing its assets viabin/console ckeditor:install --clear=drop
. After running the CKEditor install command then the asset install command and going to any admin page where we have CKEditor in use, the asset URL (as determined with thePathResolver
class) is/_themes/<theme_composer_name>/bundles/fosckeditor/ckeditor.js
. With Sylius 1.8 and the 1.x version of this bundle, the asset URL is/bundles/_themes/<theme_composer_name>/fosckeditor/ckeditor.js
and this is working OK (note,public/bundles/_themes
doesn't exist on the new version either, just to be sure there wasn't anything strange here).The text was updated successfully, but these errors were encountered: