Giter Site home page Giter Site logo

liipthemebundle's Introduction

Theme Bundle

This project is not longer maintained and recommends to use SyliusThemeBundle instead for support of Symfony 5 and Twig 3. For migration have a look at Migrate to SyliusThemeBundle.

This bundle provides you the possibility to add themes to each bundle. In your bundle directory it will look under Resources/themes/<themename> or fall back to the normal Resources/views if no matching file was found.

Build Status

Installation

Installation is a quick (I promise!) 3 step process:

  1. Download LiipThemeBundle
  2. Enable the Bundle
  3. Import LiipThemeBundle routing

Step 1: Install LiipThemeBundle with composer

Run the following composer require command:

$ php composer.phar require liip/theme-bundle

Step 2: Enable the bundle

Finally, enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Liip\ThemeBundle\LiipThemeBundle(),
    );
}

Step 3: Import LiipThemeBundle routing files

Now that you have activated and configured the bundle, all that is left to do is import the LiipThemeBundle routing files.

In YAML:

# app/config/routing.yml
liip_theme:
    resource: "@LiipThemeBundle/Resources/config/routing.xml"
    prefix: /theme

Or if you prefer XML:

<!-- app/config/routing.xml -->
<import resource="@LiipThemeBundle/Resources/config/routing.xml" prefix="/theme" />

Configuration

You will have to set your possible themes and the currently active theme. It is required that the active theme is part of the themes list.

# app/config/config.yml
liip_theme:
    themes: ['standardTheme', 'winter_theme', 'weekend']
    active_theme: 'standardTheme'

Device specific themes/templates

You can provide specific themes or even templates for different devices (like: desktop, tablet, phone, plain). Set option autodetect_theme to true for setting current_device parameter based on the user agent:

# app/config/config.yml
liip_theme:
    autodetect_theme: true

Then in path_patterns you can use %%current_device%% parameter (with your device type as value)

# app/config/config.yml
liip_theme:
    path_patterns:
        app_resource:
            - %%app_path%%/themes/%%current_theme%%/%%current_device%%/%%template%%
            - %%app_path%%/themes/fallback_theme/%%current_device%%/%%template%%
            - %%app_path%%/views/%%current_device%%/%%template%%

Optionally autodetect_theme can also be set to a DIC service id that implements the Liip\ThemeBundle\Helper\DeviceDetectionInterface interface.

Get active theme information from cookie

If you want to select the active theme based on a cookie you can add:

# app/config/config.yml
liip_theme:
    cookie:
        name: NameOfTheCookie
        lifetime: 31536000 # 1 year in seconds
        path: /
        domain: ~
        secure: false
        http_only: false

Disable controller based theme switching

If your application doesn't allow the user to switch theme, you can deactivate the controller shipped with the bundle:

# app/config/config.yml
liip_theme:
    load_controllers: false

Theme Cascading Order

The following order is applied when checking for templates that live in a bundle, for example @BundleName/Resources/template.html.twig with theme name phone is located at:

  1. Override themes directory: app/Resources/themes/phone/BundleName/template.html.twig
  2. Override view directory: app/Resources/BundleName/views/template.html.twig
  3. Bundle theme directory: src/BundleName/Resources/themes/phone/template.html.twig
  4. Bundle view directory: src/BundleName/Resources/views/template.html.twig

For example, if you want to integrate some TwigBundle custom error pages regarding your theme architecture, you will have to use this directory structure : app/Resources/themes/phone/TwigBundle/Exception/error404.html.twig

The following order is applied when checking for application-wide base templates, for example ::template.html.twig with theme name phone is located at:

  1. Override themes directory: app/Resources/themes/phone/template.html.twig
  2. Override view directory: app/Resources/views/template.html.twig

Change Theme Cascading Order

You able change cascading order via configurations directives: path_patterns.app_resource, path_patterns.bundle_resource, path_patterns.bundle_resource_dir. For example:

