src/Components.php
public static function getApp($bUseCache = true): Component
    {
        //  If we have already fetched this data then don't get it again
        if ($bUseCache && isset(static::$aCache['APP'])) {
            return static::$aCache['APP'];
        }

        // --------------------------------------------------------------------------

        $sComposer = @file_get_contents(NAILS_APP_PATH . 'composer.json');

        if (empty($sComposer)) {
            ErrorHandler::halt('Failed to get app configuration; could not load composer.json');
        }

        $oComposer = @json_decode($sComposer);

        if (empty($oComposer)) {
            ErrorHandler::halt('Failed to get app configuration; could not decode composer.json');
        }

        $aComposer = (array) $oComposer;
        $aNails    = !empty($oComposer->extra->nails) ? (array) $oComposer->extra->nails : [];
        $oOut      = new Component(
            (object) [
                'slug'        => 'app',
                'name'        => 'app',
                'description' => ArrayHelper::getFromArray('description', $aNails, ArrayHelper::getFromArray('description', $aComposer)),
                'homepage'    => ArrayHelper::getFromArray('homepage', $aNails, ArrayHelper::getFromArray('homepage', $aComposer)),
                'authors'     => ArrayHelper::getFromArray('authors', $aNails, ArrayHelper::getFromArray('authors', $aComposer)),
                'extra'       => (object) [
                    'nails' => (object) [
                        'namespace'  => '\\App\\',
                        'moduleName' => ArrayHelper::getFromArray('moduleName', $aNails, ''),
                        'data'       => ArrayHelper::getFromArray('data', $aNails, null),
                        'autoload'   => ArrayHelper::getFromArray('autoload', $aNails, null),
                    ],
                ],
            ],
            NAILS_APP_PATH,
            './',
            true
        );

        // --------------------------------------------------------------------------

        if ($bUseCache) {
            static::$aCache['APP'] = $oOut;
        }

        return $oOut;
    }
public static function getApp($bUseCache = true): Component
    {
        //  If we have already fetched this data then don't get it again
        if ($bUseCache && isset(static::$aCache['APP'])) {
            return static::$aCache['APP'];
        }

        // --------------------------------------------------------------------------

        $sComposer = @file_get_contents(NAILS_APP_PATH . 'composer.json');

        if (empty($sComposer)) {
            ErrorHandler::halt('Failed to get app configuration; could not load composer.json');
        }

        $oComposer = @json_decode($sComposer);

        if (empty($oComposer)) {
            ErrorHandler::halt('Failed to get app configuration; could not decode composer.json');
        }

        $aComposer = (array) $oComposer;
        $aNails    = !empty($oComposer->extra->nails) ? (array) $oComposer->extra->nails : [];
        $oOut      = new Component(
            (object) [
                'slug'        => 'app',
                'name'        => 'app',
                'description' => ArrayHelper::getFromArray('description', $aNails, ArrayHelper::getFromArray('description', $aComposer)),
                'homepage'    => ArrayHelper::getFromArray('homepage', $aNails, ArrayHelper::getFromArray('homepage', $aComposer)),
                'authors'     => ArrayHelper::getFromArray('authors', $aNails, ArrayHelper::getFromArray('authors', $aComposer)),
                'extra'       => (object) [
                    'nails' => (object) [
                        'namespace'  => '\\App\\',
                        'moduleName' => ArrayHelper::getFromArray('moduleName', $aNails, ''),
                        'data'       => ArrayHelper::getFromArray('data', $aNails, null),
                        'autoload'   => ArrayHelper::getFromArray('autoload', $aNails, null),
                    ],
                ],
            ],
            NAILS_APP_PATH,
            './',
            true
        );

        // --------------------------------------------------------------------------

        if ($bUseCache) {
            static::$aCache['APP'] = $oOut;
        }

        return $oOut;
    }
public static function getApp ( $ bUseCache = true ) : Component { //  If we have already fetched this data then don't get it again if ( $ bUseCache && isset ( static :: $ aCache [ 'APP' ] ) ) { return static :: $ aCache [ 'APP' ] ; } // -------------------------------------------------------------------------- $ sComposer = @ file_get_contents ( NAILS_APP_PATH . 'composer.json' ) ; if ( empty ( $ sComposer ) ) { ErrorHandler :: halt ( 'Failed to get app configuration; could not load composer.json' ) ; } $ oComposer = @ json_decode ( $ sComposer ) ; if ( empty ( $ oComposer ) ) { ErrorHandler :: halt ( 'Failed to get app configuration; could not decode composer.json' ) ; } $ aComposer = ( array ) $ oComposer ; $ aNails = ! empty ( $ oComposer -> extra -> nails ) ? ( array ) $ oComposer -> extra -> nails : [ ] ; $ oOut = new Component ( ( object ) [ 'slug' => 'app' , 'name' => 'app' , 'description' => ArrayHelper :: getFromArray ( 'description' , $ aNails , ArrayHelper :: getFromArray ( 'description' , $ aComposer ) ) , 'homepage' => ArrayHelper :: getFromArray ( 'homepage' , $ aNails , ArrayHelper :: getFromArray ( 'homepage' , $ aComposer ) ) , 'authors' => ArrayHelper :: getFromArray ( 'authors' , $ aNails , ArrayHelper :: getFromArray ( 'authors' , $ aComposer ) ) , 'extra' => ( object ) [ 'nails' => ( object ) [ 'namespace' => '\\App\\' , 'moduleName' => ArrayHelper :: getFromArray ( 'moduleName' , $ aNails , '' ) , 'data' => ArrayHelper :: getFromArray ( 'data' , $ aNails , null ) , 'autoload' => ArrayHelper :: getFromArray ( 'autoload' , $ aNails , null ) , ] , ] , ] , NAILS_APP_PATH , './' , true ) ; // -------------------------------------------------------------------------- if ( $ bUseCache ) { static :: $ aCache [ 'APP' ] = $ oOut ; } return $ oOut ; }
Returns an instance of the app as a component

@param bool $bUseCache Whether to use the cache or not

@return Component
Returns an instance of the app as a component