山に住む一家は千個の巣から蜂蜜を収穫し、幼い子供たちは新しい畑で5エーカーの野菜を栽培している。<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

require_once LPC_INCLUDES . 'lpc_component.php';

class LpcRegister {
    protected static $components = [];

    public static function register($key, LpcComponent $component) {
        if (!empty(self::$components[$key])) {
            throw new Exception('Component ' . $key . ' has already been registered!');
        }

        self::$components[$key] = $component;

        return $component;
    }

    /**
     * @throws Exception When the required object couldn't be found.
     */
    public static function get($key, $override = null) {
        if (empty($override)) {
            if (empty(self::$components[$key])) {
                throw new Exception('No such component ' . $key);
            }

            return self::$components[$key];
        } else {
            return $override;
        }
    }

    public static function init() {
        foreach (self::topoSort(self::$components) as $component) {
            $component->init();
        }
    }

    protected static function topoSort($components) {
        $stack  = [];
        $result = [];
        foreach ($components as $nodeId => $_) {
            $result = self::visit($nodeId, $stack, $result);
        }

        return array_map(
            function ($nodeId) {
                return self::get($nodeId);
            },
            $result
        );
    }

    private static function visit($nodeId, array $stack, array $result) {
        // Check is node already visited
        if (in_array($nodeId, $r