public function boot()
 {
     if (!Type::hasType('branch_logo')) {
         Type::addType('branch_logo', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\BranchLogoType');
     }
     if (!Type::hasType('priority')) {
         Type::addType('priority', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketPriorityType');
     }
     if (!Type::hasType('file')) {
         Type::addType('file', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\AttachmentFileType');
     }
     if (!Type::hasType('status')) {
         Type::addType('status', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketStatusType');
     }
     if (!Type::hasType('source')) {
         Type::addType('source', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSourceType');
     }
     if (!Type::hasType('ticket_sequence_number')) {
         Type::addType('ticket_sequence_number', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSequenceNumberType');
     }
     if (!Type::hasType('ticket_unique_id')) {
         Type::addType('ticket_unique_id', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketUniqueIdType');
     }
     foreach ($this->dataAuditTypes as $type) {
         if (!AuditFieldTypeRegistry::hasType($type)) {
             AuditFieldTypeRegistry::addType($type, $type);
         }
     }
     $em = $this->container->get('doctrine.orm.default_entity_manager');
     $conn = $em->getConnection();
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('FILE', 'string');
 }
Exemplo n.º 2
0
 /**
  * @param AbstractAudit $audit
  * @param string $field
  * @param string $dataType
  * @param mixed $newValue
  * @param mixed $oldValue
  */
 public function __construct(AbstractAudit $audit, $field, $dataType, $newValue, $oldValue)
 {
     $this->audit = $audit;
     $this->field = $field;
     $this->dataType = AuditFieldTypeRegistry::getAuditType($dataType);
     $this->setOldValue($oldValue);
     $this->setNewValue($newValue);
 }
 public function testAuditFieldTypeRegistry()
 {
     $this->assertFalse(AuditFieldTypeRegistry::hasType('newtype'));
     AuditFieldTypeRegistry::addType('newtype', 'newtype_');
     $this->assertTrue(AuditFieldTypeRegistry::hasType('newtype'));
     $this->assertEquals('newtype_', AuditFieldTypeRegistry::getAuditType('newtype'));
     AuditFieldTypeRegistry::overrideType('newtype', 'overridentype');
     $this->assertEquals('overridentype', AuditFieldTypeRegistry::getAuditType('newtype'));
     AuditFieldTypeRegistry::removeType('newtype');
     $this->assertFalse(AuditFieldTypeRegistry::hasType('newtype'));
 }
 public function teardown()
 {
     AuditFieldTypeRegistry::removeType('testingtype');
 }
Exemplo n.º 5
0
 /**
  * @param OrmFilterDatasourceAdapter $ds
  * @param string $objectClass
  * @param string $fieldName
  * @param array $data
  */
 protected function applyNewAuditValueFilter(OrmFilterDatasourceAdapter $ds, $objectClass, $fieldName, array $data)
 {
     if ($data['auditFilter']['type'] !== static::TYPE_CHANGED_TO_VALUE) {
         return;
     }
     $metadata = $ds->getQueryBuilder()->getEntityManager()->getClassMetadata($objectClass);
     $type = $metadata->getTypeOfField($fieldName);
     if (!$type) {
         $type = 'text';
     }
     $newValueField = sprintf('new%s', ucfirst(AuditFieldTypeRegistry::getAuditType($type)));
     $this->applyFilter($ds, $data['filter']['filter'], sprintf('%s.%s', $this->auditFieldAlias, $newValueField), $data['filter']['data']);
 }
Exemplo n.º 6
0
 /**
  * @param array $row
  * @param array $data
  */
 private function processArrayData(array $row, array $data)
 {
     foreach ($data as $field => $values) {
         $visible = true;
         $fieldType = $this->getFieldType($row['entity_id'], $field);
         $dataType = null;
         if (!AuditFieldTypeRegistry::hasType($fieldType) || !array_key_exists('old', $values) || !array_key_exists('new', $values)) {
             $dataType = 'array';
             $visible = false;
         } else {
             $dataType = AuditFieldTypeRegistry::getAuditType($fieldType);
         }
         $dbData = ['audit_id' => $row['id'], 'data_type' => $dataType, 'field' => $field, sprintf('old_%s', $dataType) => $this->parseValue($values, 'old'), sprintf('new_%s', $dataType) => $this->parseValue($values, 'new'), 'visible' => $visible];
         $types = ['integer', 'string', 'string', $dataType, $dataType, 'boolean'];
         $this->connection->insert('oro_audit_field', $dbData, $types);
     }
 }