Getting this error at "execute" method.
Declaration must be compatible with BlockServiceInterface->execute(blockContext : \Sonata\BlockBundle\Block\BlockContextInterface, [response : \Sonata\BlockBundle\Block\Response = null])
my composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~1.3",
"symfony/assetic-bundle": "2.1.*",
"misd/guzzle-bundle": "^1.1",
"liip/imagine-bundle": "^1.2",
"sonata-project/admin-bundle": "2.3.3",
"sonata-project/doctrine-orm-admin-bundle": "2.3.2"
My class, where this "execute" method is placed and getting the error:
<?php
namespace Socca\UserBundle\SonataController;
use Socca\UserBundle\Form\Type\UploadingFormType;
use Symfony\Component\HttpFoundation\Response;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Block\BaseBlockService;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UploadingService extends BaseBlockService
{
private $formFactory;
public function getName()
{
return 'uploading';
}
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
$block = $blockContext->getBlock();
$form = $this->getFormFactory()->createBuilder(new UploadingFormType(), null)
->getForm();
if (!$block->getEnabled()) {
return new Response();
}
$settings = $blockContext->getSettings();
$resolver = new OptionsResolver();
$resolver->setDefaults($settings);
$settings = $resolver->resolve($block->getSettings());
return $this->renderResponse('SoccaUserBundle:Block:uploading.html.twig', array(
'block' => $blockContext->getBlock(),
'settings' => $settings,
'form' => $form->createView()
), $response);
}
/**
* @return mixed
*/
public function getFormFactory()
{
return $this->formFactory;
}
/**
* @param mixed $formFactory
*/
public function setFormFactory($formFactory)
{
$this->formFactory = $formFactory;
}
}
If i check the BaseBlockService
class of namespace Sonata\BlockBundle\Block
, it is full of "wrong" methods saying the same "Declaration must be compatible...".
How can i fix it?
Replace
use Symfony\Component\HttpFoundation\Response
byuse Sonata\BlockBundle\Block\Response