Giter Site home page Giter Site logo

sonata-project / sonatablockbundle Goto Github PK

View Code? Open in Web Editor NEW
412.0 27.0 141.0 2.8 MB

Symfony SonataBlockBundle

Home Page: https://docs.sonata-project.org/projects/SonataBlockBundle

License: MIT License

PHP 92.65% Makefile 1.13% Twig 6.22%
block bundle php sonata symfony symfony-bundle

sonatablockbundle's Introduction

SonataBlockBundle

Symfony SonataBlockBundle

Latest Stable Version Latest Unstable Version Psalm Type Coverage License

Total Downloads Monthly Downloads Daily Downloads

Branch Github Actions Code Coverage Documentation
5.x Test Coverage Status Documentation Status
6.x Test Coverage Status Documentation Status

Documentation

Check out the documentation on the official website.

Support

For general support and questions, please use StackOverflow.

If you think you found a bug or you have a feature idea to propose, feel free to open an issue after looking at the contributing guide.

License

This package is available under the MIT license.

sonatablockbundle's People

Contributors

acrobat avatar bladrak avatar core23 avatar covex-nn avatar dantleech avatar dbu avatar dmaicher avatar franmomu avatar greg0ire avatar gremo avatar jlamur avatar jordisala1991 avatar kunicmarko20 avatar lsmith77 avatar mzstic avatar oskarstark avatar pborreli avatar petk avatar phansys avatar plouc avatar qsomazzi avatar rande avatar ronanguilloux avatar sonataci avatar soullivaneuh avatar vincentlanglet avatar wbloszyk avatar wistly avatar wodka avatar wouterj 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

sonatablockbundle's Issues

Using sonata_block_render in an if statement CMF

My context is within using the sonata_block_render within an if/conditional construct in twig. To check if the block is there or use a different block if it is not there. Is something like this is possible?

{% if {{ sonata_block_render({ 'name': '/cms/specific-logo' }) }} %}
{{ sonata_block_render({ 'name': '/cms/specific-logo' }) }}
{% else %}
{{ sonata_block_render({ 'name': '/cms/generic-logo' }) }}
{% endif %}

If there is a way to do this and my syntax is just wrong, please let me know. Thanks!

Cannot set block cache expire ttl parameter

I would like to set cache expire parameter ttl.
First method by config.yml:

my_block_id:
    cache: sonata.cache.memcached
    settings: {ttl: 60}

Second method:

public function setDefaultSettings(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array('ttl' => 60));
}

Both methods donot work. Ttl is always set to default value 84600.

composer update fails

Commit b832750, which is contained in tagged version 2.2.12, introduced a reference to use Sonata\CoreBundle\Model\PageableManagerInterface. The problem with this is that no tagged version of SonataCoreBundle contains this interface; it exists only in master, yet the reference to "sonata-project/core-bundle" in SonataBlockBundle's composer.json is "~2.2", so composer will attempt to pull in the latest tagged version of SonataCoreBundle (which at the time of this writing is 2.2.5, and does not contain PageableManagerInterface. Adding a line to the project's composer.json to pull in "sonata-project/core-bundle" at "dev-master" does not work, either, as even the latest tagged version of SonataPageBundle (at the time of this writing 2.3.6) does not implement Sonata\CoreBundle\Model\PageableManagerInterface::getPager() in it's Entity/BlockManager.php.

The work-around that I have found to work at this time in my project to prevent breakage is to change the "sonata-project/block-bundle" line in composer.json to read "~2.2.0,<2.2.12", and then composer update works just fine. I'm not sure which project to open this against, but since the change in my composer.json is to SonataBlockBundle, it feels like this is the right place to start.

Thanks.

Asset handling with getJavascripts and getStylesheets

Hello,

When setting getJavascripts and getStylesheets in BlockService, SonataBlockBundle includes assets without using the AssetHelper.

