<?php

namespace Brexis\LaravelWorkflow;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;

class WorkflowServiceProvider extends ServiceProvider
{
    protected $commands = [
        'Brexis\LaravelWorkflow\Commands\WorkflowDumpCommand',
    ];

    /**
    * Bootstrap the application services...
    *
    * @return void
    */
    public function boot()
    {
        $configPath = __DIR__ . '/../config/config.php';

        $this->publishes([$configPath => config_path('workflow.php')], 'config');

        $this->registerBladeExtensions();
    }

    /**
    * Register the application services.
    *
    * @return void
    */
    public function register()
    {
        $this->commands($this->commands);

        $this->app->singleton(
            'workflow', function ($app) {
                return new WorkflowRegistry($app['config']['workflow']);
            }
        );
    }

    /**
     * Register blades extensions
     */
    private function registerBladeExtensions()
    {
        Blade::directive('workflow_can', function ($object, $transitionName, $workflowName = null) {
            $workflow = Workflow::get($object, $workflowName);

            return $workflow->can($object, $transitionName);
        });

        Blade::directive('workflow_transitions', function ($object) {
            $workflow = Workflow::get($object);

            return $workflow->getEnabledTransitions($object);
        });
    }

    /**
    * Get the services provided by the provider.
    *
    * @return array
    */
    public function provides()
    {
        return ['workflow'];
    }
}

<?php

namespace Brexis\LaravelWorkflow;

use Illuminate\Support\ServiceProvider;

class WorkflowServiceProvider extends ServiceProvider
{
    protected $commands = [
        'Brexis\LaravelWorkflow\Commands\WorkflowDumpCommand',
    ];

    /**
    * Bootstrap the application services...
    *
    * @return void
    */
    public function boot()
    {
        $configPath = __DIR__ . '/../config/config.php';

        $this->publishes([$configPath => config_path('workflow.php')], 'config');
    }

    /**
    * Register the application services.
    *
    * @return void
    */
    public function register()
    {
        $this->commands($this->commands);

        $this->app->singleton(
            'workflow', function ($app) {
                return new WorkflowRegistry($app['config']['workflow']);
            }
        );
    }

    /**
    * Get the services provided by the provider.
    *
    * @return array
    */
    public function provides()
    {
        return ['workflow'];
    }
}

Revert "Add workflow_can and workflow_transitions blade extensions"
Revert "Add workflow_can and workflow_transitions blade extensions"

This reverts commit 300795a3b1fe2494d1da954531b4f37d1aa88ec9.
