Skip to content

Commit

Permalink
Merge branch '11.x' into fix-null-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 committed Dec 1, 2023
2 parents ae45840 + b3cda74 commit 7bb9491
Show file tree
Hide file tree
Showing 25 changed files with 355 additions and 68 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/clone-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Clone branch
on:
workflow_dispatch:
inputs:
base_ref:
required: true
type: string
description: Base branch name for cloning
ref_name:
required: true
type: string
description: Branch name on destination repo

jobs:
clone-branch:
uses: pimcore/workflows-collection-public/.github/workflows/reusable-clone-branch.yaml@v1.0.0-rc.2
if: github.repository == 'pimcore/pimcore'
with:
base_ref: ${{ inputs.base_ref }}
ref_name: ${{ inputs.ref_name }}
target_repo: 'ee-pimcore'
secrets:
SYNC_TOKEN: ${{ secrets.SYNC_TOKEN }}
GIT_NAME: ${{ secrets.GIT_NAME }}
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@
"require-dev": {
"codeception/codeception": "^5.0.3",
"codeception/module-symfony": "^3.1.0",
"codeception/phpunit-wrapper": "^9",
"ergebnis/phpstan-rules": "^2.0",
"phpstan/phpstan": "1.10.43",
"phpstan/phpstan": "1.10.46",
"phpstan/phpstan-symfony": "^1.3.5",
"phpunit/phpunit": "^9.3",
"gotenberg/gotenberg-php": "^1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,33 @@ The installer writes a log in `var/log` which contains any errors encountered du
## 5. Maintenance Cron Job

Maintenance tasks are handled with Symfony Messenger. The `pimcore:maintenance` command will add the maintenance
messages to the bus and run them afterward immediately from the queue. However, it is recommended to set up independent workers that process the queues by running `bin/console messenger:consume pimcore_core pimcore_maintenance pimcore_image_optimize pimcore_asset_update` (using e.g.
`Supervisor`).
messages to the bus. However, `pimcore:maintenance` will not process the maintenance messages itself.
Independent workers are required to consume these messages from the queues and perform maintenance tasks.
In a typical Pimcore installation, you should set up workers for these transports:

| # | Transport name | Purpose |
|---|--------------------------------|-----------------------------------------------------------------------------------------------|
| 1 | pimcore_core | Core background tasks such as converting videos, rendering Asset previews, etc. |
| 2 | pimcore_maintenance | [Maintenance tasks](../../20_Extending_Pimcore/16_Maintenance_Tasks.md) |
| 3 | pimcore_scheduled_tasks | [Scheduled tasks](../../18_Tools_and_Features/03_Scheduling.md) |
| 4 | pimcore_image_optimize | Execute optimizers on Asset image thumbnails |
| 5 | pimcore_asset_update | Process Asset metadata e.g. Documents page count, Video duration/dimensions, Image previews etc. |
| 6 | pimcore_search_backend_message | Update the index for Pimcore backend search. Only if you install `SimpleBackendSearchBundle` |

Beware that the actual transports depend on which core bundles you installed. Therefore, you will need to adjust the list accordingly to your installation.
Use `bin/console debug:messenger` to list all available transports.

Consuming messages from the queues is performed with the `messenger:consume` command (e.g., `bin/console messenger:consume pimcore_core ...`).
You might need to spawn multiple workers, each consuming from a different queue to avoid blocking message processing by long-running tasks.
For example:

```bash
bin/console messenger:consume pimcore_core pimcore_maintenance pimcore_scheduled_tasks pimcore_search_backend_message pimcore_asset_update
bin/console messenger:consume pimcore_image_optimize
```

We recommend following the [Symfony Messenger guide](https://symfony.com/doc/current/messenger.html#deploying-to-production) for setting up
worker processes in production. The following is a simplified example of maintenance tasks execution using cron:

```bash
# this command needs to be executed via cron or similar task scheduler
Expand All @@ -91,9 +116,14 @@ messages to the bus and run them afterward immediately from the queue. However,
# it's recommended to run the following command using a process control system like Supervisor
# please follow the Symfony Messenger guide for a best practice production setup:
# https://symfony.com/doc/current/messenger.html#deploying-to-production
*/5 * * * * /your/project/bin/console messenger:consume pimcore_core pimcore_maintenance pimcore_image_optimize pimcore_search_backend_message --time-limit=300
*/5 * * * * /your/project/bin/console messenger:consume pimcore_core pimcore_maintenance pimcore_scheduled_tasks pimcore_search_backend_message --time-limit=300
*/5 * * * * /your/project/bin/console messenger:consume pimcore_asset_update --time-limit=300
*/5 * * * * /your/project/bin/console messenger:consume pimcore_image_optimize --time-limit=300
```

Refer to [Symfony Messenger](../02_Advanced_Installation_Topics/01_Symfony_Messenger.md) for further information on working
with the messenger component in Pimcore.

> Depending on installed and activated extensions, it might be necessary to add additional transports to the messenger consume command. Please look at the documentation of corresponding extensions for more details.
Keep in mind that the cron job has to run as the same user as the web interface to avoid permission issues (eg. `www-data`).
Expand Down
18 changes: 9 additions & 9 deletions doc/03_Documents/01_Editables/10_Date.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

### Configuration

| Name | Type | Description |
|----------|--------|------------------------------------------------------------------------------------|
| `format` | string | A string which describes how to format the date in editmode, [see possible formats](https://docs.sencha.com/extjs/7.0.0/modern/Ext.Date.html) |
| `outputFormat` | string | A string which describes how to format the date in frontend, [see possible formats](https://www.php.net/manual/en/function.strftime.php#refsect1-function.strftime-parameters) |
| `class` | string | A CSS class that is added to the surrounding container of this element in editmode |
| Name | Type | Description |
|---------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `format` | string | A string which describes how to format the date in editmode and frontend (when outputFormat/outputIsoFormat is not defined), [see possible formats](https://docs.sencha.com/extjs/7.0.0/modern/Ext.Date.html) |
| `outputFormat` | string | **Deprecated:** A string which describes how to format the date in frontend, [see possible formats](https://www.php.net/manual/en/function.strftime.php#refsect1-function.strftime-parameters) |
| `outputIsoFormat` | string | A string which describes how to format the date in frontend, [see possible formats](https://carbon.nesbot.com/docs/#iso-format-available-replacements) |
| `class` | string | A CSS class that is added to the surrounding container of this element in editmode |

## Methods

Expand All @@ -18,15 +19,14 @@
## Simple Example

The following code will create a simple date widget in editmode.
In frontend it will format the date as defined in `format`.
In frontend it will format the date as defined in `outputIsoFormat`.

Localization (output-format, ...) is automatically used from the globally registered locale.
Please read the topic [Localization](../../06_Multi_Language_i18n/README.md).

```twig
{{ pimcore_date('myDate', {
'format': 'd.m.Y',
'outputFormat': '%d.%m.%Y'
})
}}
'outputIsoFormat': 'DD.MM.YYYY'
}) }}
```
11 changes: 11 additions & 0 deletions doc/03_Documents/01_Editables/40_WYSIWYG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

Similar to Textarea and Input you can use the WYSIWYG editable in the templates to provide rich-text editing. TinyMce is installed by default in our demo. Another editor can be installed via the wysiwyg-events you find in `events.js`

## Enable TinyMce

Add the bundle in your `config/bundles.php` file:

```php
\Pimcore\Bundle\TinymceBundle\PimcoreTinymceBundle::class => ['all' => true],
```

After this, make sure PimcoreTinymceBundle is installed with `bin/console pimcore:bundle:list`.
If it is not installed, you can install it with `bin/console pimcore:bundle:install PimcoreTinymceBundle`.

## Add a Custom Editor
Make sure that you add the Editor to `pimcore.wysiwyg.editors`. This array can be used to have different editors for different use cases(documents, objects ...):
```javascript
Expand Down
31 changes: 25 additions & 6 deletions doc/03_Documents/03_Navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,19 @@ For example, generate bootstrap 4.0 style navigation:
```

## Adding Custom Items to the Navigation

In the following example we're adding news items (objects) to the navigation using Twig Extension.

In the following example we're adding
- news items (objects) to an existing navigation with the "pageCallback" attribute
- category items (objects) to the root Navigation with the "rootCallback" attribute
using Twig Extension.

```php
<?php

namespace App\Twig\Extension;

use App\Website\LinkGenerator\NewsLinkGenerator;
use App\Website\LinkGenerator\CategoryLinkGenerator;
use Pimcore\Model\Document;
use Pimcore\Navigation\Container;
use Pimcore\Twig\Extension\Templating\Navigation;
Expand All @@ -289,11 +293,13 @@ class NavigationExtension extends AbstractExtension
{
protected Navigation $navigationHelper;
protected NewsLinkGenerator $newsLinkGenerator;
protected CategoryLinkGenerator $categoryLinkGenerator;

public function __construct(Navigation $navigationHelper, NewsLinkGenerator $newsLinkGenerator)
public function __construct(Navigation $navigationHelper, NewsLinkGenerator $newsLinkGenerator, CategoryLinkGenerator $categoryLinkGenerator)
{
$this->navigationHelper = $navigationHelper;
$this->$newsLinkGenerator = $newsLinkGenerator;
$this->newsLinkGenerator = $newsLinkGenerator;
$this->categoryLinkGenerator = $categoryLinkGenerator;
}

/**
Expand All @@ -302,14 +308,14 @@ class NavigationExtension extends AbstractExtension
public function getFunctions(): array
{
return [
new TwigFunction('app_navigation_news_links', [$this, 'getDataLinks'])
new TwigFunction('app_navigation_links', [$this, 'getNavigationLinks'])
];
}

/**
* @throws \Exception
*/
public function getNewsLinks(Document $document, Document $startNode): Container
public function getNavigationLinks(Document $document, Document $startNode): Container
{
$navigation = $this->navigationHelper->build([
'active' => $document,
Expand All @@ -330,6 +336,19 @@ class NavigationExtension extends AbstractExtension
$page->addPage($uri);
}
}
},
'rootCallback' => function(Container $navigation) {
$list = new \Pimcore\Model\DataObject\Category\Listing;
$list->load();
foreach($list as $category) {
$detailLink = $this->categoryLinkGenerator->generate($category);
$categoryDocument = new \Pimcore\Navigation\Page\Document([
"label" => $category->getName(),
"id" => "object-" . $category->getId(),
"uri" => $detailLink,
]);
$navigation->addPage($categoryDocument);
}
}
]);

Expand Down
9 changes: 9 additions & 0 deletions doc/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Upgrade Notes

## Pimcore 11.2.0
### Elements
#### [Documents]:
- Using `outputFormat` config for `Pimcore\Model\Document\Editable\Date` editable is deprecated, use `outputIsoFormat` config instead.
#### [Data Objects]:
- Methods `getAsIntegerCast()` and `getAsFloatCast()` of the `Pimcore\Model\DataObject\Data` class are deprecated now.
#### [Navigation]
- Add rootCallback option to `Pimcore\Navigation\Builder::getNavigation()`

## Pimcore 11.1.0
### Elements

Expand Down
12 changes: 8 additions & 4 deletions lib/Event/Workflow/GlobalActionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

use Pimcore\Event\Traits\ArgumentsAwareTrait;
use Pimcore\Workflow\GlobalAction;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowInterface;
use Symfony\Contracts\EventDispatcher\Event;

class GlobalActionEvent extends Event
{
use ArgumentsAwareTrait;

protected Workflow $workflow;
protected WorkflowInterface $workflow;

protected mixed $subject = null;

Expand All @@ -35,15 +35,19 @@ class GlobalActionEvent extends Event
* DocumentEvent constructor.
*
*/
public function __construct(Workflow $workflow, mixed $subject, GlobalAction $globalAction, array $arguments = [])
public function __construct(
WorkflowInterface $workflow,
mixed $subject,
GlobalAction $globalAction,
array $arguments = [])
{
$this->workflow = $workflow;
$this->subject = $subject;
$this->globalAction = $globalAction;
$this->arguments = $arguments;
}

public function getWorkflow(): Workflow
public function getWorkflow(): WorkflowInterface
{
return $this->workflow;
}
Expand Down
8 changes: 8 additions & 0 deletions lib/Navigation/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function configureOptions(OptionsResolver $options): void
'root' => null,
'htmlMenuPrefix' => null,
'pageCallback' => null,
'rootCallback' => null,
'cache' => true,
'cacheLifetime' => null,
'maxDepth' => null,
Expand All @@ -76,6 +77,7 @@ protected function configureOptions(OptionsResolver $options): void
$options->setAllowedTypes('root', [Document::class, 'null']);
$options->setAllowedTypes('htmlMenuPrefix', ['string', 'null']);
$options->setAllowedTypes('pageCallback', ['callable', 'null']);
$options->setAllowedTypes('rootCallback', ['callable', 'null']);
$options->setAllowedTypes('cache', ['string', 'bool']);
$options->setAllowedTypes('cacheLifetime', ['int', 'null']);
$options->setAllowedTypes('maxDepth', ['int', 'null']);
Expand All @@ -93,6 +95,7 @@ protected function resolveOptions(array $options): array
* root?: ?Document,
* htmlMenuPrefix?: ?string,
* pageCallback?: ?callable,
* rootCallback?: ?callable,
* cache?: string|bool,
* cacheLifetime?: ?int,
* maxDepth?: ?int,
Expand All @@ -108,6 +111,7 @@ public function getNavigation(array $params): Container
'root' => $navigationRootDocument,
'htmlMenuPrefix' => $htmlMenuIdPrefix,
'pageCallback' => $pageCallback,
'rootCallback' => $rootCallback,
'cache' => $cache,
'cacheLifetime' => $cacheLifetime,
'maxDepth' => $maxDepth,
Expand Down Expand Up @@ -160,6 +164,10 @@ public function getNavigation(array $params): Container
$navigation->addPages($rootPage);
}

if ($rootCallback instanceof \Closure) {
$rootCallback($navigation);
}

// we need to force caching here, otherwise the active classes and other settings will be set and later
// also written into cache (pass-by-reference) ... when serializing the data directly here, we don't have this problem
if ($cacheEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public static function getMail(array|string $recipients = null, string $subject
return $mail;
}

public static function getHttpData(string $url, array $paramsGet = [], array $paramsPost = [], array $options = []): bool|string
public static function getHttpData(string $url, array $paramsGet = [], array $paramsPost = [], array $options = []): false|string
{
$client = \Pimcore::getContainer()->get('pimcore.http_client');
$requestType = 'GET';
Expand Down

0 comments on commit 7bb9491

Please sign in to comment.