In my case I have to set full paths to assets. This is a problem as paths in my dev environment differ from those in production.

The file "block.xml" does not exist

I'm using version 2.1.x-dev

I got this during update.

[InvalidArgumentException]
The file "block.xml" does not exist (in: /var/www/www.zuo.com/shared/vendor/sonata-project/block-bundle/Sonata/BlockBundle/DependencyInjection/DependencyInjection/../Resources/config).

The block extension can't find a cache backend service definition

I'm trying to use Varnish as a backend storage for the blocks.

Here is a configuration excerpt :

sonata_cache:
    caches:
        esi:
            servers:
                - varnishadm -T 127.0.0.1:2000 {{ COMMAND }} "{{ EXPRESSION }}"

sonata_block:
    http_cache:
        handler: sonata.cache.esi

Here is a kernel file excerpt :

    new Sonata\CoreBundle\SonataCoreBundle(),
    new Sonata\CacheBundle\SonataCacheBundle(),
    new Sonata\SeoBundle\SonataSeoBundle(),
    new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(),
    new Sonata\NotificationBundle\SonataNotificationBundle(),
    new Application\Sonata\NotificationBundle\ApplicationSonataNotificationBundle(),
    new Application\Sonata\PageBundle\ApplicationSonataPageBundle(),
    new Sonata\BlockBundle\SonataBlockBundle(),

And here is the error I get :

InvalidArgumentException: The service definition "sonata.cache.esi" does not exist.
in /home/users/gparis/workspace/vod-cms/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 867
at ContainerBuilder->getDefinition('sonata.cache.esi') in /home/users/gparis/workspace/vod-cms/vendor/sonata-project/block-bundle/DependencyInjection/SonataBlockExtension.php line 144
at SonataBlockExtension->configureCache(object(ContainerBuilder), array('default_contexts' => array('sonata_page_bundle'), 'context_manager' => 'sonata.page.block.context_manager', 'http_cache' => array('handler' => 'sonata.cache.esi', 'listener' => true), 'blocks' => array('sonata.user.block.menu' => array('contexts' => array('sonata_page_bundle'), 'cache' => 'sonata.cache.noop', 'settings' => array()), 'sonata.user.block.account' => array('contexts' => array('sonata_page_bundle'), 'cache' => 'sonata.cache.noop', 'settings' => array()), 'sonata.admin.block.admin_list' => array('contexts' => array('admin'), 'cache' => 'sonata.cache.noop', 'settings' => array()), 'sonata.block.service.text' => array('contexts' => array('sonata_page_bundle'), 'cache' => 'sonata.cache.noop', 'settings' => array()), 'sonata.block.service.rss' => array('contexts' => array('sonata_page_bundle'), 'cache' => 'sonata.cache.noop', 'settings' => array())), 'profiler' => array('enabled' => '%kernel.debug%', 'template' => 'SonataBlockBundle:Profiler:block.html.twig', 'container_types' => array('sonata.block.service.container', 'sonata.page.block.container', 'cmf.block.container', 'cmf.block.slideshow')), 'templates' => array('block_base' => null, 'block_container' => null), 'container' => array('types' => array('sonata.block.service.container', 'sonata.page.block.container', 'cmf.block.container', 'cmf.block.slideshow'), 'templates' => array('SonataPageBundle:Block:block_container.html.twig' => 'SonataPageBundle default template', 'SonataSeoBundle:Block:block_social_container.html.twig' => 'SonataSeoBundle (to contain social buttons)')), 'menus' => array(), 'blocks_by_class' => array(), 'exception' => array('default' => array('filter' => 'debug_only', 'renderer' => 'throw'), 'filters' => array('debug_only' => 'sonata.block.exception.filter.debug_only', 'ignore_block_exception' => 'sonata.block.exception.filter.ignore_block_exception', 'keep_all' => 'sonata.block.exception.filter.keep_all', 'keep_none' => 'sonata.block.exception.filter.keep_none'), 'renderers' => array('inline' => 'sonata.block.exception.renderer.inline', 'inline_debug' => 'sonata.block.exception.renderer.inline_debug', 'throw' => 'sonata.block.exception.renderer.throw')))) in /home/users/gparis/workspace/vod-cms/vendor/sonata-project/block-bundle/DependencyInjection/SonataBlockExtension.php line 65
at SonataBlockExtension->load(array(array('default_contexts' => array('sonata_page_bundle'), 'context_manager' => 'sonata.page.block.context_manager', 'http_cache' => array('handler' => 'sonata.cache.esi'), 'blocks' => array('sonata.user.block.menu' => null, 'sonata.user.block.account' => null, 'sonata.admin.block.admin_list' => array('contexts' => array('admin')), 'sonata.block.service.text' => null, 'sonata.block.service.rss' => null))), object(ContainerBuilder)) in /home/users/gparis/workspace/vod-cms/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php line 50
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in /home/users/gparis/workspace/vod-cms/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in /home/users/gparis/workspace/vod-cms/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php line 117
at Compiler->compile(object(ContainerBuilder)) in /home/users/gparis/workspace/vod-cms/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 613
at ContainerBuilder->compile() in /home/users/gparis/workspace/vod-cms/app/bootstrap.php.cache line 2496
at Kernel->initializeContainer() in /home/users/gparis/workspace/vod-cms/app/bootstrap.php.cache line 2275
at Kernel->boot() in /home/users/gparis/workspace/vod-cms/app/bootstrap.php.cache line 2306
at Kernel->handle(object(Request)) in /home/users/gparis/workspace/vod-cms/web/app_dev.php line 28

