-
Notifications
You must be signed in to change notification settings - Fork 76
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
Assets improved #138
Assets improved #138
Conversation
…e assets:install)
); | ||
|
||
$finder = new Finder(); | ||
$paths = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this Bundle is still compatible with PHP 5.3 please do not use short array syntax.
Made some improvements based on your comments. cc @Morgan-pepe |
there are still 2 failing tests. |
Travis CI tells me this :
From If I understood well, following the stacktrace, i added to ThemeLocator to ActiveTheme (injected in controller) and ThemeLocator needs So when @lsmith77 Do you have some input ? I fail to see what's wrong or what to fix to pass the LiipThemeExtensionTest. |
Actually for this asset improvement thing this would work? |
I actually developed my own theming bundle since last year. I'll see if we can open-source it, in the meantime, I close this pull request. |
First, thanks for the great work you've put in writing theme-bundle. It works great.
Context
Working on a project close to a CMS, built on Symfony, our clients were asking was customizing the look-and-feel of the platform to match their brand identity.
That's how I stubbled upon this bundle and it works great but allow user to upload their theme including assets (CSS, JS, images) was the main struggle I encountered.
That's why I worked on a way to make those assets available in web/ directory. This might be a solution to some opened issues like #110.
Solution
The solution is a command, similar to
assets:install
.~ $ php app/console assets:themes-install --symlink web
Then you can use the
asset()
twig function to reference your asset as you would do with regular bundles assets.If the theme is part of a bundle :
If the theme is inside the app/ directory :
Under the hood
Every theme ships its own assets in a
public/
directory.public/
public/images/
public/javascripts/
public/stylesheets/
The command makes symlinks (or hard copies) of assets into the
web/themes/
directory.It takes the
liip_theme.themes
configuration and makes the right symlink – if apublic/
directory is found inside each theme.If
liip_theme.themes
is not defined, it just scans the project, searching for themes inliip_theme.path_patterns
paths.ThemeLocator & Installer.php
Discovering themes (dynamically) is possible by calling the service
liip_theme.theme_locator
andThemeLocator::discoverThemes()
.Install assets of a theme is possible calling the service
liip_theme.installer
– that you can call after the upload of a theme and therefore dynamically install the assets of the theme (that's why I'm linking the issue #110).What do you think ?