@DI\Observe("claroline_external_parameters_menu_configure")

@param \Claroline\CoreBundle\Menu\ConfigureMenuEvent $event

@return \Knp\Menu\ItemInterface $menu
429346
public function onExternalAuthenticationMenuConfigure(ConfigureMenuEvent $event)
    {
        $name = $this->translator->trans('external_user_group_parameters', [], 'claro_external_user_group');
        $menu = $event->getMenu();
        $menu->addChild(
            $name,
            [
                'route' => 'claro_admin_external_sync_config_index',
            ]
        )->setExtra('name', $name);

        return $menu;
    }
699113
public function on($event, callable $callback, int $priority = 0): EventInterface
    {
        //deal with multiple events
        if (is_array($event)) {
            foreach ($event as $item) {
                $this->on($item, $callback, $priority);
            }

            return $this;
        }

        //set up the observer
        $observer = $this->resolve(EventObserver::class, $callback);

        //is there a regexp ?
        if (strpos($event, '#') === 0 && strrpos($event, '#') !== 0) {
            $this->regex[] = $event;
        //is there a sprintf ?
        //because sscanf will match Render Home Page
        //and Render Home Body with Render %s Page
        //so this needs to be pseudo
        } else if (preg_match('#%[sducoxXbgGeEfF]#s', $event)) {
            //transform that into a regex
            $event = preg_quote($event, '#');
            $event = preg_replace('#%[sducoxXbgGeEfF]#s', '(.+)', $event);
            $event = '#' . $event . '#s';

            $this->regex[] = $event;
        }

        $this->observers[$event][] = [
            'priority' => $priority,
            'observer' => $observer
        ];

        return $this;
    }
1305733
private function addEvent($event)
    {
        if (is_string($event)) {
            $event = Event::named($event);
        }

        if (!$event instanceof EventInterface) {
            throw new \InvalidArgumentException(
                'Events should be provides as Event instances or string, received type: ' . gettype($event)
            );
        }

        $this->events[] = $event;

        return $event;
    }
587333
public static function configureProject(Event $event)
    {
        DirectoryConfigurator::fromEvent($event)->run();
        BundleConfigurator::fromEvent($event)->run();

        // Install assets here since they they were skipped above
        static::installAssets($event, false);
    }
664500
public function onMenuConfigure(ConfigureMenuEvent $event)
    {
        if ($this->permissionResolver->hasAccess('uisites', 'read')) {
            $menu = $event->getMenu();

            $menu->addChild(self::ITEM_SITES, []);
        }
    }
202747
protected function ensureEvent($event): Event
    {
        if (Assert::instanceOf($event, '\\One\\Event\\Event')) {
            return $event;
        } elseif (Assert::string($event)) {
            return new Event($event);
        }

        throw new InvalidArgumentException(
            '`Event` must be `string` or extends class `One\Event\Event`'
        );
    }
156802
public function onExternalAuthenticationMenuConfigure(ConfigureMenuEvent $event)
    {
        $menu = $event->getMenu();
        $menu->addChild(
            'CAS',
            [
                'route' => 'claro_admin_cas_server_config_form',
            ]
        )->setExtra('name', 'CAS');

        return $menu;
    }
680064
public function build(array $options): ItemInterface
    {
        $menu = $this->createStructure($options);

        $menuBuilder = new ConfigureMenuEvent($this->factory, $menu);
        $this->dispatchMenuEvent(ConfigureMenuEvent::PROFILE_SIDEBAR_LEFT, $menuBuilder);

        return $menu;
    }
1151409
public static function fromEvent(Event $event)
    {
        $io = NutStyle::fromComposer($event->getIO());
        $options = Options::fromEvent($event);

        return new static($io, $options);
    }