# app/config/config.yml
liip_theme:
    path_patterns:
        app_resource:
            - %%app_path%%/themes/%%current_theme%%/%%template%%
            - %%app_path%%/themes/fallback_theme/%%template%%
            - %%app_path%%/views/%%template%%
        bundle_resource:
            - %%bundle_path%%/Resources/themes/%%current_theme%%_%%current_device%%/%%template%%
            - %%bundle_path%%/Resources/themes/%%current_theme%%/%%template%%
            - %%bundle_path%%/Resources/themes/fallback_theme/%%template%%
        bundle_resource_dir:
            - %%dir%%/themes/%%current_theme%%/%%bundle_name%%/%%template%%
            - %%dir%%/themes/fallback_theme/%%bundle_name%%/%%template%%
            - %%dir%%/%%bundle_name%%/%%override_path%%
Cascading Order Patterns Placeholders
Placeholder Representation Example
%app_path% Path where application resources are located app/Resources
%bundle_path% Path where bundle located, for example src/Vendor/CoolBundle/VendorCoolBundle
%bundle_name% Name of the bundle VendorCoolBundle
%dir% Directory, where resource should looking first
%current_theme% Name of the current active theme
%current_device% Name of the current device type desktop, phone, tablet, plain
%template% Template name view.html.twig
%override_path% Like template, but with views directory views/list.html.twig

Change Active Theme

For that matter have a look at the ThemeRequestListener.

If you are early in the request cycle and no template has been rendered you can still change the theme without problems. For this the theme service exists at:

$activeTheme = $container->get('liip_theme.active_theme');
echo $activeTheme->getName();
$activeTheme->setName("phone");

Theme Specific Controllers

In some situations, a different template is not enough and you need a different controller for a specific theme. We encountered this with A/B testing. Do not abuse this feature and check whether your use case is still to be considered a theme.

This feature is not active by default as there is an additional request listener involved. Enable it by setting theme_specific_controllers in your configuration:

# app/config/config.yml
liip_theme:
    # ...
    theme_specific_controllers: true

Now you can configure controllers per theme in your routing file:

my_route:
    path: /x/y
    defaults:
        _controller: my_service:fooAction
        theme_controllers:
            a: my_other_service:fooAction
            b: App:Other:foo

As usual, you can use both the service notation or the namespace notation for the controllers. Just specify the controller by theme under the key theme_controllers.

Assetic integration

Because of the way the LiipThemeBundle overrides the template locator service, assetic will only dump the assets of the active theme.

In order to dump the assets of all themes enable the assetic_integration option:

# app/config/config.yml
liip_theme:
    # ...
    assetic_integration: true

This will override the Twig formula loader and iterate over all of the themes, ensuring that all of the assets are dumped.

Note that this only works with AsseticBundle 2.1 or higher.

Override the Device Detection

It is possible to override the service used for the device detection. Make sure to either extend DeviceDetection or implement DeviceDetectionInterface:

# app/config/config.yml
services:
    my_devcice_detection:
        class: SomeClass

liip_theme:
    # ...
    device_detection: my_devcice_detection

Migrate to SyliusThemeBundle

This will show you the stepts to switch from the LiipThemeBundle to SyliusThemeBundle.

Remove the old theme bundle and install the SyliusThemeBundle:

# Remove old theme-bundle
composer remove liip/theme-bundle --no-update

# Install new theme-bundle
composer require sylius/theme-bundle:"^2.0"

Remove old configuration

The old liip_theme.yaml configuration needs to be removed:

-liip_theme:
-    themes: ['awesome']
-    active_theme: 'awesome'

In the next step you see how you configure the awesome theme using the SyliusThemeBundle.

Configure the SyliusThemeBundle:

In order to use the bundle you have to add the following default configuration:

# ./config/packages/sylius_theme.yaml

sylius_theme:
    sources:
        filesystem: ~

By default, the bundle seeks for the themes in the %kernel.project_dir%/themes directory and looks for a configuration file named composer.json. This can be changed via the yaml configuration:

