Download the PHP package arsthanea/page-actions-bundle without Composer
On this page you can find all versions of the php package arsthanea/page-actions-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package page-actions-bundle
Page subactions
This bundle enables to mount controllers (or any other routing for that matter) under any Kunstmaan CMS page.
In effect, given a /foo/bar
page and a /thank-you
route, you can access /foo/bar/thank-you
and have $page
and
$nodeTranslation
of /foo/bar
provided.
Installation
composer require arsthanea/page-actions-bundle
- Add
PageActionsBundle
to your Kernel - Update your db schema / create migration
- Import the
page_actions
routing in your mainrouting.yml
:
Usage
Configure available resources
First, you need to configure available routes / controllers. Since this routing is highly dynamic, not any route will match any page, so we need to have some hints. List your resources in configuration:
This is either an annotation
and a controller, or a yaml
/ xml
etc with routes, same as you’d use in routing.yml
.
You cannot however use other configuration options such as prefix
, defaults
, etc. The key name is important, it will
be used later.
Create controller
Let’s now define the controller. You can automatically use $page
and $nodeTranslation
in your actions. Besides
that, it’s just a standard controller. For example:
Configure the page
The last piece is configuring the page entity to handle specified actions. Do this by implementing the PageActionsInterface
:
Notice, that the values returned by this method need to match the keys defined in configuration earlier.
Save the page
Nothing works yet. Now you need to save the page, for the custom page routes to be created.
Use the actions
For example, in your default view:
You didn’t specify the url
parameter in your route, but since the resources are mounted relative to a page it
is added automatically by the bundle and you need to provide it when generating routes.