Execute the console command.

@param \Illuminate\Contracts\Events\Dispatcher $events
@param ManagerRegistry                         $registry
495217
public function handle(Dispatcher $events, ManagerRegistry $registry)
    {
        $class = $this->argument('model');
        $em    = $registry->getManagerForClass($class);

        $repository = $em->getRepository($class);

        if (!$repository instanceof SearchableRepository) {
            $repository = new SearchableRepository(
                $em,
                $em->getClassMetadata($class),
                $this->getLaravel()->make(EngineManager::class)
            );
        }

        $events->listen(ModelsImported::class, function ($event) use ($class) {
            $this->line(sprintf(
                '<comment>Imported %d [%s] models up to ID: %s</comment>',
                $event->models->count(),
                $class,
                $event->models->last()->getKey()
            ));
        });

        $repository->makeAllSearchable();

        $events->forget(ModelsImported::class);

        $this->info('All [' . $class . '] records have been imported.');
    }
365067
public static function trigger($event, &$data)
    {
        if (!isset(self::$manager)) {
            self::init();
        }

        return self::$manager->triggerEvent($event, $data);
    }
941355
public function handle(BlueprintManager $manager) {
        $blueprints = $manager->all();

        if(empty($blueprints)) {
            $this->error("Your application doesn't have any blueprints.");

            return;
        }

        $generalTable = new Table($this->output);
        $generalTable->setHeaders($this->headers);
        $generalTable->setRows($this->getTable($blueprints));
        $generalTable->render();
    }
361629
public function fire(string $event, array $arguments = null) {
        return $this->getEventManager()->fire($event, $arguments);
    }
214061
public function handle(Dispatcher $events)
    {
        $class = $this->argument('model');

        $model = new $class();
        $tnt = new TNTSearch();        
        $driver = $model->getConnectionName() ?: config('database.default');
        $config = config('scout.tntsearch') + config("database.connections.$driver");

        $tnt->loadConfig($config);
        $tnt->setDatabaseHandle(app('db')->connection($driver)->getPdo());

        $indexer = $tnt->createIndex($model->searchableAs().'.index');
        $indexer->setPrimaryKey($model->getKeyName());

        $availableColumns = \Schema::getColumnListing($model->getTable());
        $desiredColumns = array_keys($model->toSearchableArray());

        $fields = implode(', ', array_intersect($desiredColumns, $availableColumns));

        $query = "{$model->getKeyName()}, $fields";

        if ($fields == '') {
            $query = '*';
        }

        $indexer->query("SELECT $query FROM {$model->getTable()};");

        $indexer->run();
        $this->info('All ['.$class.'] records have been imported.');
    }
229991
public function fire(ManagerRegistry $registry)
    {
        if (!$this->option('sql') && (!$this->laravel->environment('local') && !$this->option('force'))) {
            $this->error('ATTENTION: This operation should not be executed in a production environment.');
            $this->error('Use the incremental update to detect changes during development and use');
            $this->error('the SQL DDL provided to manually update your database in production.');
        }

        $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();

        foreach ($names as $name) {
            $em   = $registry->getManager($name);
            $tool = new SchemaTool($em);

            $this->comment('');
            $this->message('Checking if database connected to <info>' . $name . '</info> entity manager needs updating...',
                'blue');

            // Check if there are updates available
            $sql = $tool->getUpdateSchemaSql(
                $em->getMetadataFactory()->getAllMetadata(),
                $this->option('clean')
            );

            if (0 === count($sql)) {
                return $this->error('Nothing to update - your database is already in sync with the current entity metadata.');
            }

            if ($this->option('sql')) {
                $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
            } else {
                if ($this->laravel->environment('local') || $this->option('force')) {
                    $this->message('Updating database schema...', 'blue');
                    $tool->updateSchema(
                        $em->getMetadataFactory()->getAllMetadata(),
                        $this->option('clean')
                    );

                    $pluralization = (1 === count($sql)) ? 'query was' : 'queries were';
                    $this->info(sprintf('Database schema updated successfully! "<info>%s</info>" %s executed',
                        count($sql),
                        $pluralization));
                } else {
                    $this->message(sprintf('The Schema-Tool would execute <info>"%s"</info> queries to update the database.',
                        count($sql)));
                }
            }
        }

        if (!$this->option('sql') && (!$this->laravel->environment('local') && !$this->option('force'))) {
            $this->info('');
            $this->message('Please run the operation by passing one - or both - of the following options:');
            $this->comment(sprintf('    <info>php artisan %s --force</info> to execute the command',
                $this->getName()));
            $this->comment(sprintf('    <info>php artisan %s --sql</info> to dump the SQL statements to the screen',
                $this->getName()));
        }
    }
