public function readJsonFile($localsIncluded = [])
    {
        $hooks = [];

        if (!$this->filesystem->exists(base_path('hooks'))) {
            $this->filesystem->makeDirectory(base_path('hooks'));
        }

        if (!$this->filesystem->exists(base_path('hooks/hooks.json'))) {
            $this->filesystem->put(base_path('hooks/hooks.json'), '{}');
        }

        $data = json_decode($this->filesystem->get(base_path('hooks/hooks.json')), true);
        $enabled = [];

        if (isset($data['hooks'])) {
            foreach ($data['hooks'] as $key => $hook) {
                if (!$this->filesystem->exists(base_path("hooks/{$key}/composer.json")) &&
                    !$this->filesystem->exists(base_path("vendor/{$key}/composer.json"))) {
                    continue; // This hook does not seem to exist anymore
                }

                $hooks[$key] = new Hook($hook);
                if ($hooks[$key]->enabled) {
                    $enabled[] = $key;
                }
            }
        }

        if (isset($data['last_remote_check'])) {
            $this->lastRemoteCheck = Carbon::createFromTimestamp($data['last_remote_check']);
        }

        foreach ($this->readComposerHooks() as $name => $composerHook) {
            $hooks[$name] = $composerHook;

            if (in_array($name, $enabled)) {
                $hooks[$name]->enabled = true;
            }
        }

        foreach ($this->readLocalHooks() as $name => $composerHook) {
            if (!isset($hooks[$name]) && !in_array($name, $localsIncluded)) {
                continue; // Do not show not-installed local hooks.
            }

            $hooks[$name] = $composerHook;

            if (in_array($name, $enabled)) {
                $hooks[$name]->enabled = true;
            }
        }

        $this->hooks = collect($hooks);
    }
public function readJsonFile($localsIncluded = [])
    {
        $hooks = [];

        if (!$this->filesystem->exists(base_path('hooks'))) {
            $this->filesystem->makeDirectory(base_path('hooks'));
        }

        if (!$this->filesystem->exists(base_path('hooks/hooks.json'))) {
            $this->filesystem->put(base_path('hooks/hooks.json'), '{}');
        }

        $data = json_decode($this->filesystem->get(base_path('hooks/hooks.json')), true);
        $enabled = [];

        if (isset($data['hooks'])) {
            foreach ($data['hooks'] as $key => $hook) {
                if (!$this->filesystem->exists(base_path("hooks/{$key}/composer.json")) &&
                    !$this->filesystem->exists(base_path("vendor/{$key}/composer.json"))) {
                    continue; // This hook does not seem to exist anymore
                }

                $hooks[$key] = new Hook($hook);
                if ($hooks[$key]->enabled) {
                    $enabled[] = $key;
                }
            }
        }

        if (isset($data['last_remote_check'])) {
            $this->lastRemoteCheck = Carbon::createFromTimestamp($data['last_remote_check']);
        }

        foreach ($this->readComposerHooks() as $name => $composerHook) {
            $hooks[$name] = $composerHook;

            if (in_array($name, $enabled)) {
                $hooks[$name]->enabled = true;
            }
        }

        foreach ($this->readLocalHooks() as $name => $composerHook) {
            if (!isset($hooks[$name]) && !in_array($name, $localsIncluded)) {
                continue; // Do not show not-installed local hooks.
            }

            $hooks[$name] = $composerHook;

            if (in_array($name, $enabled)) {
                $hooks[$name]->enabled = true;
            }
        }

        $this->hooks = collect($hooks);
    }
public function readJsonFile ( $ localsIncluded = [ ] ) { $ hooks = [ ] ; if ( ! $ this -> filesystem -> exists ( base_path ( 'hooks' ) ) ) { $ this -> filesystem -> makeDirectory ( base_path ( 'hooks' ) ) ; } if ( ! $ this -> filesystem -> exists ( base_path ( 'hooks/hooks.json' ) ) ) { $ this -> filesystem -> put ( base_path ( 'hooks/hooks.json' ) , '{}' ) ; } $ data = json_decode ( $ this -> filesystem -> get ( base_path ( 'hooks/hooks.json' ) ) , true ) ; $ enabled = [ ] ; if ( isset ( $ data [ 'hooks' ] ) ) { foreach ( $ data [ 'hooks' ] as $ key => $ hook ) { if ( ! $ this -> filesystem -> exists ( base_path ( "hooks/{$key}/composer.json" ) ) && ! $ this -> filesystem -> exists ( base_path ( "vendor/{$key}/composer.json" ) ) ) { continue ; // This hook does not seem to exist anymore } $ hooks [ $ key ] = new Hook ( $ hook ) ; if ( $ hooks [ $ key ] -> enabled ) { $ enabled [ ] = $ key ; } } } if ( isset ( $ data [ 'last_remote_check' ] ) ) { $ this -> lastRemoteCheck = Carbon :: createFromTimestamp ( $ data [ 'last_remote_check' ] ) ; } foreach ( $ this -> readComposerHooks ( ) as $ name => $ composerHook ) { $ hooks [ $ name ] = $ composerHook ; if ( in_array ( $ name , $ enabled ) ) { $ hooks [ $ name ] -> enabled = true ; } } foreach ( $ this -> readLocalHooks ( ) as $ name => $ composerHook ) { if ( ! isset ( $ hooks [ $ name ] ) && ! in_array ( $ name , $ localsIncluded ) ) { continue ; // Do not show not-installed local hooks. } $ hooks [ $ name ] = $ composerHook ; if ( in_array ( $ name , $ enabled ) ) { $ hooks [ $ name ] -> enabled = true ; } } $ this -> hooks = collect ( $ hooks ) ; }
Read hooks.json file.
Read hooks . json file .