sylius_theme:
    sources:
        filesystem:
            filename: theme.json

Convert Theme Configuration

In the SyliusThemeBundle every theme must have its own configuration file in form of a theme.json. Add a theme.json file and add the following minimal configuration:

{
    "name": "app/awesome"
}

Go to the Theme Configuration Reference for the detailed documentation about the configuration options.

Most likely you have to change the theme name. It is important, that the name matches the naming convention of composer (vendor/name). Furthermore the theme.json has to be moved into the directory for this specific theme.

For example: %kernel.project_dir%/themes/awesome/theme.json

Update project structure

Your templates have to be placed in a templates directory next to the theme.json file.

For example: %kernel.project_dir%/themes/<theme-name>/templates

This results in the following project structure:

ProjectName
├── composer.json
├── assets
├── bin
├── config
├── templates
├── themes
│   ├── awesome
│   │   ├── templates
│   │   │   └── base.html.twig
│   │   └── theme.json
│   └── <theme-name-2>
│       ├── templates
│       │   └── base.html.twig
│       └── theme.json
├── ...
└── ...

As you can see in the project structure, each theme must have their own theme.json configuration file next to the templates directory.

Create ThemeRequestListener

You need to create a ThemeRequestListener to set the theme based on the current $request data:

use Sylius\Bundle\ThemeBundle\Context\SettableThemeContext;
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

final class ThemeRequestListener
{
    /** @var ThemeRepositoryInterface */
    private $themeRepository;

    /** @var SettableThemeContext */
    private $themeContext;

    public function __construct(ThemeRepositoryInterface $themeRepository, SettableThemeContext $themeContext)
    {
        $this->themeRepository = $themeRepository;
        $this->themeContext = $themeContext;
    }

    public function onKernelRequest(GetResponseEvent $event): void
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            // don't do anything if it's not the master request
            return;
        }

        $themeName = 'app/awesome';

        // here you can set the $themeName based on $event->getRequest() object

        $this->themeContext->setTheme(
            $this->themeRepository->findOneByName($themeName)
        );
    }
}

Have a look also at the SyliusThemeBundle Documentation.

Contribution

Active contribution and patches are very welcome. To keep things in shape we have quite a bunch of unit tests. If you're submitting pull requests please make sure that they are still passing and if you add functionality please take a look at the coverage as well it should be pretty high :)

First install dependencies:

   composer.phar install --dev

This will give you proper results:

phpunit --coverage-text

liipthemebundle's People

Contributors

ahilles107 avatar beberlei avatar coil avatar dantleech avatar dbu avatar ebi avatar emulienfou avatar erivello avatar fabian avatar gimler avatar j0k3r avatar jdeniau avatar jmeyo avatar koc avatar liuggio avatar lsmith77 avatar maximgeerinck avatar maximgubar avatar mikoweb avatar nyholm avatar oleg-andreyev avatar pborreli avatar peterrehm avatar phiamo avatar rawkode avatar sander-toonen avatar seldaek avatar stof avatar tifabien avatar xabbuh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liipthemebundle's Issues

cache:warmup command fails

Hi,

When using the CLI command:

console cache:warmup
[15:45:38] PHP Fatal error:  Call to a member function getContent() on a non-object in /Users/coil/Sites/mysite/vendor/bundles/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php on line 56
PHP Stack trace:
PHP   1. {main}() /Users/coil/Sites/mysite.com/app/console:0

The default theme is set, but is not "loaded" which seems logical in CLI.

Is there a clean way to avoid this error, other than creating the missing templates at the root of my bundle in the standard view directories ?

non-existent service "liip_theme.theme_controller".

I am following the README but I get the following error when accessing the /theme/web

You have requested a non-existent service "liip_theme.theme_controller".

First I had Issue #23 so I fixed by changing AsseticBundle to origin/2.0. I now have Symfony2 2.0.11.