434527
public function dispatchEvent($event, ...$arguments)
    {
        $this->dispatchEventToEventCallbacks($event, $arguments);

        $this->dispatchEventToEventHandler($event, $arguments);
    }
815879
public static function run(I_Registry $registry, Manager $evtManager)
    {
        $instances = [];
        $methods = array_keys($registry->get('core/log', []));
        foreach ($methods as $method) {
            $levels = $registry->get(
                sprintf('core/log/%s', $method),
                []
            );
            foreach (array_keys($levels) as $level) {
                $methodRegistry = $registry->newFromKey(
                    sprintf('core/log/%s/%s', $method, $level)
                );
                $methodRegistry->set('name',  $method);
                $methodRegistry->set('level', $level);
                $methodRegistry->set('env',   $registry->get('core/env'));
                $class = $methodRegistry->get('class', null, false);
                if (is_null($class)) {
                    $class = sprintf(
                        "\\donbidon\\Core\\Log\\Method\\%s",
                        $method
                    );
                }
                $instance = new $class($methodRegistry, $evtManager);
                if (!($instance instanceof Method\A_Method)) {
                    throw new \RuntimeException(sprintf(
                        "Class '%s' has to be instance of %s",
                        $class,Method\A_Method::class
                    ));
                }
                $instances[] = $instance;
            }
        }

        return $instances;
    }
572674
protected function registerManagerRegistry()
    {
        $this->app->singleton('registry', function ($app) {
            $registry = new IlluminateRegistry($app, $app->make(EntityManagerFactory::class));

            // Add all managers into the registry
            foreach ($app->make('config')->get('doctrine.managers', []) as $manager => $settings) {
                $registry->addManager($manager, $settings);
            }

            return $registry;
        });

        // Once the registry get's resolved, we will call the resolve callbacks which were waiting for the registry
        $this->app->afterResolving('registry', function (ManagerRegistry $registry, Container $container) {
            $this->bootExtensionManager();

            BootChain::boot($registry);
        });

        $this->app->alias('registry', ManagerRegistry::class);
        $this->app->alias('registry', IlluminateRegistry::class);
    }
769269
public function command(ConsoleCommandEvent $event)
    {
        /** @var BridgeCommand $command */
        $command = $event->getCommand();

        if (!in_array($command->getName(), $this->getSupportedCommands())) {
            return;
        }

        $command->setRegistry($this->registry);
    }
808961
public function handle(DomainEvent $event) : void {
        $method = lcfirst($this->getShortName($event));
        if (method_exists($this, $method)) {
            $this->$method($event);
        }
    }
