Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-static method Statamic\StaticSite\Generator::after() should not be called statically #21

Closed
tao opened this issue May 17, 2020 · 1 comment · Fixed by #49
Closed

Comments

@tao
Copy link
Contributor

tao commented May 17, 2020

I tried adding the post generator function to my AppServiceProvider as the documentation suggests but I ran into an issue:

ErrorException  : Non-static method Statamic\StaticSite\Generator::after() should not be called statically

  at /.../app/Providers/AppServiceProvider.php:21
    17|     {
    18|         // Statamic::script('app', 'cp');
    19|         // Statamic::style('app', 'cp');
    20| 
  > 21|         Generator::after(function () {
    22|             // eg. copy directory to some server
    23|         });
    24|     }

  Exception trace:

  1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Non-static method Statamic\StaticSite\Generator::after() should not be called statically", "/.../app/Providers/AppServiceProvider.php", [])
      /.../app/Providers/AppServiceProvider.php:21

  2   App\Providers\AppServiceProvider::boot()
      /.../vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
@tao
Copy link
Contributor Author

tao commented May 17, 2020

It seems to work fine if you use it as a real-time facade though:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Statamic\Statamic;
use Statamic\StaticSite\Generator;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(Generator $ssg)
    {
        // Statamic::script('app', 'cp');
        // Statamic::style('app', 'cp');

        $ssg->after(function() {
            // eg. copy directory to some server
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant