Download the PHP package basilicom/path-formatter-bundle without Composer

On this page you can find all versions of the php package basilicom/path-formatter-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 path-formatter-bundle

Basilicom Extended Path Formatter Bundle for Pimcore

Usecase / Summary

If you want to display specific information of a DataObject when it's listed in a relation-field (Many-to-Many, Many-to-One, Advanced Many-to-Many, etc.), you can use this bundle to easily configure a display pattern.

Instead of creating a new PathFormatter PHP class for every specific display requirement (e.g., showing the name, price, and currency of a product), you can simply define patterns in your configuration.

You can also define specific pattern overwrites for a class when it is referenced in a specific field of another class:

While the product will be formatted like Sneakers 19.99EUR in most relation-fields, the products field in the ProductList class will show them like #13 Sneakers.


Version information

Bundle Version PHP Pimcore
^1.0 ^7.3 ^6.0
^2.0 ^8.0 ^10.0
^3.0 ^8.1 ^11.0
^4.0 ^8.1 / ^8.3 ^11.0 || ^12.0

Works with the classic admin UI as well as with Pimcore Studio (via pimcore/studio-backend-bundle). Pimcore 12 itself requires PHP 8.3 or 8.4.

Upgrading from 3.x

Configuration files keep working, but some behaviour changed:

Installation

  1. Install the bundle using composer:

  2. Enable the bundle:
    • Pimcore >= 10: The bundle should be automatically registered. If not, add it to config/bundles.php.
    • Pimcore < 10: Add the following to AppKernel::registerBundlesToCollection():

Configuration

  1. Create a configuration file (e.g., config/packages/basilicom_path_formatter.yaml).
  2. Configure your patterns using the full qualified class names as keys.

Basic Configuration

Use curly brackets {} to reference class properties. Any property accessible via a public getter (e.g., {name} calls getName()) can be used.

Nested Properties

The bundle supports nested property access using dot notation. For example, if a Product has a Category, and you want to show the category name:

Note: This will call $product->getCategory()->getName().

Contextual Pattern Overwrites

You can override patterns based on the context (the parent object and the specific field).

Formatting Documents and Assets

The formatter is not limited to DataObjects; it also works for Assets and Documents.

Additional Features

Optional Parts

Anything wrapped in [[ … ]] disappears when all placeholders inside it are empty. Without it, a missing value leaves punctuation behind (Sneakers ( )):

Sneakers (19.99 EUR) when the price is set, Sneakers when it is not. Single brackets stay literal, groups are not nested.

Expressions

{{ … }} evaluates a Symfony expression with the related element available as element and the editor's language as locale. Use it for formatting; use {…} for plain values.

Note that expressions read methods, not properties: element.getPrice(), not element.price. Pimcore's properties are protected, so property syntax would silently yield nothing.

These functions are available:

Function Example
number(value, decimals = 2) number(element.getPrice(), 2) → 19,99 (formatted for the editor's locale)
date(value, format = 'd.m.Y') date(element.getCreationDate(), 'Y-m-d')
upper(value) / lower(value) / trim(value) upper(element.getKey())
truncate(value, length, suffix = '…') truncate(element.getName(), 40)
trans(key, domain = 'admin') trans('product.label')

Patterns are checked for syntax errors when the container is built, so a broken expression fails the deployment instead of the editor's grid. An expression that fails at runtime (a null in the middle of a call chain, for example) renders as empty and is logged.

Translations

{@some.key} inserts an admin translation in the language of the logged-in editor. The same is available inside expressions as trans('some.key').

Default Pattern

default_pattern is used for every element that no other pattern matches — DataObjects, Assets and Documents alike.

Pattern Precedence

When several patterns match a target, the bundle picks:

  1. a contextual overwrite (SourceClass::fieldName) matching the current source object and field,
  2. otherwise the pattern whose class is the most specific one the target is an instance of,
  3. otherwise default_pattern.

So with Product extends AbstractProduct, a pattern configured for Product always wins over one configured for AbstractProduct, regardless of the order in your YAML file.

Inheritance in DataObjects

By default, inherited values are used when resolving placeholders:

Caching

Formatted paths are cached in the Pimcore cache and tagged with every element that was touched while resolving a pattern — the target itself and everything reached via dot notation. Saving any of those elements invalidates the entry.

This matters in practice: both the classic UI and Pimcore Studio request formatted paths per relation field instance, which means one HTTP request per FieldCollection entry. The cache turns those repeated requests into cache hits instead of repeated object loads.

One limitation: {…} placeholders register a cache tag for every element they traverse, but {{ … }} expressions cannot. If an expression reaches a different element, its value is only refreshed when the target itself changes.

Skipping Containers

If relation fields in a specific container are too expensive to format, exclude the container instead of the field:

Those relations then show their plain path, and no element is loaded for them at all.

Debugging

Prints the pattern that matches, the rendered result, the cache tags, and what each placeholder resolved to — including the ones that came out empty.

Asset Previews

If a referenced property resolves to a Pimcore\Model\Asset\Image, the bundle renders the pimcore-system-treepreview thumbnail of it in the relation list.

If the target element itself is an Asset\Image, a preview is also prepended to the pattern.

Escaping

Resolved property values are HTML-escaped before they are inserted into the pattern, so editor content cannot inject markup into the admin UI. The pattern itself and the asset preview generated by this bundle are the only raw HTML in the output.

Usage in Pimcore Admin

To apply the formatter to a field:

  1. Open your Class Definition.
  2. Select a relation field (e.g., Many-to-Many Relation).
  3. In the Formatter input field, enter the service ID: @Basilicom\PathFormatterBundle\DependencyInjection\BasilicomPathFormatter

Author: Alexander Heidrich (Basilicom GmbH)
License: MIT — see LICENSE


All versions of path-formatter-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
pimcore/pimcore Version ^11.0 || ^12.0
symfony/expression-language Version ^6.4 || ^7.0
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 basilicom/path-formatter-bundle contains the following files

Loading the files please wait ...