Default DeviceDetectionInterface

The readme file contains the following:

You will have to set your possible themes and the currently active theme. It is required that the active theme is part of the themes list.

# app/config/config.yml
liip_theme:
    themes: ['web', 'tablet', 'phone']
    active_theme: 'web'

So our possible themes names can be anything and the bundle works well with any name we give to our themes. Later we have:

It is also possible to automate setting the theme based on the user agent:

# app/config/config.yml
liip_theme:
    autodetect_theme: true

The default DeviceDetectionInterface uses the following to detect the device:

protected $devices = array(
        "tablet" => array(
            "androidtablet" => "android(?!.*(?:mobile|opera mobi|opera mini))",
            "blackberrytablet" => "rim tablet os",
            "ipad" => "(ipad)"
        ),
        "plain" => array(
            "kindle" => "(kindle)",
            "IE6" => "MSIE 6.0"
        ),
        "phone" => array(
            "android" => "android.*mobile|android.*opera mobi|android.*opera mini",
            "blackberry" => "blackberry",
            "iphone" => "(iphone|ipod)",
            "palm" => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino|webOS)",
            "windows" => "windows ce; (iemobile|ppc|smartphone)",
            "windowsphone" => "windows phone os",
            "generic" => "(mobile|mmp|midp|o2|pda|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap|opera mini|opera mobi|opera mini)",
        ),
        "desktop" => array(
            "osx" => "Mac OS X",
            "linux" => "Linux",
            "windows" => "Windows",
            "generic" => "",
        )
    );

From what I see based on this, the return values is one of the following: tablet, plain, phone, desktop. So unless you are using those names for you template the devices are not detected properly. Having a theme named web only works if web is the active theme because it defaults to that when nothing is detected but setting active_theme to another teams does not give you the expected results.

Please correct me if I am wrong. If not, may be a note can be added in the README file about using the provided implementation for DeviceDetectionInterface.
#43

Translations (and public ressources)

What about Translations ? If i use another theme, i want to load another translation-file too! it is possible to regard this too ? or maybe some workarounds ?

greez,
sky...

theme with only css, js and images

Hello

I wanted to know if it was possible to create themes with the twig file by default, so only the CSS files, js and images will be different.

And what looks like the code in the layout.html.twig in index.html.twig file and in the file index.html.twig my theme if it is a mandatory file:

 {% stylesheets '@BundleName/Resources/public/less/bootstrap.less'
filter='less, cssrewrite' %}
< link rel="stylesheet" href="{{ asset_url }}" / >
{% endstylesheets %}

thank you

add themes dinamically...

not properly an issue but a question....

Use case:

-Need to 'link' themes with customer marketing segments. It means i need to:
-When configuring my app i need to take all marketing segments from database and add as much themes as marketing segments, i'm trying this from my bundle extension but i got....

 [exec]   [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]  
 [exec]   The service definition "liip_theme.active_theme" does not exist.

when executing
....
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

    $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
    $loader->load('general_services.yml');
    $loader->load('specific_services.yml');

    //Registrar los themes de la tienda que dependen de los segmentos.
    $liip = $container->get('liip_theme.active_theme');
    $themes = $liip->getThemes();

.......

any hint?

thx in advance.

Twig override in app/ stops working for FOSUser when LiipTheme installed

Hi,

So this is my first time using LiipTheme, although I've been using Sf2 for a long time now. The problem I'm having is the following:
I've just set up LiipTheme on a project I was already developing on, and it's working just fine for theming my twig files. However, I'm also using FOSUser and I want to overide it's views/layout.html.twig in app/Resources/FOSUserBundle/views/layout.html.twig
Before I install LiipTheme, and even now if I disable it, my app/Resources/FOSUserBundle/views/layout.html.twig overide works as intended. However, if I have LiipTheme installed, they don't. Overides for my bundle in app/Resources, work just fine, and I've only tested FOSUser, so I don't know if other bundles are affected.

