Files
chill-bundles/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php
2021-11-30 13:54:58 +01:00

132 lines
2.4 KiB
PHP

<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Actions;
use Symfony\Component\EventDispatcher\Event;
/**
* Event triggered when an entity attached to a person is removed.
*/
class ActionEvent extends Event
{
public const DELETE = 'CHILL_PERSON.DELETE_ASSOCIATED_ENTITY';
public const MOVE = 'CHILL_PERSON.MOVE_ASSOCIATED_ENTITY';
/**
* the FQDN class name as recorded in doctrine.
*
* @var string
*/
protected $entity;
/**
* an array of key value data to describe the movement.
*
* @var array
*/
protected $metadata;
/**
* @var int
*/
protected $personId;
/**
* @var string[]
*/
protected $postSql = [];
/**
* @var string[]
*/
protected $preSql = [];
/**
* the sql statement.
*
* @var string
*/
protected $sqlStatement;
public function __construct($personId, $entity, $sqlStatement, $metadata = [])
{
$this->personId = $personId;
$this->entity = $entity;
$this->sqlStatement = $sqlStatement;
$this->metadata = $metadata;
}
/**
* Add Sql which will be executed **after** the delete statement.
*
* @param type $postSql
*
* @return $this
*/
public function addPostSql(string $postSql)
{
$this->postSql[] = $postSql;
return $this;
}
/*
* Add Sql which will be executed **before** the delete statement
*/
public function addPreSql(string $preSql)
{
$this->preSql[] = $preSql;
return $this;
}
/**
* get the entity name, as recorded in doctrine.
*/
public function getEntity(): string
{
return $this->entity;
}
public function getMetadata()
{
return $this->metadata;
}
public function getPersonId(): int
{
return $this->personId;
}
/**
* @return string[]
*/
public function getPostSql(): array
{
return $this->postSql;
}
/**
* @return string[]
*/
public function getPreSql(): array
{
return $this->preSql;
}
public function getSqlStatement()
{
return $this->sqlStatement;
}
}