Download the PHP package perspeqtive/sulu-action-blocks-bundle without Composer

On this page you can find all versions of the php package perspeqtive/sulu-action-blocks-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sulu-action-blocks-bundle

SuluActionBlocksBundle

compatibility

The Sulu Action Blocks Bundle lets you make application actions available as reusable blocks in Sulu. Editors can select an action in the Sulu admin, configure it when necessary, and place it anywhere in the content tree.

An action can either return HTML that is rendered at the position of the block or a redirect URL that is handled after the action has been executed.

🚀 Features

🛠️ Installation

1. Requirements

2. Install the bundle

Run the following command in your project root:

If Symfony Flex does not register the bundle automatically, add it to config/bundles.php:

📖 Usage

1. Create an action service

Create a service that implements ServiceActionItemInterface. The service is the only application-specific part you need to provide.

The interface requires these four methods:

Method Purpose
getIdentifier() Returns a stable and unique identifier for the action. self::class is a suitable choice.
getTitle() Returns the name shown to editors. It is also used to generate the block name when no configuration block is defined.
getConfigurationBlock() Returns the key of the global block containing the action's configuration fields, or null when the action needs no editor input.
execute() Runs your application logic and returns an ActionExecutionResult. The values configured in Sulu are available in $options.

Register any dependencies of the action as usual. With Symfony autoconfiguration, services implementing ServiceActionItemInterface are registered automatically. If autoconfiguration is disabled, add the bundle tag manually:

2. Add an optional configuration block

If an action needs values from an editor, create a regular Sulu global block in config/templates/blocks/. Its <key> must be the value returned by getConfigurationBlock().

For example, the FeaturedProductsAction above uses the following block:

The values of the block's properties are passed to execute() as the $options array. An action without configuration can return null from getConfigurationBlock(); editors then select it by the title returned from getTitle().

After adding or changing an action or its configuration block, clear or warm up the Symfony cache so that Sulu can update the available action block types:

3. Add action blocks to a page template

Add the action-blocks type to the block property of every page template where editors should be able to use actions:

The bundle adds each registered action to the action-blocks selection automatically. You do not need to add individual action types to the page template.

4. Render action blocks with Twig

Use perspeqtive_render_action_blocks() when rendering the complete value of an action-blocks property:

To render individual entries, use perspeqtive_render_action_block(). Pass the complete block value; it must contain the type field generated by Sulu:

You can add values to the options passed to the action before rendering:

5. Return HTML or a redirect

Return HTML when the action should render content at its position:

Return a redirect URL when the action should redirect the visitor after execution:

Only the HTML value is rendered by the Twig function. Redirects are handled by the bundle's request integration.

6. Cache an action block independently of the page

Action blocks are rendered while the page is rendered, so their output becomes part of the page's HTTP cache entry. If an action is expensive, or if it needs a cache lifetime that differs from the surrounding page, let it implement CacheableActionItemInterface in addition to ServiceActionItemInterface:

Method Purpose
getCacheTtl() Returns the shared cache lifetime of this action's output in seconds. It is sent as Cache-Control: s-maxage=<ttl> on the fragment response.

Instead of being rendered inline, such a block is embedded as an ESI fragment that points at the bundle's fragment controller. The reverse proxy then requests, caches and expires that fragment on its own, independently of the page's <cacheLifetime>.

Import the fragment route

The fragment controller is only reachable once the bundle's route is imported. Bundle routes are never loaded automatically, so add the import to your website routing:

Enable ESI

ESI has to be enabled in the framework configuration, and a reverse proxy that understands <esi:include> has to sit in front of the application:

framework.http_cache uses Symfony's built-in reverse proxy and is the quickest way to get started. In production a dedicated proxy such as Varnish is the usual choice — make sure ESI processing is enabled there as well. Sulu's SuluHttpCacheBundle proxy builds on Symfony's HttpCache and supports ESI too.

Without a surrogate in front of the application, Symfony falls back to rendering the fragment through an internal sub-request. The page still renders correctly, but the fragment is not cached separately. The same fallback applies when framework.esi is disabled entirely — the action is then executed inline and a message is written to the action_block log channel.

Signed fragment URIs

The fragment URI is signed with the application secret, and the controller rejects unsigned or modified URIs with 403. Only actions that implement CacheableActionItemInterface are reachable through it, so the endpoint cannot be used to invoke arbitrary actions with arbitrary options.

Signing covers the scheme and host of the fragment URI. If your reverse proxy terminates TLS or rewrites the host, configure framework.trusted_proxies so that the application reconstructs the original URI — otherwise every fragment request fails with 403.

What to keep in mind

💡 Example implementation

The docs/example directory contains a complete, minimal setup:

👩‍🍳 Contribution

We welcome contributions! Please feel free to fork the repository, add features, and submit a pull request. To maintain high code quality, please include unit tests for all changes and update the documentation accordingly.


All versions of sulu-action-blocks-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-intl Version *
ext-dom Version *
ext-libxml Version *
sulu/sulu Version ^3.0
symfony/monolog-bridge Version ^7.3
symfony/monolog-bundle Version ^4.0
nesbot/carbon Version 3.10.*
friendsofsymfony/rest-bundle Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package perspeqtive/sulu-action-blocks-bundle contains the following files

Loading the files please wait ...