Skip to content

Commit

Permalink
private methods now are protected
Browse files Browse the repository at this point in the history
so users can extend it in any ways they want.
that will hopefully prevent from many crazy pull and feature requests.
  • Loading branch information
l3pp4rd authored Sep 13, 2018
1 parent c411020 commit 71e709d
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/DataDog/AuditBundle/EventSubscriber/AuditSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ class AuditSubscriber implements EventSubscriber
/**
* @var SQLLogger
*/
private $old;
protected $old;

/**
* @var TokenStorage
*/
protected $securityTokenStorage;

private $auditedEntities = [];
private $unauditedEntities = [];
protected $auditedEntities = [];
protected $unauditedEntities = [];

private $inserted = []; // [$source, $changeset]
private $updated = []; // [$source, $changeset]
private $removed = []; // [$source, $id]
private $associated = []; // [$source, $target, $mapping]
private $dissociated = []; // [$source, $target, $id, $mapping]
protected $inserted = []; // [$source, $changeset]
protected $updated = []; // [$source, $changeset]
protected $removed = []; // [$source, $id]
protected $associated = []; // [$source, $target, $mapping]
protected $dissociated = []; // [$source, $target, $id, $mapping]

private $assocInsertStmt;
private $auditInsertStmt;
protected $assocInsertStmt;
protected $auditInsertStmt;

/** @var UserInterface */
private $blameUser;
protected $blameUser;

public function __construct(TokenStorage $securityTokenStorage)
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public function getUnauditedEntities()
return array_keys($this->unauditedEntities);
}

private function isEntityUnaudited($entity)
protected function isEntityUnaudited($entity)
{
if (!empty($this->auditedEntities)) {
// only selected entities are audited
Expand Down Expand Up @@ -180,7 +180,7 @@ public function onFlush(OnFlushEventArgs $args)
}
}

private function flush(EntityManager $em)
protected function flush(EntityManager $em)
{
$em->getConnection()->getConfiguration()->setSQLLogger($this->old);
$uow = $em->getUnitOfWork();
Expand Down Expand Up @@ -230,7 +230,7 @@ private function flush(EntityManager $em)
$this->dissociated = [];
}

private function associate(EntityManager $em, $source, $target, array $mapping)
protected function associate(EntityManager $em, $source, $target, array $mapping)
{
$this->audit($em, [
'source' => $this->assoc($em, $source),
Expand All @@ -242,7 +242,7 @@ private function associate(EntityManager $em, $source, $target, array $mapping)
]);
}

private function dissociate(EntityManager $em, $source, $target, $id, array $mapping)
protected function dissociate(EntityManager $em, $source, $target, $id, array $mapping)
{
$this->audit($em, [
'source' => $this->assoc($em, $source),
Expand All @@ -254,7 +254,7 @@ private function dissociate(EntityManager $em, $source, $target, $id, array $map
]);
}

private function insert(EntityManager $em, $entity, array $ch)
protected function insert(EntityManager $em, $entity, array $ch)
{
$meta = $em->getClassMetadata(get_class($entity));
$this->audit($em, [
Expand All @@ -267,7 +267,7 @@ private function insert(EntityManager $em, $entity, array $ch)
]);
}

private function update(EntityManager $em, $entity, array $ch)
protected function update(EntityManager $em, $entity, array $ch)
{
$diff = $this->diff($em, $entity, $ch);
if (!$diff) {
Expand All @@ -284,7 +284,7 @@ private function update(EntityManager $em, $entity, array $ch)
]);
}

private function remove(EntityManager $em, $entity, $id)
protected function remove(EntityManager $em, $entity, $id)
{
$meta = $em->getClassMetadata(get_class($entity));
$source = array_merge($this->assoc($em, $entity), ['fk' => $id]);
Expand All @@ -298,7 +298,7 @@ private function remove(EntityManager $em, $entity, $id)
]);
}

private function audit(EntityManager $em, array $data)
protected function audit(EntityManager $em, array $data)
{
$c = $em->getConnection();
$p = $c->getDatabasePlatform();
Expand Down Expand Up @@ -345,7 +345,7 @@ private function audit(EntityManager $em, array $data)
$this->auditInsertStmt->execute();
}

private function id(EntityManager $em, $entity)
protected function id(EntityManager $em, $entity)
{
$meta = $em->getClassMetadata(get_class($entity));
$pk = $meta->getSingleIdentifierFieldName();
Expand All @@ -357,7 +357,7 @@ private function id(EntityManager $em, $entity)
return $pk;
}

private function diff(EntityManager $em, $entity, array $ch)
protected function diff(EntityManager $em, $entity, array $ch)
{
$uow = $em->getUnitOfWork();
$meta = $em->getClassMetadata(get_class($entity));
Expand All @@ -384,7 +384,7 @@ private function diff(EntityManager $em, $entity, array $ch)
return $diff;
}

private function assoc(EntityManager $em, $association = null)
protected function assoc(EntityManager $em, $association = null)
{
if (null === $association) {
return null;
Expand All @@ -406,7 +406,7 @@ private function assoc(EntityManager $em, $association = null)
return $res;
}

private function typ($className)
protected function typ($className)
{
// strip prefixes and repeating garbage from name
$className = preg_replace("/^(.+\\\)?(.+)(Bundle\\\Entity)/", "$2", $className);
Expand All @@ -416,7 +416,7 @@ private function typ($className)
}, explode('\\', $className)));
}

private function label(EntityManager $em, $entity)
protected function label(EntityManager $em, $entity)
{
if (is_callable($this->labeler)) {
return call_user_func($this->labeler, $entity);
Expand All @@ -436,7 +436,7 @@ private function label(EntityManager $em, $entity)
}
}

private function value(EntityManager $em, Type $type, $value)
protected function value(EntityManager $em, Type $type, $value)
{
$platform = $em->getConnection()->getDatabasePlatform();
switch ($type->getName()) {
Expand Down

0 comments on commit 71e709d

Please sign in to comment.