PHP code example of neunerlei / lockpick-bundle

1. Go to this page and download the library: Download neunerlei/lockpick-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

neunerlei / lockpick-bundle example snippets



namespace App;

use App\Override\NotSoFinalUrlHelper;
use Neunerlei\LockpickBundle\ClassOverridesKernelTrait;
use Neunerlei\LockpickBundle\Overrides\OverrideGeneratorConfig;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpFoundation\UrlHelper;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;
    
    // Add this trait to your kernel
    use ClassOverridesKernelTrait;

    /**
     * @inheritDoc
     */
    public function boot(): void
    {
        // The configureOverrideGenerator accepts a closure as parameter, which will receive an instance of 
        // {@see OverrideGeneratorConfig} you can use to configure all facets of the override generator...
        $this->configureOverrideGenerator(static function (OverrideGeneratorConfig $config): void {
        
            // You can add your overrides through the speaking configuration interface,
            // take a look at the code documentation if you feel lost.
            $config->registerOverride(UrlHelper::class, NotSoFinalUrlHelper::class);
            
            // You can also chain multiple overrides
            $config
              ->registerOverride(AcmeBundle\ClassToOverride::class, YourBundle\ClassToOverrideWith::class)
              ->registerOverride(AnotherAcmeBundle\AnotherClassToOverride::class, YourBundle\AnotherClassToOverrideWith::class);
              
            // Those options are optional and will be automatically set if omitted:
            
            // The absolute path to your composer autoload.php. If omitted the script tries to find the autoloader itself
            $config->setComposerAutoloadPath('/...');
            
            // The path where the generated class copies should be stored
            $config->setStoragePath('/...')
        });

        // IMPORTANT! Configure the override generator BEFORE calling parent::boot()!
        parent::boot();
    }
}



return [
    Neunerlei\LockpickBundle\LockpickBundle::class => ['all' => true], // <- The bundle should be loaded here...
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
];