Cheers

autodetect

Hello,
first of all thanks for this bundle.
This is not an issue, this is a question. I have read documentation and some part still unclear for me. How does auto-detect work?

I can change current theme in controller by code:

$activeTheme = $this->container->get('liip_theme.active_theme');
$activeTheme->setName("phone");

but I would like to do in automatically. In case of configurations like this it does not work.

liip_theme:    
    autodetect_theme: true

or

liip_theme:
    themes: ['web', 'tablet', 'phone']
    active_theme: 'web'
    autodetect_theme: true

or

liip_theme:
   themes: ['web', 'tablet', 'phone']
   active_theme: 'web'
   cookie:
        name: NameOfTheCookie
        lifetime: 31536000 # 1 year in seconds
        path: /
        domain: ~
       secure: false
       http_only: false
  autodetect_theme: true

So how to configure and user auto-detection?

I know I can change theme in controller by $activeTheme->setName("phone");, but how to know "phone" or "other"?

Thanks

Theme cascade order seems off

The user-configured theme cascading order is searched through after the existing hard-coded directories. I may be misunderstand the existing reasoning, but it seems to make more sense to search through what the user has listed first.

yellow1912 might be touching on this in a later comment of this issue - #85

Assetic write-to (conflict for resources with same name)

I wonder if anyone ran into this issue before: with the current setting there is no theme-specific path for write_to which means if your themes share the same asset filenames place in the same structure then assetic will generate the same output files. This is a big problem if you consider dynamically changing active theme per request.

I'm trying to find out how to get around this issue. The first thing would be determining how assetic generates its asset_url and making sure it must be theme-aware. Then assetic:dump must also dump assets to the correct place (I guess I can override the assetic:dump command for this).

Any suggestion?

Theme By host

We have some themes and some server Alias, one by affiliate.

When a user connect to host1.example.com we want use host1 theme.
When a user connect to host2.example.com we want use host2 theme.

How can we do this feature?

Is it optimal to use a listener for each request?

$activeTheme = $container->get('liip_theme.active_theme');
$activeTheme->setName($request->getHost());

Thanks.

assetic:dump and capifony

When I deploy my application with capifony, assets doesn't install.
I've also tried to launch "cap symfony:assetic:dump" manually and doesn't work.
I've noted that this behaviour is became from liipthemebundle's installation.
Therefore, I've uninstalled liipthemebundle and all works both with cap depoy and with symfony:assetic:dump task.
Is this a LiipThemeBundle bug?

Feature request - More information in a theme

What are your thoughts on expanding on the theme config so that it has a full name.

eg:

liip_theme:
    load_controllers: false
    themes:
        themeKey1:
            name: 'Full theme name'
        themeKey2:
            name: 'Full theme name 2'

This would then be useful for creating a Choices form type within the application where a user can choose the theme while displaying a full theme name.

Also, I think it would then be handy if there was the option to specify fallback themes inside a theme. This would then allow the following:

liip_theme:
    load_controllers: false
    themes:
        themeKey1:
            name: 'Full theme name'
        themeKey1-mobile:
            name: 'Theme 1 - Mobile'
            fallback:
                - themeKey1
        themeKey2:
            name: 'Full theme name 2'

Let me know what you think. I could submit a PR for the full name functionality along with a choice form type if this is something you would allow?

Assetic dump do not check theme folders

This is issue is pretty known, but I need to admit it's really hard to understand what is the current status of this problem. Would be great to add a documentation page where we talk about this problem, and the current status of how to deal with that.

The problem :
When dumping assets, with assetic:dump command, assetic check just in the Resources/views directory for asset to be generated. It does not check Resources/{theme}/views directory

The simplest current workaround :
"The Problem is that assetic doesn't scan the theme folders. This can be solved by putting the assetic block into a template that is in Bundle/Ressources/views and include this from the theme template."

Notes :
I would not be surprised if there was a way to tell assetic to check in some other directories while assetic:dumping.