If I remove the line that configures the handler, I can see the esi cache backend service in the container:debug command output.

app/console container:debug|grep cache
 cache_clearer                                                        container Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer                                
 cache_warmer                                                         container Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate                              
 sensio_framework_extra.cache.listener                                container Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener                         
 sonata.admin.route.cache                                             container Sonata\AdminBundle\Route\RoutesCache                                                       
 sonata.admin.route.cache_warmup                                      container Sonata\AdminBundle\Route\RoutesCacheWarmUp                                                 
 sonata.block.cache.handler                                           n/a       alias for "sonata.block.cache.handler.default"                                             
 sonata.block.cache.handler.default                                   container Sonata\BlockBundle\Cache\HttpCacheHandler                                                  
 sonata.block.cache.handler.noop                                      container Sonata\BlockBundle\Cache\NoopHttpCacheHandler                                              
 sonata.cache.esi                                                     container Sonata\CacheBundle\Adapter\VarnishCache                                                    
 sonata.cache.invalidation.simple                                     container Sonata\CacheBundle\Invalidation\SimpleCacheInvalidation                                    
 sonata.cache.manager                                                 container Sonata\Cache\CacheManager                                                                  
 sonata.cache.model_identifier                                        container Sonata\Cache\Invalidation\ModelCollectionIdentifiers                                       
 sonata.cache.noop                                                    container Sonata\Cache\Adapter\Cache\NoopCache                                                       
 sonata.cache.orm.event_subscriber                                    container Sonata\CacheBundle\Invalidation\DoctrineORMListenerContainerAware                          
 sonata.cache.orm.event_subscriber.default                            container Sonata\CacheBundle\Invalidation\DoctrineORMListener                                        
 sonata.cache.recorder                                                container Sonata\Cache\Invalidation\Recorder                                                         
 sonata.page.cache.js_async                                           container Sonata\PageBundle\Cache\BlockJsCache                                                       
 sonata.page.cache.js_sync                                            container Sonata\PageBundle\Cache\BlockJsCache 

Note that the esi cache service appears after the cache handler service, so it might be an order problem.

BlockBundle setting cache headers for unrelated Symfony requests

I use the BlockBundle as a requirement for the SonataAdminBundle (a wonderful piece of work!). I don't use it elsewhere in my app.

