Get an array representing the properties of an application.

@param  \Illuminate\Foundation\Application  $app
@return array
160645
public static function castApplication($app)
    {
        $results = [];

        foreach (self::$appProperties as $property) {
            try {
                $val = $app->$property();

                if (! is_null($val)) {
                    $results[Caster::PREFIX_VIRTUAL.$property] = $val;
                }
            } catch (Exception $e) {
                //
            }
        }

        return $results;
    }
728741
public function connect(Application $app)
    {
        $controllers = $app['controllers_factory'];

        $handler = function ($resource) use ($app) {
            if ($app['logger']) {
                $app['logger']->debug(sprintf('Appending a trailing slash for the request to `/%s`.', $resource));
            }

            $currentRequest = $app['request_stack']->getCurrentRequest();
            $request = Request::create(
                '/' . $resource . '/',
                $currentRequest->getMethod(),
                [],
                $currentRequest->cookies->all(),
                $currentRequest->files->all(),
                $currentRequest->server->all(),
                $currentRequest->getContent()
            );
            $request = $request->duplicate(
                $currentRequest->query->all(),
                $currentRequest->request->all()
            );
            $request->headers->replace($currentRequest->headers->all());

            // Make an internal sub-request based off the request that would have 404'd.
            // http://silex.sensiolabs.org/doc/usage.html#forwards
            return $app->handle($request, HttpKernelInterface::SUB_REQUEST);
        };

        /**
         * Register the catch-all route.
         *
         * Use a look behind assertion to ensure we only match routes
         * with no trailing slash.
         *
         * @link https://stackoverflow.com/questions/16398471/regex-not-ending-with
         */
        $controllers->match('/{resource}', $handler)
                    ->assert('resource', '.*(?<!\/)$')
                    ->bind('no_trailing_slash_handler');

        return $controllers;
    }
294236
protected function assertRequiredKeysExist(Application $app)
    {
        $required = [
            'path.base',
        ];

        $missingKeys = array_diff($required, $app->keys());
        if (false === empty($missingKeys)) {
            $message = 'Missing required config parameters ('.implode(', ', $missingKeys).')';
            throw new \RuntimeException($message);
        }
    }
1219599
public function connect(Application $app)
    {
        /**
         * @var ControllerCollection $collection
         */
        $collection = $app['controllers_factory'];
        $collection
            ->match('/', Controller::INDEX . ':indexAction')
            ->method('GET')
            ->value('template', 'pages/landing');
        $collection
            ->match('/account/login', Controller::INDEX . ':indexAction')
            ->method('POST')
            ->value('template', 'pages/landing');
        $collection
            ->match('/account/create', Controller::ACCOUNT . ':indexAction')
            ->method('POST|GET')
            ->value('template', 'pages/registration');
        $collection
            ->match('/game', Controller::INDEX . ':indexAction')
            ->method('GET')
            ->value('template', 'pages/landing');
        $collection
            ->match('/cities',Controller::CITY.':listAction')
            ->method('GET')
            ->value('template','pages/game/cityList');
        $collection
            ->match('/city/create',Controller::CITY.':createAction')
            ->method('GET')
            ->value('template','pages/game/newcity');


        return $collection;
    }
247371
public function register(Application $app)
    {
        $app['ladybug.options'] = array(
            'theme' => 'modern',
            'expanded' => false,
            'silenced' => false,
            'array_max_nesting_level' => 9,
            'object_max_nesting_level' => 3,
        );

        $app['ladybug.dumper'] = $app->share(function () use ($app) {
            $dumper = new Dumper();
            $dumper->setOptions( $app['ladybug.options'] );

            return $dumper;
        });

        $app['ladybug'] = $app->share(function() use ($app){
            return new LadybugDataCollector( $app['ladybug.dumper'] );
        });

        $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, $app) {
            $twig->addExtension(new LadybugExtension($app));

            return $twig;
        }));

        if( isset( $app['profiler'] ) ) {
            $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
                $loader->addPath($app['rswork.templates_path'], 'Rswork');
                return $loader;
            }));

            $app['rswork.templates_path'] = function () {
                return realpath(__DIR__.'/../../views');
            };

            $app['data_collector.templates'] = array_merge(
                $app['data_collector.templates'],
                array(array('ladybug', '@Rswork/collector/ladybug.html.twig'))
            );

            $app['data_collectors'] = $app->share( $app->extend( 'data_collectors', function( $collectors, $app ){
                $collectors['ladubug'] = $app->share(function( $app ){
                    return $app['ladybug'];
                });

                return $collectors;
            } ) );
        }
    }