Bundle not working with symfony-master?

Hello,

I tryed to install the liip theme bundle with the current symfony standart edition. But I get always and error with composer, because composer can not solve the dependency:
- Installation request for liip/theme-bundle * -> satisfiable by liip/theme-bundle[dev-master].
- Conclusion: don't install symfony/symfony 2.3.x-dev
- liip/theme-bundle dev-master requires symfony/framework-bundle >=2.0,<=2.3-dev -> satisfiable by symfony/symfony[2.0.7, 2.0.x-dev, 2.1.x-dev, 2.2.x-dev, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.9, v2.1.0, v2.1.0-BETA1, v2.1.0-BETA2, v2.1.0-BETA3, v2.1.0-BETA4, v2.1.0-RC1, v2.1.0-RC2, v2.1.1, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.0-BETA1, v2.2.0-BETA2, v2.2.0-RC1, v2.2.0-RC2, v2.2.0-RC3, v2.2.1], symfony/framework-bundle[2.0.7, 2.0.x-dev, 2.1.x-dev, 2.2.x-dev, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.9, v2.1.0, v2.1.0-BETA1, v2.1.0-BETA2, v2.1.0-BETA3, v2.1.0-BETA4, v2.1.0-RC1, v2.1.0-RC2, v2.1.1, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.0-BETA1, v2.2.0-BETA2, v2.2.0-RC1, v2.2.0-RC2, v2.2.0-RC3, v2.2.1].

It seems like liip theme bundle don't accept 2.3.*, but it is written in the composer.json - I'm a litle bit confused now :-/

The minimum stability flag is "dev" and my composer.json looks like:
"php": ">=5.3.3",
"symfony/symfony": "2.3.",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.
",
"twig/extensions": "1.0.",
"symfony/assetic-bundle": "2.1.
",
"symfony/swiftmailer-bundle": "2.2.",
"symfony/monolog-bundle": "2.2.
",
"sensio/distribution-bundle": "2.2.",
"sensio/framework-extra-bundle": "2.2.
",
"sensio/generator-bundle": "2.2.",
"jms/security-extra-bundle": "1.4.
",
"jms/di-extra-bundle": "1.3.",
"gedmo/doctrine-extensions": "
",
"stof/doctrine-extensions-bundle": "",
"liip/theme-bundle": "
"

Have you any idea to solve this problem? :)

Best regards,
Christian

Overwrite Bundle Template not working

Hello everybody,

i have installed the FOSUserBundle and the LiipThemeBundle. I want to overwrite the login form template for the desktop theme.

I have created the template in:
app\Resources\themes\desktop\FOSUserBundle\Security\login.html.twig

Now i want to clear the cache, but everytime i get an error:
Fatal error: Call to a member function getContent() on a non-object in vendor\bundles\Symfony\Bundle\AsseticBundle\Factory\Resource\FileResource.php on line 55

I try to debug this error, but i dont find the reason for it.
I have dumped the template ressource:
object(Symfony\Bundle\FrameworkBundle\Templating\TemplateReference)[5092]
protected 'parameters' =>
array
'bundle' => string '' (length=0)
'controller' => string 'FOSUserBundle/Security' (length=22)
'name' => string 'login' (length=5)
'format' => string 'html' (length=4)
'engine' => string 'twig' (length=4)

Maybe the problem is, that in controller is "FOSUserBundle/Security", this is maybe wrong, but i don't know. Have anyone an idea, how i can resolve this problem?

Tag releases

Hi,

Would it be possible to create tag releases for LiipThemeBundle?

I'd prefer to avoid requiring "dev-master" in my composer.json :)

Assetic issue

It seems as though if I run app/console assetic:dump --env=prod assetic does not dump the css/js for the theme template.

However, if I run app/console assetic:dump --env=dev it finds the file.

I have tried running app/console cache:clear --env=prod before running the dump and also rm -rf app/cache* as well.