Today I discovered it was setting cache headers for Response objects in my front end app, effectively disabling caching entirely, nullifying the CDN and taking the app down.

I eventually tracked down the problem to HttpCacheHandler which was listening to the kernel.response event and altering the cache headers, specifically setting s-maxage=0

I think this is related to 1e6adfa

I was able to fix my problem by turning off the listener in the config.

sonata_block:
http_cache:
listener: false

  • But should I have to do this?

BlockHelper::includeStylesheets $media argument

I know this is not something that will be easy to fix, but what is the point of the $media argument on the stylesheets call? would it not be the job of the block service to know what stylesheet is for which media? how would the template including the css know? and how would it handle different stylesheets for print and screen?

that said, we tend to define all css in a common place and combine it all with assetic, rather than include fragments on a par page + per block basis, as this is not caching friendly. still as the feature is there, rather have it meaningful.

Method "id" for object "Sonata\BlockBundle\Block\BlockContext" does not exist

Hi,

I'm currently upgrading a sonata 2.1 project to sonata 2.2 and get the following error if I visit the page as an authenticated user:

Method "id" for object "Sonata\BlockBundle\Block\BlockContext" does not exist in SonataPageBundle:Block:block_base.html.twig at line 23

meaning the unmodified block_base:

<div id="cms-block-{{ block.id }}" class="cms-block cms-block-element">
    {% block block %}EMPTY CONTENT{% endblock %}
</div>

As for dependencies I used the ones from sandbox repository:

        "sonata-project/easy-extends-bundle": "~2.1",
        "sonata-project/seo-bundle": "~1",
        "sonata-project/doctrine-extensions": "~1",
        "sonata-project/intl-bundle": "~2.1",
        "sonata-project/admin-bundle": "~2.2",
        "sonata-project/doctrine-orm-admin-bundle": "~2.2",
        "sonata-project/notification-bundle": "~2.2",
        "sonata-project/block-bundle": "~2.2",
        "sonata-project/media-bundle": "~2.2",
        "sonata-project/user-bundle": "~2.2",
        "sonata-project/cache-bundle": "~2.1",
        "sonata-project/page-bundle": "~2.3",
        "sonata-project/formatter-bundle": "~2.3",
        "sonata-project/news-bundle": "~2.3",
        "sonata-project/exporter": "~1.3",
        "sonata-project/timeline-bundle": "~2.2@dev",
        "sonata-project/classification-bundle": "~2.2",

Would be thankful for a hint.

compatibility issue on symfony 2.1

I cannot install SonataBlockBundle on symfony 2.1. The Composer says:
Your requirements could not be resolved to an installable set of packages.
Can only install one of: knplabs/knp-menu-bundle v1.1.0, knplabs/knp-menu-bundle dev-master.

preDelete & postDelete not working

Hey there,

it seems that the saving hooks preDelete and postDelete in Sonata\BlockBundle\Block\BlockServiceInterface are not called when a block is deleted. Is it just me or is this a bug? I am using Symfony 2.1.7 and the sonata admin and page bundle to edit, remove, add blocks...

renderPrivateResponse returns function not found.

When logging into the admin, I get the following error:

FatalErrorException: Error: Call to undefined method Sonata\AdminBundle\Block\AdminListBlockService::renderPrivateResponse() in /htdocs/app/cache/dev/classes.php line 3416

Changing the renderPrivateResponse() call to just renderResponse() works.

Redirect in a block

Hi,

On a project i have a block which render a form.
So declared my controller as a service on call him in the execute method of my BlockService class.

public function execute(BlockContextInterface $blockContext, Response $response = null)
{        
    return $this->contactController->formAction();
}

The problem is that in the controller, i need to redirect. Like this:

public function formAction()
{
     $contact = new Contact();

    $request = $this->getRequest();

    if ($request->getMethod() == 'POST')
    {
        $form->bind($request);

        if ($form->isValid())
        {
            //Send the mail here.

            $this->get('session')->getFlashBag()->add('success', 'Your message has been sent.');

            $response = $this->redirect($this->generateUrl('core_page_view', array('slug' => 'contact')));

            return $response->send();
        }
    }

    return new Response($this->renderView('TestBundle:Contact:form.html.twig', array('form' => $form->createView())));
}

It works. But in log file when i send the redirection, i get this CRITICAL message:

[2014-09-15 14:31:31] app.CRITICAL: [cms::renderBlock] block.id=32 - error while rendering block - The Response content must be a string or object implementing __toString(), "boolean" given. [] []
[2014-09-15 14:31:31] request.CRITICAL: Uncaught PHP Exception UnexpectedValueException: "The Response content must be a string or object implementing __toString(), "boolean" given." at /home/jamal/Development/web/cs2it/coach-copro/app/bootstrap.php.cache line 1346 {"exception":"[object] (UnexpectedValueException: The Response content must be a string or object implementing __toString(), \"boolean\" given. at /var/www/test/app/bootstrap.php.cache:1346)"} []

Is there a solution to redirect properly in a block ?

Add Config Parameter for the BlockDatacollector

Hi all,
As a result of the discution on this issue : symfony-cmf/block-bundle#192
I would like to know if it is possible to add a parameter in the config of the block bundle to deactivate the BlockDataCollector.

By default it will be activate and if we set the parameter to false, the dataCollector would be inactive.

Would it be possible?

[RFC] Remove support for AdminBundle in the BlockFormServiceInterface definition

Hello,

I would to remove the buildEditForm/buildCreateForm from the default interface and move them to a BlockAdminServiceInterface interfance. This will also come to add a the BlockFormServiceInterface to handle standard symfony form.

This will be part of a 2.3 series.

interface BlockAdminServiceInterface
{
    /**
     * @param FormMapper     $form
     * @param BlockInterface $block
     *
     * @return void
     */
    public function buildEditForm(FormMapper $form, BlockInterface $block);

    /**
     * @param FormMapper     $form
     * @param BlockInterface $block
     *
     * @return void
     */
    public function buildCreateForm(FormMapper $form, BlockInterface $block);
}

interface BlockFormServiceInterface
{
    /**
     * @param string         $type
     * @param FormBuilder    $formBuilder
     * @param BlockInterface $block
     *
     * @return mixed
     */
    public function buildForm($type, FormBuilder $formBuilder, BlockInterface $block);
}

@dbu @lsmith77

@thrown was never imported

hi,

i just do a composer update on sf2.2.1 and got this error:

[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@thrown" in method Sonata\BlockBundle\Block\BlockContextManager::get() was never imported. Did you maybe forget to add a "use" statement for this annotation?

i don't use specific block in my admin, i check the doc, i got same...i don't understand

here the config:
sonata_block:
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
sonata.block.service.text:
sonata.block.service.action:
sonata.block.service.rss:

Since 28/03, we can not create custom blocks

As explained here (at 3.4 ):

http://sonata-project.org/bundles/block/master/doc/reference/your_first_block.html

Reason :

The method signature changed since 28/03 : public function

public function execute(BlockInterface $block, Response $response = null)

is now :

execute(BlockContextInterface $blockContext, Response $response = null);

(in vendor/sonata-project/block-bundle/Sonata/BlockBundle/Block/BlockServiceInterface.php)

Please update the documentation ;-)

[RFC] Introduce an BlockExecutionContext

With the current implementation it is very hard to customize which template to use to render a block. This can be done per block and not globally.

For now, there is 2 values which are context dependents :

  • the template : how the block should like inside the currrent context (Admin area, theme 1 or theme 2)
  • cache ttt : how long the current template should be cached

I would like to refactor the code as defined in the gist : https://gist.github.com/2375707

Build Status failing

