0

I have done this before for a Zikula module but I must be forgetting something. As I remember it, if you want to provide a service to a form you have to do three steps.

First, Create a folder in your module called DependencyInjection. Inside it create a php class that uses the YAML loader to load your YAML file. Here is the code for that:

class PaustianPMCIModuleExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new YamlFileLoader($container, new FileLocator(realpath(__DIR__ . '/../Resources/config')));

        $loader->load('services.yml');
    }
}

Second create a services.yml file in the Resources/config/ folder of the module Third, in that services.yml file have your yml to configure the service. Here is that file:

services:
  paustian_pmci_module.container.link_container:
    class: Paustian\PMCIModule\Container\LinkContainer
    arguments: ["@translator.default", "@jms_i18n_routing.router", "@zikula_permissions_module.api.permission"]
    tags:
    - { name: zikula.link_container }

  paustian_pmci_module.person_type:
    class: Paustian\PMCIModule\Form\Person
    arguments: ["@translator.default"]
    tags:
      - { name: form.type }

Right now the load function of the PaustianPMCIModuleExtension class is not being called at all. I did clear the catch to force reloading of everything. I know I am missing something silly, but I just can't seem to see it.

sirandy
  • 1,834
  • 5
  • 27
  • 32
MicroDoc
  • 1
  • 1
  • Do you have a Zikula bundle class? And if so, is it being loaded in AppKernel.php? – Cerad Sep 18 '18 at 17:22
  • Thanks for the comment. How can I check that? – MicroDoc Sep 18 '18 at 17:28
  • https://symfony.com/doc/current/bundles.html Be sure the pick the correct Symfony version as things have changed quite a bit. – Cerad Sep 18 '18 at 17:31
  • Yes, it is being loaded. That is all taken care of by the CMS. I am writing an extension to the CMS. This type of thing works in a very similar class and it loads it's yml correctly. Thanks for looking at the code. – MicroDoc Sep 18 '18 at 18:03
  • It is likely you have an error in namespace or your Bundle class isn't set up appropriately (e.g. `PaustianPMCIModule` class at the root of the module). Another possibility is that the module must be installed for it to work. – craigh Sep 18 '18 at 20:37
  • Thanks Craig, it turned out you were right, I had an error in the Namespace. Once I fixed the typo it all started working. – MicroDoc Sep 19 '18 at 01:37

0 Answers0