Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • 5.x
  • ll-php8-bs5
  • release_5_bs5
  • ll-php8
  • 4.x
  • laminas_migration
  • release_1.0.0.2
  • release_4.0.0
  • release_3.2.8
  • bootstrap4_migration
  • 1.0.0.3
  • 6.0.7
  • 6.0.6
  • 6.0.5
  • 6.0.4
  • 6.0.3
  • 6.0.2
  • 6.0.1
  • 5.1.1
  • 6.0.0
  • 5.1.0
  • 5.0.0
  • 4.0.2
  • 3.2.11
  • 4.0.1
  • 3.2.10
  • 4.0.0
  • 1.0.0.2
  • 3.2.9
  • 3.2.8
31 results

LdapConnectViewHelper.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    LdapConnectViewHelper.php 1.54 KiB
    <?php
    
    namespace UnicaenAuth\View\Helper;
    
    use Zend\Form\Form;
    use Zend\View\Helper\AbstractHelper;
    use Zend\View\Renderer\PhpRenderer;
    use Zend\View\Resolver\TemplatePathStack;
    
    /**
     * Aide de vue dessinant le formulaire d'authentification LDAP,
     * si l'authentification LDAP est activée.
     *
     * @method PhpRenderer getView()
     * @author Unicaen
     */
    class LdapConnectViewHelper extends AbstractHelper
    {
        /**
         * @var bool
         */
        protected $enabled = true;
    
        /**
         * @var Form
         */
        protected $form;
    
        /**
         * @param bool $enabled
         * @return $this
         */
        public function setEnabled($enabled = true)
        {
            $this->enabled = $enabled;
    
            return $this;
        }
    
        /**
         * @param Form $form
         * @return $this
         */
        public function __invoke(Form $form)
        {
            $this->form = $form;
    
            $this->getView()->resolver()->attach(
                new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]])
            );
    
            return $this;
        }
    
        /**
         * @return string
         */
        public function __toString()
        {
            if (! $this->enabled) {
                return '';
            }
    
            try {
                return $this->getView()->render("connect", [
                    'title' => null,
                    'enabled' => $this->enabled,
                    'form' => $this->form,
                    'redirect' => null,
                    'passwordReset' => false,