References #67

cache:warm generates incorrect app/cache/[env]/templates.php

It seems that the overriding of the template.locator isnt taken into account at this point yet, so the file is generated incorrectly. Maybe the file just needs to be overwritten inside another cache warmer provided by the ThemeBundle or maybe there is some way to adjust this in time.

Might be related to #6

Call to a member function getContent() on a non-object

On windows I got:

Notice: Undefined offset: 1 in vendor\bundles\Liip\ThemeBundle\Locator\FileLocator.php on line 82

afterf replacing DIRECTORY_SEPARATOR with '/' I got errror:

Fatal error: Call to a member function getContent() on a non-object in vendor\symfony\src\Symfony\Bundle\AsseticBundle\Factory\Resource\FileResource.php on line 56

@BundleName annotation not imported?

I'm trying to install JMSSecurityExtraBundle 1.1.0 because Access Control via DI configuration is not supported by the default version included in Symfony 2.0.12

I was getting error "Class Metadata\Driver\LazyLoadingDriver does not exist". In another issue I found out i needed to use the master for [metadata] i trired using version 1.1.0 and the branch and I also delete the lock from deps.lock but i get the following error:

AnnotationException: [Semantical Error] The annotation "@BundleName" in method Liip\ThemeBundle\Locator\FileLocator::locate() was never imported. Did you maybe forget to add a "use" statement for this annotation?

I get this error with metadata 1.0, 1.1.0, 1.1.1 and the branch.

Fatal error: Call to a member function getContent() on a non-object

Fatal error: Call to a member function getContent() on a non-object in /Users/xxx/Documents/www-root/PROJECT/vendor/bundles/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php on line 54

after i place my themes in app/Resources/themes/THEME_NAME/BUNDLE_NAME/views

Newly added theme files not located until cache cleared

Good afternoon,
Just started with LiipThemeBundle - so apologies if I'm trying to run before i can walk.

I have set up 2 themes (say, Brand1 and Brand2) and set fallback to Resources/views/

If I have a template which loaded from the fallback - this works. If I then place a template in (say) Resources/themes/Brand1/ and reload the page, it still pulls the template from the fallback.

Once I clear the cache though, the newly added override template is (correctly) loaded.

I think the cause is down in the Liip\ThemeBundle\Locator\TemplateLocator::locate method - as I understand things, once a template is added to the cache, the locator method then relies on this rather than relocating the template.

Would this be better to use the %%kernel_debug%% value, and always relocate the template if the app is in an environment with debug=true?

Regards,
Ryan

$url for redirect is null in switchAction

Cannot redirect to null - happens if referrer isn't set.

$ git diff
diff --git a/Controller/ThemeController.php b/Controller/ThemeController.php
index 549c362..7559d46 100644
--- a/Controller/ThemeController.php
+++ b/Controller/ThemeController.php
@@ -74,6 +74,8 @@ class ThemeController
         $this->activeTheme->setName($theme);

         $url = $request->headers->get('Referer');
+        if ($url === NULL) $url = "/";
+
         $cookie = new Cookie(
             $this->cookieOptions['name'],
             $theme,

pull #54 broke regular cookie support

Issue #54 broke regular cookie support.

Problem lies in ThemeRequestListener.php

     * @param GetResponseEvent $event
     */
    public function onKernelRequest(GetResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
            if (null !== $this->cookieOptions) {
                $activeCookie = $event->getRequest()->cookies->get($this->cookieOptions['name']);
            }

            if (!$this->newTheme && $this->autoDetect instanceof DeviceDetectionInterface) {
                $activeCookie = $this->newTheme = $this->getThemeType($event->getRequest());
            }

            if ($activeCookie && $activeCookie !== $this->activeTheme->getName()
                && in_array($activeCookie, $this->activeTheme->getThemes())
            ) {
                $this->activeTheme->setName($activeCookie);
            }
        }
    } 

