Перейти к основному содержимому

Руководство по разработчику панкера

Поскольку Pimcore использует мощную систему Symfony Bundle, давайте обратимся к Symfony Bundle Документация о том, как начать работу с вашими пользовательскими пучками. Пакет может сделать что угодно - на самом деле, основные функции Pimcore, такие как интерфейс администратора, реализованы как пачки. Из вашего пакета у вас есть возможность расширить систему, от определения новых услуг или маршрутов до зацепления в систему событий или предоставления контроллеров и представлений.

Структура каталога Bundle

См. Структура каталогов для стандартной компоновки каталога пакетов.

Pimcore Puckles

Существует особый вид реализации пакета {c12}, который дает вам дополнительный возможности. Эти пачки обеспечивают аналогичный API, как и плагины в предыдущих версиях:

  • Пакет отображается в команде pimcore:bundle:list с информацией, если пакет может быть установлен или удален.
  • Пакет может быть установлен с помощью pimcore:bundle:install или удаляется с помощью pimcore:bundle:uninstall для запуска установки/удаления (например, для установки/обновления структуры базы данных).
  • Пакет добавляет методы, чтобы изначально регистрировать файлы JS и CSS, которые будут загружены с помощью интерфейса администратора и в режиме редактирования.

Смотрите документацию Пимкорные пучки, чтобы начать с Pimcore Puckles.

генерирование памбров

С Генератор пакета Pimcore мы предоставляем инструмент для генерации скелетов для пакета. Вы можете установить и активировать этот пакет в вашем экземпляре разработки и упростить запуск разработки пакета Pimcore.

# generate bundle interactively  
$ bin/console pimcore:generate:bundle

# generate bundle with a given name and don't ask questions
$ bin/console pimcore:generate:bundle --namespace=Acme/FooBundle --no-interaction


Common Tasks

Below is a list of common tasks and how to achieve them inside your bundles.

Service Configuration

If you want to provide custom services from within your bundle, you must create an Extension to load your service definitions. This topic is covered in detail in the Документация расширения.

You can find an example of how to create an extension for your bundles in Загрузка определений службы.

Auto-Loading Config and Routing Definitions

Bundles can provide config and routing definitions in Resources/config/pimcore which will be automatically loaded with the bundle. See Конфигурация автоматической загрузки и определения маршрутизации for more information.

i18n / Translations

See the Документация компонента перевода Symfony for locations that will be automatically searched for translation files.

For bundles, translations should be stored in the Resources/translations/ directory of the bundle in the format locale.loader (or domain.locale.loader if you want to handle a specific translation domain). In most cases, this will be something like Resources/translations/en.yml, which resolves to the default messages translation domain.

Example: admin.en.yml or messages.en.yml

Translations Domain

A translation domain is only considered valid when it is registered as follows:

pimcore:  
translations:
domains:
- site_1
- site_2

Then only translations stored in a dedicated domain table e.g. translations_DOMAIN are used by the Pimcore translation service.

Security / Authentication

You can fully use the Компонент безопасности Symfony by auto-loading the security configuration as documented above. The best practice is to define the security configuration in a dedicated security.yaml, which can be imported from your bundle's config.yaml.

For further details on security please refer to Безопасность.

Events

To hook into core functions, you can attach to any event provided by the {P10}. Custom listeners can be registered from your bundle by defining an event listener service. Further reading:

  • {P11} for documentation on how to create event listeners and how to register them as a service.
  • {P12} for a list of available events.

Local Storage for Your Bundle

Sometimes a bundle needs to save files (e.g. generated files or cached data, ...). If the data is temporary and should be removed when the Symfony cache is cleared, please use a directory inside the cache directory. The core cache directory can be fetched from the Kernel and is registered as a parameter on the container:

  • $kernel->getCacheDir()
  • %kernel.cache_dir% parameter

If you need persistent storage, create a unique directory in PIMCORE_PRIVATE_VAR, e.g. var/bundles/YourBundleName.

расширение пользовательского интерфейса администратора

В следующем разделе объясняется, как проектировать и структурировать пучки и как зарегистрироваться и использовать события, представленные в бэкэнд PHP и Frontend Ext JS: Событие \ _Listener \ _UI

Добавление редактируемых документов редактируется

См. Добавление документов редактируется


Вы можете предложить улучшение документации или задать вопрос в комментариях.
Если вам нужна полноценная консультация — вы можете заказать её на нашем сайте.