319135
public function handle(ManagerRegistry $registry)
    {
        $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();

        foreach ($names as $name) {
            $em = $registry->getManager($name);

            $this->comment('');
            $this->message('Generating getter and setter for <info>' . $name . '</info> entity manager...', 'blue');

            $cmf = new DisconnectedClassMetadataFactory();
            $cmf->setEntityManager($em);
            $metadatas = $cmf->getAllMetadata();
            $metadatas = MetadataFilter::filter($metadatas, $this->option('filter'));

            $destPath = base_path($this->argument('dest-path') ?:'app/Entities');

            if (!is_dir($destPath)) {
                mkdir($destPath, 0777, true);
            }

            $destPath = realpath($destPath);

            if (!file_exists($destPath)) {
                throw new \InvalidArgumentException(
                    sprintf("Proxies destination directory ' < info>%s </info > ' does not exist.",
                        $em->getConfiguration()->getProxyDir())
                );
            }

            if (count($metadatas)) {

                // Create EntityGenerator
                $entityGenerator = new EntityGenerator();

                $entityGenerator->setGenerateAnnotations($this->option('generate-annotations'));
                $entityGenerator->setGenerateStubMethods($this->option('generate-methods'));
                $entityGenerator->setRegenerateEntityIfExists($this->option('regenerate-entities'));
                $entityGenerator->setUpdateEntityIfExists($this->option('update-entities'));
                $entityGenerator->setNumSpaces($this->option('num-spaces'));
                $entityGenerator->setBackupExisting(!$this->option('no-backup'));

                if (($extend = $this->option('extend')) !== null) {
                    $entityGenerator->setClassToExtend($extend);
                }

                foreach ($metadatas as $metadata) {
                    $this->comment(
                        sprintf('Processing entity "<info>%s</info>"', $metadata->name)
                    );
                }

                // Generating Entities
                $entityGenerator->generate($metadatas, $destPath);

                // Outputting information message
                $this->comment(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath));
            }
        }
    }
706757
@Override
    public boolean invoke(Manager manager, Object event) {
        try {
            Object[] arguments = resolveArguments(manager, event);
            if (containsNull(arguments)) {
                return false;
            }
            if (!method.isAccessible()) {
                method.setAccessible(true);
            }
            method.invoke(target, arguments);
            return true;
        } catch (Exception e) {
            if (e instanceof InvocationTargetException) {
                Throwable cause = ((InvocationTargetException) e).getTargetException();
                // Exception already wrapped by another Observer down the chain.
                if (cause instanceof InvocationException) {
                    throw (InvocationException) cause;
                }
                throw new InvocationException(cause);
            }
            throw new InvocationException(e);
        }
    }
991839
public function dispatch(DomainEvents $events) : void {
        $events->each(function (DomainEvent $event) {
            $this->listeners->each(function (Listener $listener) use ($event) {
                    $listener->handle($event);
            });
        });
    }
85862
public function execute() {
        global $CFG, $DB;

        $timenow = time();

        // Cleanup read and unread notifications.
        if (!empty($CFG->messagingdeleteallnotificationsdelay)) {
            $notificationdeletetime = $timenow - $CFG->messagingdeleteallnotificationsdelay;
            $params = array('notificationdeletetime' => $notificationdeletetime);
            $DB->delete_records_select('notifications', 'timecreated < :notificationdeletetime', $params);
        }

        // Cleanup read notifications.
        if (!empty($CFG->messagingdeletereadnotificationsdelay)) {
            $notificationdeletetime = $timenow - $CFG->messagingdeletereadnotificationsdelay;
            $params = array('notificationdeletetime' => $notificationdeletetime);
            $DB->delete_records_select('notifications', 'timeread < :notificationdeletetime', $params);
        }
    }
249656
public function handle(EventInterface $event)
    {

        try {
            // load the application server, naming directory and system configuration instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */
            $namingDirectory = $applicationServer->getNamingDirectory();
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\SystemConfigurationInterface $systemConfiguration */
            $systemConfiguration = $applicationServer->getSystemConfiguration();

            // initialize the loggers
            $loggers = array();
            foreach ($systemConfiguration->getLoggers() as $loggerNode) {
                $loggers[$loggerNode->getName()] = LoggerFactory::factory($loggerNode);
            }

            // register the logger callbacks in the naming directory
            foreach ($loggers as $name => $logger) {
                $namingDirectory->bind(sprintf('php:global/log/%s', $name), $logger);
            }

            // set the initialized loggers finally
            $applicationServer->setLoggers($loggers);

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
677241
public function handle(Registered $event)
    {
        if ($event->user instanceof MustVerifyEmail && ! $event->user->hasVerifiedEmail()) {
            $event->user->sendEmailVerificationNotification();
        }
    }