public static function bind_manipulation_capture()
    {
        $current = DB::get_conn();
        if (!$current || !$current->getConnector()->getSelectedDatabase() || @$current->isManipulationLoggingCapture) {
            return;
        } // If not yet set, or its already captured, just return

        $type = get_class($current);
        $sanitisedType = str_replace('\\', '_', $type);
        $file = TEMP_FOLDER . "/.cache.CLC.$sanitisedType";
        $dbClass = 'AuditLoggerManipulateCapture_' . $sanitisedType;

        if (!is_file($file)) {
            file_put_contents($file, "<?php
				class $dbClass extends $type
                {
					public \$isManipulationLoggingCapture = true;

					public function manipulate(\$manipulation)
                    {
						\SilverStripe\Auditor\AuditHook::handle_manipulation(\$manipulation);
						return parent::manipulate(\$manipulation);
					}
				}
			");
        }

        require_once $file;

        /** @var Database $captured */
        $captured = new $dbClass();

        $captured->setConnector($current->getConnector());
        $captured->setQueryBuilder($current->getQueryBuilder());
        $captured->setSchemaManager($current->getSchemaManager());

        // The connection might have had it's name changed (like if we're currently in a test)
        $captured->selectDatabase($current->getConnector()->getSelectedDatabase());

        DB::set_conn($captured);
    }
public static function bind_manipulation_capture()
    {
        $current = DB::get_conn();
        if (!$current || !$current->getConnector()->getSelectedDatabase() || @$current->isManipulationLoggingCapture) {
            return;
        } // If not yet set, or its already captured, just return

        $type = get_class($current);
        $sanitisedType = str_replace('\\', '_', $type);
        $file = TEMP_FOLDER . "/.cache.CLC.$sanitisedType";
        $dbClass = 'AuditLoggerManipulateCapture_' . $sanitisedType;

        if (!is_file($file)) {
            file_put_contents($file, "<?php
				class $dbClass extends $type
                {
					public \$isManipulationLoggingCapture = true;

					public function manipulate(\$manipulation)
                    {
						\SilverStripe\Auditor\AuditHook::handle_manipulation(\$manipulation);
						return parent::manipulate(\$manipulation);
					}
				}
			");
        }

        require_once $file;

        /** @var Database $captured */
        $captured = new $dbClass();

        $captured->setConnector($current->getConnector());
        $captured->setQueryBuilder($current->getQueryBuilder());
        $captured->setSchemaManager($current->getSchemaManager());

        // The connection might have had it's name changed (like if we're currently in a test)
        $captured->selectDatabase($current->getConnector()->getSelectedDatabase());

        DB::set_conn($captured);
    }
public static function bind_manipulation_capture ( ) { $ current = DB :: get_conn ( ) ; if ( ! $ current || ! $ current -> getConnector ( ) -> getSelectedDatabase ( ) || @ $ current -> isManipulationLoggingCapture ) { return ; } // If not yet set, or its already captured, just return $ type = get_class ( $ current ) ; $ sanitisedType = str_replace ( '\\' , '_' , $ type ) ; $ file = TEMP_FOLDER . "/.cache.CLC.$sanitisedType" ; $ dbClass = 'AuditLoggerManipulateCapture_' . $ sanitisedType ; if ( ! is_file ( $ file ) ) { file_put_contents ( $ file , "<?php
				class $dbClass extends $type
                {
					public \$isManipulationLoggingCapture = true;

					public function manipulate(\$manipulation)
                    {
						\SilverStripe\Auditor\AuditHook::handle_manipulation(\$manipulation);
						return parent::manipulate(\$manipulation);
					}
				}
			" ) ; } require_once $ file ; /** @var Database $captured */ $ captured = new $ dbClass ( ) ; $ captured -> setConnector ( $ current -> getConnector ( ) ) ; $ captured -> setQueryBuilder ( $ current -> getQueryBuilder ( ) ) ; $ captured -> setSchemaManager ( $ current -> getSchemaManager ( ) ) ; // The connection might have had it's name changed (like if we're currently in a test) $ captured -> selectDatabase ( $ current -> getConnector ( ) -> getSelectedDatabase ( ) ) ; DB :: set_conn ( $ captured ) ; }
This will bind a new class dynamically so we can hook into manipulation
and capture it. It creates a new PHP file in the temp folder, then
loads it and sets it as the active DB class.

@deprecated 2.1...3.0 Please use ProxyDBExtension with the tractorcow/silverstripe-proxy-db module instead
This will bind a new class dynamically so we can hook into manipulation and capture it . It creates a new PHP file in the temp folder then loads it and sets it as the active DB class .