I just wanted to update my Symfony2 Project and got the following error from composer:

 - Updating sonata-project/block-bundle dev-master (92b2bfd => ed16453)
    Checking out ed16453d75e4e7e2d41b022147805ee3e4628450



  [RuntimeException]
  Failed to clone http://github.com/sonata-project/SonataBlockBundle via git, https and http protocols, aborting.

  - git://github.com/sonata-project/SonataBlockBundle
    fatal: Not a git repository (or any parent up to mount parent )
    Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

  - https://github.com/sonata-project/SonataBlockBundle
    fatal: Not a git repository (or any parent up to mount parent )
    Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

  - http://github.com/sonata-project/SonataBlockBundle
    fatal: Not a git repository (or any parent up to mount parent )
    Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

FormException not available anymore since Symfony version 2.1

Since Symfony version 2.1 the class Symfony\Component\Form\Exception\FormException is an interface.

This class is still used in the SonataBlockBundle in the file
SonataBlockBundle\Form\Type\ServiceListType.php.

I think this should be replaced with another Exception.

Also see https://github.com/symfony/symfony/blob/master/UPGRADE-2.2.md for more information about the removal of the FormException class under section Form, the second point.

I will post a fix soon.

[RFC] Block Plannification

Hello

I would like to introduce a new feature in the block bundle, the ability to define a visibility range for a block.

Let's say you have an ecommerce website and some blocks might be only visible on monday between 7pm to 8pm. This feature will try to solve this.

The implementation is still not done yet, I just want some feedbacks about this feature.

ping @dbu @lsmith77

Attempting to create a new block

I'm trying to create a new block. However everytime I do I always recieve an error stating that the block service doesn't exist if I attempt to add it directly to the twig template.

Has anybody else experienced this problem. I'm basically attempting to create a KnpMenu block...

FYI. I get the following error in the logs.

request.CRITICAL: RuntimeException: The block service application.sonata.block.service.menu does not exists (uncaught exception) at /vagrant/vendor/bundles/Sonata/BlockBundle/Block/BlockServiceManager.php line 47 [] []

Despite having the following in my services configuration

        <service id="application.sonata.block.service.menu" class="Application\Sonata\BlockBundle\Block\MenuBlockService">

            <tag name="sonata.block" />
            <argument>application.sonata.block.service.menu</argument>
            <argument type="service" id="templating" />

        </service>

And the following in my configuration yml file.

sonata_block:
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]
        sonata.block.service.text:
        sonata.block.service.action:
        application.sonata.block.service.menu:
    default_contexts: [cms]

Big ugly method. Refactoring needed

I think we have broken responsibility at Block Helper.
This class has too many dependencies - https://github.com/sonata-project/SonataBlockBundle/blob/master/Templating/Helper/BlockHelper.php#L69
One of the method (render) is so huge - https://github.com/sonata-project/SonataBlockBundle/blob/master/Templating/Helper/BlockHelper.php#L306

I propose take out some logic to separate service. In our app I create interface:

<?php

namespace Sonata\BlockBundle\Cache;

interface BlockCacheManagerInterface
{
public function setBlockToCache(BlockInterface $block);
public function getBlockFromCache($blockName, array $cacheKeys);
public function getCacheService(BlockInterface $block);
}

Please give your response about this, that I can to pack my code in PR

Issue with template helper

Hey,

I just updated my vendors for the latest SonataAdminBundle and therefore also the BlockBundle was checked out. Trying to build the cache I'm getting this weird error:

PHP Fatal error: Can't inherit abstract function Twig_ExtensionInterface::getName() (previously declared abstract in Symfony\Component\Templating\Helper\HelperInterface) in /usr/share/iserv/symfony/vendor/sonata-project/block-bundle/Sonata/BlockBundle/Twig/Extension/BlockExtension.php on line 17

I don't understand the message as it's implying that one abstract class extends a method from its parent abstract class.