389411
public function register(Application $app)
    {
        /** @var ApplicationConfiguration $config */
        $config = $app['config'];

        $app['translator.locale'] = $config->getTranslator()->getLocale();

        $app['translator'] = $app->share(
            function ($app) {
                $translator = new Translator();
                $translator->setLocale($app['translator.locale']);

                return $translator;
            }
        );
    }
462504
public function connect(Application $app)
    {
        $ctrl = parent::connect($app);



        $this->auth = function () use ($app) {
            if (!$app['debug']) {
                $username = $app['request']->server->get('PHP_AUTH_USER', false);
                $password = $app['request']->server->get('PHP_AUTH_PW');

                if ((!$username || !$password) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_REMOTE_USER'], $matches)) {
                    list($username, $password) = explode(':', base64_decode($matches[1]));

                    $username = strip_tags($username);
                    $password = strip_tags($password);
                }

                if (($username != $app['config']['admin']['username']) || ($password != $app['config']['admin']['password'])) {
                    $response = new Response(null, Response::HTTP_UNAUTHORIZED);
                    $response->headers->set('WWW-Authenticate', 'Basic realm="Administration"');

                    return $response;
                }
            }
        };



        /**
         * List items
         */
        $ctrl
            ->get(
                '/list',
                function () use ($app) {
                    return $app['twig']->render(
                        'admin/'.$this->table.'/list.twig',
                        [$this->table.'s' => $app['redbean']->findAll(
                            $this->table,
                            'ORDER BY '.(array_key_exists('position', $app['redbean']->getColumns($this->table)) ? 'position' : 'id')
                        )]
                    );
                }
            )
            ->bind($this->table.'.list')
            ->before($this->auth);



        /**
         * Move item up or down
         */
        $ctrl
            ->get(
                '/move/{model}/{up}',
                function ($model, $up) use ($app) {
                    $model->move($up);
                    $app['redbean']->store($model);

                    return $app->redirect($app['url_generator']->generate($this->table.'.list'));
                }
            )
            ->bind($this->table.'.move')
            ->convert('model', $this->modelProvider)
            ->assert('up', '0|1')
            ->before($this->auth);



        /**
         * Clone item
         */
        $ctrl
            ->get(
                '/clone/{model}',
                function ($model) use ($app) {
                    $clone = $app['redbean']->dup($model->unbox());
                    $model->cloneFilesFor($clone);

                    $app['redbean']->store($clone);

                    $app['session']->getFlashBag()->clear();
                    $app['session']->getFlashBag()->add('success', $app['translator']->trans('success.cloning'));

                    return $app->redirect($app['url_generator']->generate($this->table.'.list'));
                }
            )
            ->bind($this->table.'.clone')
            ->convert('model', $this->modelProvider)
            ->before($this->auth);



        /**
         * Toggle item's visibility
         */
        $ctrl
            ->get(
                '/toggle/{model}',
                function ($model) use ($app) {
                    $model->toggle();
                    $app['redbean']->store($model);

                    return $app->redirect($app['url_generator']->generate($this->table.'.list'));
                }
            )
            ->bind($this->table.'.toggle')
            ->convert('model', $this->modelProvider)
            ->before($this->auth);



        /**
         * Delete item
         */
        $ctrl
            ->get(
                '/delete/{model}',
                function ($model) use ($app) {
                    $app['redbean']->trash($model);

                    $app['session']->getFlashBag()->clear();
                    $app['session']->getFlashBag()->add('success', $app['translator']->trans('success.deletion'));

                    return $app->redirect($app['url_generator']->generate($this->table.'.list'));
                }
            )
            ->bind($this->table.'.delete')
            ->convert('model', $this->modelProvider)
            ->before($this->auth);



        /**
         * Create/update item
         */
        $ctrl
            ->match(
                '/post/{model}',
                function ($model) use ($app) {
                    if ('POST' == $app['request']->getMethod()) {
                        $app['session']->getFlashBag()->clear();

                        $app['hydrator']->hydrate($model);
                        $errors = [];

                        // Format error array
                        foreach ($app['validator']->validate($model) as $error) {
                            $errors[] = [
                                $error->getPropertyPath() => $error->getMessage()
                            ];
                        }

                        if (!count($errors)) {
                            $app['redbean']->store($model);
                            $app['session']->getFlashBag()->add('success', $app['translator']->trans('success.save'));

                            return $app->redirect($app['url_generator']->generate($this->table.'.post', ['model' => $model->id]));
                        }

                        foreach ($errors as $error) {
                            $app['session']->getFlashBag()->add('error', $error);
                        }
                    }

                    return $app['twig']->render('admin/'.$this->table.'/post.twig', [$this->table => $model]);
                }
            )
            ->bind($this->table.'.post')
            ->convert('model', $this->modelProvider)
            ->value('model', 0)
            ->before($this->auth)
            ->method('GET|POST');



        /**
         * Delete item's attached file
         */
        $ctrl
            ->get(
                '/delete_file/{model}/{field}',
                function ($model, $field) use ($app) {
                    $app['session']->getFlashBag()->clear();

                    $file = $model->$field;
                    $model->$field = null;
                    $errors = [];

                    // Format error array
                    foreach ($app['validator']->validate($model) as $error) {
                        $errors[] = [
                            $error->getPropertyPath() => $error->getMessage()
                        ];
                    }

                    if (!count($errors)) {
                        is_file($file) && unlink($file);
                        $app['redbean']->store($model);
                        $app['session']->getFlashBag()->add('success', $app['translator']->trans('success.file_deletion'));
                    }

                    foreach ($errors as $error) {
                        $app['session']->getFlashBag()->add('error', $error);
                    }

                    return $app->redirect($app['url_generator']->generate($this->table.'.post', ['model' => $model->id]));
                }
            )
            ->bind($this->table.'.delete_file')
            ->convert('model', $this->modelProvider)
            ->before($this->auth);



        return $ctrl;
    }
