2017 © Pedro Peláez
 

symfony-bundle user-aware-command-bundle

Provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands.

image

bentools/user-aware-command-bundle

Provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands.

  • Tuesday, August 23, 2016
  • by bpolaszek
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4,692 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 20 % Grown

The README.md

UserAwareCommandBundle

This Symfony bundle provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands., (*1)

Installation

composer require bentools/user-aware-command-bundle, (*2)

Then, enable the bundle into Symfony's AppKernel.php:, (*3)

# app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles() 
    {
        // ...
        $bundles[] = new BenTools\UserAwareCommandBundle\UserAwareCommandBundle();
    }
}

Usage

The bundle just works out of the box, provided you already have the Blameable extension configured and working on your entities. Your console command just has to implement BenTools\UserAwareCommandBundle\Model\UserAwareInterface, which contains no method:, (*4)

namespace AppBundle\Command;

use BenTools\UserAwareCommandBundle\Model\UserAwareInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DoMyCommand extends Command implements UserAwareInterface 
{
    protected function execute(InputInterface $input, OutputInterface $output) {
        // ...
    }
}

By default, the bundle will bind the System user to your createdBy / updatedBy properties., (*5)

You can change this user per command run with the --user option:, (*6)

php bin/console do:mycommand --user Ben, (*7)

Advanced configuration

# app/config.yml

user_aware_command:
    user_name: System # change default user
    option_name: user # change default command option
    option_shortcut: u # set option shortcut

The Versions

23/08 2016

dev-master

9999999-dev

Provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands.

  Sources   Download

MIT

The Requires

 

23/08 2016

v1.0.1

1.0.1.0

Provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands.

  Sources   Download

MIT

The Requires

 

02/08 2016

v1.0

1.0.0.0

Provides a user value to Doctrine Entities that implements Gedmo Blameable when using Console commands.

  Sources   Download

MIT

The Requires