Forked from phpfour/OracleDoctrineTypeMappingListener.php
Last active
July 23, 2020 18:55
-
-
Save Liscare/820f622fa8ca1d866e8dfcec038551f0 to your computer and use it in GitHub Desktop.
Symfony4 - Doctrine2 - Oracle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// src/EventListener/OracleDoctrineTypeMappingListener.php | |
namespace App\EventListener; | |
use Doctrine\DBAL\DBALException; | |
use Doctrine\DBAL\Event\ConnectionEventArgs; | |
use Doctrine\DBAL\Events; | |
use Doctrine\Common\EventSubscriber; | |
/** | |
* Changes Doctrine's default Oracle-specific column type mapping to Doctrine | |
* mapping types. This listener modifies doctrine type mapping for | |
* OraclePlatform. | |
*/ | |
class OracleDoctrineTypeMappingListener implements EventSubscriber | |
{ | |
public function getSubscribedEvents() | |
{ | |
return array(Events::postConnect); | |
} | |
/** | |
* Doctrine defines its primary database abstraction information in what it | |
* calls "Platform" classes (e.g. Doctrine\DBAL\Platforms\AbstractPlatform). | |
* Each database Doctrine supports implements a Platform file | |
* (e.g. OraclePlatform or MySqlPlatform). | |
*/ | |
public function postConnect(ConnectionEventArgs $args) | |
{ | |
if ($args->getConnection()->getDatabasePlatform()->getName() == 'oracle') { | |
$args | |
->getConnection() | |
->getDatabasePlatform() | |
->registerDoctrineTypeMapping('date', 'date'); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// src/EventListener/OracleSessionInitListener.php | |
namespace App\EventListener; | |
use Doctrine\DBAL\DBALException; | |
use Doctrine\DBAL\Event\ConnectionEventArgs; | |
use Doctrine\DBAL\Event\Listeners\OracleSessionInit; | |
/** | |
* Should be used when Oracle Server default environment does not match the Doctrine requirements. | |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL | |
* @link www.doctrine-project.com | |
* @since 2.0 | |
* @author Benjamin Eberlei <kontakt@beberlei.de> | |
*/ | |
class OracleSessionInitListener extends OracleSessionInit | |
{ | |
public function postConnect(ConnectionEventArgs $args) | |
{ | |
if ($args->getConnection()->getDatabasePlatform()->getName() == 'oracle') { | |
parent::postConnect($args); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/services.yaml | |
services: | |
app.doctrine.dbal.events.oracle_session_init.listener: | |
class: App\EventListener\OracleSessionInitListener | |
tags: | |
- { name: doctrine.event_listener, event: postConnect } | |
app.doctrine.dbal.oracle_platform.type_mapping.listener: | |
class: App\EventListener\OracleDoctrineTypeMappingListener | |
tags: | |
- { name: doctrine.event_listener, event: postConnect } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- public/web.config--> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<defaultDocument> | |
<files> | |
<clear /> | |
<add value="index.php" /> | |
</files> | |
</defaultDocument> | |
<rewrite> | |
<rules> | |
<rule name="Silex Front Controller" stopProcessing="true"> | |
<match url="^(.*)$" ignoreCase="false" /> | |
<conditions logicalGrouping="MatchAll"> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> | |
</conditions> | |
<action type="Rewrite" url="index.php" appendQueryString="true" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from phpfour's code to Symfony 4