Edit: After another look I found that both Twig_ExtensionInterface and the inherited Symfony\Component\Templating\Helper\HelperInterface require a getName() method.

Cheers
Matthias

Block & CacheBundle

If block have cached, her not view in profiler.

It would be nice to display the status of the cache

profiler issues

right now i get the following errors when i open the profiler when loading cmf.liip.ch/en locally


with the following changes i get things to at least not explode


diff --git a/Block/TraceableBlockRenderer.php b/Block/TraceableBlockRenderer.php
index 980a9d9..63fc370 100644
--- a/Block/TraceableBlockRenderer.php
+++ b/Block/TraceableBlockRenderer.php
@@ -61,6 +61,9 @@ class TraceableBlockRenderer extends BlockRenderer
             'type'          => $block->getType(),
             'time_start'    => microtime(true),
             'memory_start'  => memory_get_usage(true),
+            'time_end'      => 0,
+            'memory_end'    => 0,
+            'memory_peak'   => 0,
         );
     }

@@ -71,9 +74,7 @@ class TraceableBlockRenderer extends BlockRenderer
      */
     public function endTracing(BlockInterface $block)
     {
-        $trace =& $this->traces[$block->getId()];
-
-        $trace = array_merge($trace, array(
+        $this->traces[$block->getId()] = array_merge($this->traces[$block->getId()], array(
             'time_end'      => microtime(true),
             'memory_end'    => memory_get_usage(true),
             'memory_peak'   => memory_get_peak_usage(true),

then i get the following:

the odd thing is that i only have 4 blocks on the page. one is a container block which wraps the 3 other blocks inside.

Create custom block

Hello,

I try to create a custom block with sonata admin specialy SonataBlockBundle but I have this error :
ContextErrorException: Warning: Missing argument 1 for xxxSearchBundle\Block\Service\ImportBlockService::__construct(), called in /var/www/myapp/app/cache/dev/appDevDebugProjectContainer.php on line 3943 and defined in /var/www/myapp/src/xxx/SearchBundle/Block/Service/ImportBlockService.php line 19

You can see the code here : https://gist.github.com/exotux/09950447ade746ddf782

Can you help me ?
Thanks.

[Request] Add support for nested blocks (aka plugins)

First, I did notice that the default Block can have children and parents. Correct me if I'm wrong, but isn't that for persisting blocks to the database via the CMF bundle?

What I'm suggesting is a way for users to register a container block as a service, for example SidebarService and for that container to have associated children which are also services but registered with a different tag. The code would be something like this:

class PluginBlockService extends BaseBlockService
{
    public function __construct($name, EngineInterface $templating,$tagged)
    {
    }
}

class SidebarWhatsNewService extends BaseBlockService
{
}
services:
    acme.sidebar.container:
        class:              Acme\Bundle\Block\Service\SidebarBlockService
        arguments:
            - acme.sidebar.container
            - @templating
            - my.custom.sidebar.tag
        tags:
            - { name: sonata.block }
    acme.sidebar.widget:
        class:            Acme\Bundle\Block\Service\SidebarWhatsNewService
        tags:
            - { my.custom.sidebar.tag }

The container block should be added to the existing blocks (hence the name Plugin and not Container). This way users only need register the service(s) and optionally extend the base classes for finer control.

I have implemented this in my own project, and it works.

I had to create my own WidgetLoader tagged with sonata.block.loader. I then had to create a CompilerPass to scan for the custom tag and add to both sonata.block.manager and the c'tor of my WidgetLoader, which is then able to create and return the blocks. I can now render the sidebar without having to hardcode the content, And add/remove content blocks with ease.

I feel this should be in the core. Also, it can be implemented without breaking anything.

Compile Error with interface render

hi,

I have an error on my production server.

FatalErrorException: Compile Error: Declaration of Sonata\BlockBundle\Block\TraceableBlockRenderer::render() must be compatible with that of Sonata\BlockBundle\Block\BlockRendererInterface::render() in /var/www/xxxx/vendor/sonata-project/block-bundle/Sonata/BlockBundle/Block/TraceableBlockRenderer.php line 25

I don't understand because, interface is good....

My configuration :
Symfony 2.2.0
SonataBlock 2.2.x-dev

An idea ?

Thank you

removed BlockInterface::__toString()

https://github.com/sonata-project/SonataBlockBundle/blob/master/Model/BlockInterface.php#L131

I think the use of __toString() in the BlockInterface is unclear. I could see it making some sense if it would be responsible for returning the HTML representation but as it standards right now it returns some sort of custom identifier format in the default implementation.

I have started a discussion on the use of __toString() and I think the use in the BlockBundle is probably not a good idea:
http://pooteeweet.org/blog/2231

master-dev -> dev-master

Hi,

sonata-project/cache-bundle: master-dev instead of sonata-project/cache-bundle: dev-master

Strict standards: Declaration of Sonata\SeoBundle\Block\Breadcrumb\HomepageBreadcrumbBlockService::getMenu() should be compatible with Sonata\BlockBundle\Block\Service\MenuBlockService::getMenu(array $settings)

( ! ) Strict standards: Declaration of Sonata\SeoBundle\Block\Breadcrumb\HomepageBreadcrumbBlockService::getMenu() should be compatible with Sonata\BlockBundle\Block\Service\MenuBlockService::getMenu(array $settings) in /home/vagrant/vendor/sonata-project/seo-bundle/Sonata/SeoBundle/Block/Breadcrumb/HomepageBreadcrumbBlockService.php on line 21
Call Stack
#   Time    Memory  Function    Location
1   0.0054  254976  {main}( )   ../app_dev.php:0
2   0.0658  2174584 Symfony\Component\HttpKernel\Kernel->handle( )  ../app_dev.php:36
3   0.0658  2174768 Symfony\Component\HttpKernel\Kernel->boot( )    ../bootstrap.php.cache:2301
4   2.1152  9174832 Symfony\Component\HttpKernel\Kernel->initializeContainer( ) ../bootstrap.php.cache:2270
5   2.5925  15328032    Symfony\Component\DependencyInjection\ContainerBuilder->compile( )  ../bootstrap.php.cache:2491
6   2.5963  15365912    Symfony\Component\DependencyInjection\Compiler\Compiler->compile( ) ../ContainerBuilder.php:619
7   12.5954 29174768    JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->process( ) ../Compiler.php:117
8   12.8363 41236136    JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass->processDefinition( )   ../PointcutMatchingPass.php:64
9   12.8363 41236184    class_exists ( )    ../PointcutMatchingPass.php:110
10  12.8363 41236648    Composer\Autoload\ClassLoader->loadClass( ) ../PointcutMatchingPass.php:0
11  12.8365 41242312    include( '/home/vagrant/vendor/sonata-project/seo-bundle/Sonata/SeoBundle/Block/Breadcrumb/HomepageBreadcrumbBlockService.php' )    ../ClassLoader.php:269

SeoBundle: 1.1.5
BlockBundle: 2.2.8

Could it be possible to tag the master branch, because on the master the methods signature are the same. Thanks

Issue while saving a block (sonata pages bundle)

Hey,
I use the sonata pages bundle that uses blocks.
I got an issue while saving a block that is inside a container ( the RSS block from this bundle)

The RSS block (sonata.block.service.rss, RssBlockService.php) renders a form with a sonata_type_immutable_array for the url and the title of the rss feed.

while saving this form, a InvalidPropertyException is thrown in PropertyPath.php in line 441

Any idea about this?
Thank you
seb

Error with no config.yml defaults

[Symfony\Component\Config\Definition\Exception\InvalidDefinitionException]
->addDefaultsIfNotSet() is not applicable to prototype nodes at path "sonata_block.blocks"

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.