Skip to main content
Improves post formatting.
Link
kenorb
  • 14.3k
  • 10
  • 98
  • 168

Drupal 8 How to get the updated content of a block via an AjaxAJAX call?

added 828 characters in body
Source Link

Changing the signature to static

    namespace Drupal\livequotes\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Controller\ControllerBase;

/**
 * Controller routines for livequotes routes.
 */

class LivequotesController extends ControllerBase{
    
    protected $entity;

    public static function create(ContainerInterfaceContainer $container) {
        return new static($container->get('entity'));
    }
    
    public function __construct(EntityInterface $em) {
        $this->entity = $em;
    }
    /**
     * Re-render a specific block (yeah if we do something it should be generic).
     */
    public function livequotesShowBlock() 
    {
        $block_id = "livequotes_content";
        $block = $this->entity->getStorage('block')->load($block_id);
        return $this->entity->getViewBuilder('block')->view($block);
    }
}

Changing the signature to

public static function create(ContainerInterface $container)

Changing the signature to static

    namespace Drupal\livequotes\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Controller\ControllerBase;

/**
 * Controller routines for livequotes routes.
 */

class LivequotesController extends ControllerBase{
    
    protected $entity;

    public static function create(Container $container) {
        return new static($container->get('entity'));
    }
    
    public function __construct(EntityInterface $em) {
        $this->entity = $em;
    }
    /**
     * Re-render a specific block (yeah if we do something it should be generic).
     */
    public function livequotesShowBlock() 
    {
        $block_id = "livequotes_content";
        $block = $this->entity->getStorage('block')->load($block_id);
        return $this->entity->getViewBuilder('block')->view($block);
    }
}
added 401 characters in body
Source Link

UPDATE 4

Changing the signature to

public static function create(ContainerInterface $container)

results in the following error:

Declaration of Drupal\livequotes\Controller\LivequotesController::create() must be compatible with Drupal\Core\DependencyInjection\ContainerInjectionInterface::create(Symfony\Component\DependencyInjection\ContainerInterface $container)

UPDATE 4

Changing the signature to

public static function create(ContainerInterface $container)

results in the following error:

Declaration of Drupal\livequotes\Controller\LivequotesController::create() must be compatible with Drupal\Core\DependencyInjection\ContainerInjectionInterface::create(Symfony\Component\DependencyInjection\ContainerInterface $container)

added 48 characters in body
Source Link
Loading
edited title
Source Link
Loading
edited title
Link
Loading
added 1060 characters in body
Source Link
Loading
added 288 characters in body
Source Link
Loading
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Loading
Tweeted twitter.com/#!/StackDrupal/status/454622379109810176
Source Link
Loading