1326131
protected function findApplicationMigrations(): array
	{
		$migrations = [];

		foreach($this->fileSystem->glob($this->application->getPath() . '/migrations/*.php') as $migration)
		{
			$migrations[] = (object) ['package' => null, 'version' => $this->getBasename($migration)];
		}

		return $migrations;
	}
635673
public function register(Application $app)
    {
        $this->app = $app;

        $app['negotiator'] = $app->share(function ($app) {
            return new \Negotiation\Negotiator();
        });

        $app['language.negotiator'] = $app->share(function ($app) {
            return new \Negotiation\LanguageNegotiator();
        });

        $customFormats = $this->customFormats;

        $app['format.negotiator'] = $app->share(function ($app) use($customFormats) {
            $negotiator = new \Negotiation\FormatNegotiator();

            // add new formats
            foreach ($customFormats as $name => $mimeTypes) {
                $negotiator->registerFormat($name, $mimeTypes, true);
            }

            return $negotiator;
        });
    }
1042317
protected function getThemeConfigurationFiles(Container $app)
    {
        $files = [];
        $config_path = $app->make('config')->get('theme.config_path', realpath($app->make('wp.theme')->getRoot()) . '/config');
        
        if (file_exists($config_path) && is_dir($config_path)) {
            foreach (Finder::create()->files()->name('*.php')->in($config_path) as $file) {
                $nesting = $this->getThemeConfigurationNesting($file, $config_path);
                
                $files[$nesting . basename($file->getRealPath(), '.php')] = $file->getRealPath();
            }
        }
        
        return $files;
    }
173749
public function getRecordsToSubstitute(Application $app, $includeReason = false)
    {
        $merged = [];
        /** @var LazaretCheck $check */
        foreach($this->getChecks() as $check) {
            /** @var record_adapter $record */
            $conflicts = $check->listConflicts($app);
            foreach ($conflicts as $record) {
                if($includeReason) {
                    if (!array_key_exists($record->getRecordId(), $merged)) {
                        $merged[$record->getRecordId()] = [
                            'record' => $record,
                            'reasons' => []
                        ];
                    }
                    $merged[$record->getRecordId()]['reasons'][$this->getCheckerName($check)] = $check->getReason($app['translator']);
                }
                else {
                    $merged[$record->getRecordId()] = $record;
                }
            }
        }

        return $merged;
    }
