src/Factory.php
public static function helper(string $sHelperName, ?string $sComponentName = ''): void
    {
        $sComponentName = empty($sComponentName) ? 'nails/common' : $sComponentName;

        if (empty(self::$aLoadedHelpers[$sComponentName][$sHelperName])) {

            if (empty(self::$aLoadedHelpers[$sComponentName])) {
                self::$aLoadedHelpers[$sComponentName] = [];
            }

            /**
             * If we're only interested in the app version of the helper then we change things
             * around a little as the paths and reliance of a "component" based helper aren't the same
             */
            if ($sComponentName == 'app') {

                $sAppPath = NAILS_APP_PATH . 'application/helpers/' . $sHelperName . '.php';

                if (!file_exists($sAppPath)) {
                    throw new FactoryException(
                        'Helper "' . $sComponentName . '/' . $sHelperName . '" does not exist.',
                        1
                    );
                }

                require_once $sAppPath;

            } else {

                $sComponentPath = NAILS_APP_PATH . 'vendor/' . $sComponentName . '/helpers/' . $sHelperName . '.php';
                $sAppPath       = NAILS_APP_PATH . 'application/helpers/' . $sComponentName . '/' . $sHelperName . '.php';

                if (!file_exists($sComponentPath)) {
                    throw new FactoryException(
                        'Helper "' . $sComponentName . '/' . $sHelperName . '" does not exist.',
                        1
                    );
                }

                if (file_exists($sAppPath)) {
                    require_once $sAppPath;
                }

                require_once $sComponentPath;
            }

            self::$aLoadedHelpers[$sComponentName][$sHelperName] = true;
        }
    }
public static function helper(string $sHelperName, ?string $sComponentName = ''): void
    {
        $sComponentName = empty($sComponentName) ? 'nails/common' : $sComponentName;

        if (empty(self::$aLoadedHelpers[$sComponentName][$sHelperName])) {

            if (empty(self::$aLoadedHelpers[$sComponentName])) {
                self::$aLoadedHelpers[$sComponentName] = [];
            }

            /**
             * If we're only interested in the app version of the helper then we change things
             * around a little as the paths and reliance of a "component" based helper aren't the same
             */
            if ($sComponentName == 'app') {

                $sAppPath = NAILS_APP_PATH . 'application/helpers/' . $sHelperName . '.php';

                if (!file_exists($sAppPath)) {
                    throw new FactoryException(
                        'Helper "' . $sComponentName . '/' . $sHelperName . '" does not exist.',
                        1
                    );
                }

                require_once $sAppPath;

            } else {

                $sComponentPath = NAILS_APP_PATH . 'vendor/' . $sComponentName . '/helpers/' . $sHelperName . '.php';
                $sAppPath       = NAILS_APP_PATH . 'application/helpers/' . $sComponentName . '/' . $sHelperName . '.php';

                if (!file_exists($sComponentPath)) {
                    throw new FactoryException(
                        'Helper "' . $sComponentName . '/' . $sHelperName . '" does not exist.',
                        1
                    );
                }

                if (file_exists($sAppPath)) {
                    require_once $sAppPath;
                }

                require_once $sComponentPath;
            }

            self::$aLoadedHelpers[$sComponentName][$sHelperName] = true;
        }
    }
public static function helper ( string $ sHelperName , ? string $ sComponentName = '' ) : void { $ sComponentName = empty ( $ sComponentName ) ? 'nails/common' : $ sComponentName ; if ( empty ( self :: $ aLoadedHelpers [ $ sComponentName ] [ $ sHelperName ] ) ) { if ( empty ( self :: $ aLoadedHelpers [ $ sComponentName ] ) ) { self :: $ aLoadedHelpers [ $ sComponentName ] = [ ] ; } /**
             * If we're only interested in the app version of the helper then we change things
             * around a little as the paths and reliance of a "component" based helper aren't the same
             */ if ( $ sComponentName == 'app' ) { $ sAppPath = NAILS_APP_PATH . 'application/helpers/' . $ sHelperName . '.php' ; if ( ! file_exists ( $ sAppPath ) ) { throw new FactoryException ( 'Helper "' . $ sComponentName . '/' . $ sHelperName . '" does not exist.' , 1 ) ; } require_once $ sAppPath ; } else { $ sComponentPath = NAILS_APP_PATH . 'vendor/' . $ sComponentName . '/helpers/' . $ sHelperName . '.php' ; $ sAppPath = NAILS_APP_PATH . 'application/helpers/' . $ sComponentName . '/' . $ sHelperName . '.php' ; if ( ! file_exists ( $ sComponentPath ) ) { throw new FactoryException ( 'Helper "' . $ sComponentName . '/' . $ sHelperName . '" does not exist.' , 1 ) ; } if ( file_exists ( $ sAppPath ) ) { require_once $ sAppPath ; } require_once $ sComponentPath ; } self :: $ aLoadedHelpers [ $ sComponentName ] [ $ sHelperName ] = true ; } }
Load a helper file

@param string $sHelperName    The helper name
@param string $sComponentName The name of the component which provides the factory

@throws FactoryException
@return void
Load a helper file