Reverting changes back to use $activeCookie seemed to have fixed things, but I'm not sure what this might imply for the new changes for autodetect.

The problem lies somewhere in $this->newTheme, and might have to do with interference from onKernalReponse, which is also using $this->newTheme.

recursive template inclusion when extending

If I have MyBundle/Resources/themes/site1/pagelayout.html.twig extend MyBundle::pagelayout.html.twig I get a recursive loop. It looks like MyBundle/Resources/themes/site1/pagelayout.html.twig keeps trying to extend itself instead of the extending the base as hoped.

Unable to generate a URL for the named route "_assetic_62d1fdd_0"

I keep running into this issue with Liip, in my template I have

{% block javascripts %}
{{ parent() }}
{% javascripts
'@MyBundle/Resources/themes/default/public/js/prototype-handler.js'
'@MyBundle/Resources/themes/default/public/js/shipping-method.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}

the js files are located in my vendor/MyBundlePath/Resources/themes/default/public/js

(I also tried @MyBundle/Resources/themes/default/public/js/prototype-handler.js and reallocated my files accordingly, didn't work either).

Using several themes in the same process

Currently, it is not possible to use the same template in different themes in the same PHP process, because the Twig_Loader_Filesystem caches the resolution of template names to file names in memory.
Fixing this would require replacing the Filesystem loader with a theme-aware version (it would also be required for #50 btw).

My use case for rendering the template in different themes int he same process is background processing: I select the theme based on the user in my app. The background process sending them emails should also use the right theme. But the process can send emails to users with different themes.
Not being able to change the theme is already an issue when doing it in a command, but it becomes even worse when the logic is in a RabbitMQ consumer (as the process is long-running).

As I need it at work, I will look into implementing it.

assetic:dump does not scan all themes

so i have configured my config :
liip_theme:
themes: ['AAA', 'BBB']
active_theme : 'BBB'

and i executed :
./app/console cache:clear --env=local
./app/console assetic:dump --env=local

but the dump just scan for BBB theme dir only
And AAA not scanned

i want the theme is dynamic, so the assetic:dump must scan all themes dir

layout inheritance

Hello,

Is there any solution to have something like this in our template please ?:

{% extends 'AcmeDemoBundle::layout.html.twig' %}

Fix for the "Common pitfall"

Hello, i have been searching for a long time for this issue because it's not practical to use such template that you advise.

Therefore i think it's possible to add a "read_from" in the config.yml

assetic:
    debug:          true
    write_to: "%kernel.root_dir%/../web"
    bundles:        [ 'MyBundle1', 'MyBundle2' ]
    use_controller: false
    debug: %kernel.debug%
    read_from: %kernel.root_dir%/Resources/views/

Maybe this can be stated as a solution, it's now dumping every assetic as it should. from every theme

SpBower Compatibility

To begin thanks for the projet, this work easily and permit to dispatch content and theme with efficienceness.

Explanation

Recently, i began to use spBower . This is very usefull to provide a good and updated asset management. But as liip theme permit to have many layout in the same bundle, one for each theme, it's possible to have a theme with by example a jquery version and another with a more recent version, it's incompatible with bower process.

I know the this is more an issue in SpBower and i created an issue in : Spea/SpBowerBundle#91

But maybe you will communicate to merge yours knowledges and find a real better solution for permit to use theres two usefull bundle.

Theme override for ::template.html.twig

If the current theme is "phone", and a template contains:

{% extends '::layout.html.twig' %}

we want to search for app/Resources/themes/phone/layout.html.twig
before app/Resources/views/layout.html.twig

The theme does not exist

Hello,
I get an error The theme "phone" does not exist. However, the theme is well placed in the / src / site / siteBundle / Resources / / themes / phone / layout.html.twig
I looked issue #31, but I can not seem to solve my problem.
thank you

Error "assetic.bundles".

i've follow all step on readme, but i got this error :
ParameterNotFoundException: You have requested a non-existent parameter "assetic.bundles".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.