51510
public function getLeafNodes($app = null)
    {
        $leaves = [];

        foreach ($this->nodes as $appName => $nodes) {
            if (!is_null($app) && $app != $appName) {
                continue;
            }
            foreach ($nodes as $name => $migration) {
                // get the nodes  children
                $children = $this->getNodeFamilyTree(
                    $appName,
                    $name
                )->children;

                // if no children exist this must be the latest migration
                // or if it has children and none of them is for app we are
                // checking then this is the latest migrations
                $isLatest = true;
                foreach ($children as $child) {
                    if ($child->appName == $appName) {
                        $isLatest = false;
                    }
                }

                if ($isLatest) {
                    if (!is_null($app)) {
                        $leaves[] = $name;
                    } else {
                        $leaves[$appName][] = $name;
                    }
                }
            }
        }

        return $leaves;
    }
396593
protected function getLoggerIfEnabled($app)
    {
        /** @var ApplicationInterface $app */

        if ($this->logger === false) {
            $settings       = $this->getSettings();
            $loggingEnabled =
                array_key_exists(Settings::KEY_LOGS_ENABLED, $settings) === true &&
                $settings[Settings::KEY_LOGS_ENABLED] === true;

            $this->logger = $loggingEnabled === true ? $app[LoggerInterface::class] : null;
        }

        return $this->logger;
    }
980213
public static function getSimpleAppFormat(array $apps):array
    {
        $narray = array();
        foreach ($apps as $oneapp => $val) {
            $e = AppConfig::getInstance($oneapp);
            if ($e->checkVisibility()) {
                array_push($narray, array("name" => $oneapp, "value" => $val));
            }
        }
        return ($narray);
    }
449935
public function bootstrap(Application $app)
	{
		$this->configureHandlers($app, $this->registerLogger($app));

		// Next, we will bind a Closure that resolves the PSR logger implementation
		// as this will grant us the ability to be interoperable with many other
		// libraries which are able to utilize the PSR standardized interface.
		$app->bind('Psr\Log\LoggerInterface', function($app)
		{
			return $app['log']->getMonolog();
		});
	}
502709
public function getModels($includeAutoCreated = false, $app = null): array
    {
        $this->isAppReady();

        if ($includeAutoCreated && is_null($app)) {
            return $this->allModels;
        }

        if (!is_null($app)) {
            $appModels = $this->appModels[$app];
            if (!$includeAutoCreated) {
                $rModels = [];
                foreach ($appModels as $name => $appModel) {
                    if (!$appModel->getMeta()->autoCreated) {
                        $rModels[$name] = $appModel;
                    }
                }
                $appModels = $rModels;
            }

            return $appModels;
        }

        $rModels = [];
        /** @var $model Model */
        foreach ($this->allModels as $name => $model) {
            if (!$includeAutoCreated && $model->getMeta()->autoCreated) {
                continue;
            }
            $rModels[$name] = $model;
        }

        return $rModels;
    }
904574
public function bootstrap(Application $app)
    {
        $items = [];
        // First we will see if we have a cache configuration file. If we do, we'll load
        // the configuration items from that file so that it is very quick. Otherwise
        // we will need to spin through every configuration file and load them all.
//        if (file_exists($cached = $app->getCachedConfigPath())) {
//            $items = require $cached;
//            $loadedFromCache = true;
//        }

        // Next we will spin through all of the configuration files in the configuration
        // directory and load each one into the repository. This will make all of the
        // options available to the developer for use in various parts of this app.
        $app->share('config', $config = new Config($items, true));

//        if (!isset($loadedFromCache)) {
        $this->loadConfigurationFiles($app, $config);
//        }
        // Finally, we will set the application's environment based on the configuration
        // values that were loaded. We will pass a callback which will be used to get
        // the environment in a web context where an "--env" switch is not present.
//        $app->detectEnvironment(function () use ($config) {
//            return $config->get('app.env', 'production');
//        });
        date_default_timezone_set($config->get('app.timezone', 'UTC'));
        mb_internal_encoding('UTF-8');
    }