Using a Facade

Edit on GitHub

Using the Facade from a Controller or a Plugin

In Zed’s communication layer the facade of the same module is available with the getFacade() method from all controllers and plugins. image

A typical usage from a controller looks like this. The controller retrieves data from a submitted form and calls a method of a facade to save it.

<?php
namespace Pyz\Zed\Glossary\Communication\Controller;

class FormController extends AbstractController
{
    public function translationAction()
    {
        // ...
        if ($form->isValid()) {
            $translation = new TranslationTransfer();
            $translation->fromArray($form->getRequestData());
            $this->getFacade()->saveTranslation($translation);
        }
        // ...
    } 

Using a Facade from Another Module

To connect modules you can provide the facade to another module. To do so, you need to use the dependency provider mechanism.