545974
public function process(EventInterface $event)
    {
        $events = $this->getEventManager();
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }
        $ids = $event->getParam('id');
        if (empty($ids)) {
            return;
        }

        $options = $optionsProvider->getOptions($pane);
        $otherOptions = $optionsProvider->getOtherOptions($pane);
        if ($options->getRoot() == 'trash') {
            $this->error(self::MoveFromTrash);
            return $this->redirect($event);
        }
        if ($otherOptions->getType() == 'search') {
            $this->error(self::MoveToSearch);
            return $this->redirect($event);
        }
        if ($otherOptions->getRoot() == 'trash') {
            $this->error(self::MoveToTrash);
            return $this->redirect($event);
        }
        $newParentId = $otherOptions->getParent();
        foreach ($ids as $id) {
            try {
                $mapper->beginTransaction();
                $tid = $mapper->getTransactionIdentifier();
                $this->mapper->move($id, $newParentId, $tid);
                $events->trigger(
                    __FUNCTION__ . '.move',
                    null,
                    [
                        'content' => $id,
                        'tid' => $tid,
                    ]
                );
                $mapper->commit();
            } catch (UnavailableSourceException $e) {
                $mapper->rollBack();
                $this->setValue($id)->error(self::SourceNotFound);
            } catch (LoopException $e) {
                $mapper->rollBack();
                $meta = $mapper->findMetaById($id);
                $this->setValue($meta['title'])->error(self::LoopError);
            } catch (NestingException $e) {
                $mapper->rollBack();
                $parent = $mapper->findMetaById($newParentId);
                $meta = $mapper->findMetaById($id);
                $this->setValue($meta['title'], $meta['type'], $parent['type'])
                    ->error(self::NestingError);
            } catch (UnavailableDestinationException $e) {
                $mapper->rollBack();
                $this->setValue($newParentId)->error(self::DestinationNotFound);

                // the destination is not available for all elements
                break;
            } catch (Exception $e) {
                $mapper->rollBack();
                if (DEBUG_MODE) {
                    throw new DebugException(
                        $translator->translate('Error: ') . $e->getMessage(),
                        $e->getCode(),
                        $e
                    );
                }
                $meta = $mapper->findMetaById($id);
                $name = isset($meta['title']) ? $meta['title'] : $id;
                $this->setValue($name)->error(self::UnexpectedError);
            }
        }

        return $this->redirect($event);
    }
791988
public function onMenuConfigure(ConfigureMenuEvent $event)
    {
        if (!$this->permissionResolver->hasAccess('uicron', 'list')) {
            return;
        }

        $menu = $event->getMenu();

        $cronsMenu = $menu->getChild(MainMenuBuilder::ITEM_ADMIN);
        $cronsMenu->addChild(self::ITEM_CRONS, ['route' => 'edgar.ezuicron.list']);
    }
945172
protected function createConfigureMenuEvent(ItemInterface $menu, array $options = []): ConfigureMenuEvent
    {
        return new ConfigureMenuEvent($this->factory, $menu, $options);
    }
771965
public function addEvent(EventInterface $event)
    {
        if (!isset($this->events[$event->getName()])) {
            $this->events[$event->getName()] = $event;
        }

        return $this;
    }
1028046
public static function packageInConfig(PackageEvent $event)
    {
        self::addJobByOperationType(
            $event->getOperation(),
            function ($package) {
                return new AddConfig($package);
            },
            function ($package) {
                return new RemoveConfig($package);
            }
        );
    }
602119
public function setEvent(\Spatie\ServerMonitor\Events\Event $event): self
    {
        $this->event = $event;

        return $this;
    }
1238636
public function onBootstrap( EventInterface $event )
    {
        /* @var $event          \Zend\Mvc\MvcEvent */
        /* @var $application    \Zend\Mvc\Application */
        /* @var $serviceManager \Zend\ServiceManager\ServiceManager */

        $application    = $event->getApplication();
        $serviceManager = $application->getServiceManager();

        $application->getEventManager()
                    ->getSharedManager()
                    ->attach(
                        'Zend\Mvc\Application',
                        MvcEvent::EVENT_DISPATCH_ERROR,
                        array( $this, 'onDispatchError' )
                    );

        $response = $event->getResponse();

        if ( $response instanceof HttpResponse &&
             $serviceManager->has( 'RedirectToDomain' ) )
        {
            $redirect   = $serviceManager->get( 'RedirectToDomain' );
            $path       = '';
            $request    = $event->getRequest();

            if ( $request instanceof HttpRequest && $redirect->getUsePath() )
            {
                $path = $request->getRequestUri();
            }

            $url = $redirect->getUrl( $path );

            $response->setStatusCode( 302 )
                     ->getHeaders()
                     ->addHeaders( array(
                         'Location'          => $url,
                         'X-Redirect-Reason' => $redirect->getReason(),
                     ) );

            $this->response = $response->setContent( sprintf(
                '<meta http-equiv="refresh" content="0;url=%1$s">'
                    . '<a href="%1$s">%1$s</a>',
                htmlspecialchars( $url )
            ) );
        }
    }
866059
public function createFromSerializedEvent(SerializedEvent $event)
    {
        return new Event(
            $event->getId(),
            $event->getName(),
            $this->serializer->deserialize(
                $event->getName(),
                $event->getPayload()
            ),
            $event->getPayloadVersion(),
            $event->getVersion(),
            $event->getDate()
        );
    }