Skip to content

Instantly share code, notes, and snippets.

View Jibbarth's full-sized avatar
🌴

Jibé Barth Jibbarth

🌴
View GitHub Profile
@Jibbarth
Jibbarth / ResolveTargetEntityListenerDecorator.php
Created August 27, 2023 15:06
[DOCTRINE] Automatically remove mappedSuperClass when resolveTargetEntity target the root model
View ResolveTargetEntityListenerDecorator.php
<?php
declare(strict_types=1);
namespace App\Doctrine;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Tools\ResolveTargetEntityListener;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
@Jibbarth
Jibbarth / NoValidateFixerConfigurationResolver.php
Created February 12, 2023 11:37
[PHP-CS-Fixer] Configure any rule with except paths
View NoValidateFixerConfigurationResolver.php
<?php
declare(strict_types=1);
namespace App\Fixer;
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
final class NoValidateFixerConfigurationResolver implements FixerConfigurationResolverInterface
{
@Jibbarth
Jibbarth / sylius_restrict_payment_methods.md
Last active May 10, 2021 16:38
[Sylius] Restrict Payment Methods depending on customer group
View sylius_restrict_payment_methods.md

It could be common to display some payment methods only to customers that belong to a group.

For example, you can add an offline payment method for you B2B customers, and invoice them at the end of the month, and this offline payment should absolutely not be available for other customer! Let's see how to integrate this in a Sylius Application.

1. The Quick and Dirty way

The form displaying payment methods in Sylius retrieve them from the service sylius.payment_methods_resolver.

Let's decorate it !

@Jibbarth
Jibbarth / 00_sylius_admin_links_phpunit.md
Last active December 10, 2020 20:00
[Sylius] Test all admin menu links 🦢
View 00_sylius_admin_links_phpunit.md
@Jibbarth
Jibbarth / README.md
Last active May 2, 2020 14:46
🇫🇷 Gnome / Chrome / Dark mode
View README.md

Sur GNOME, j'ai ajouté l'extension DayNight qui permet de passer d'un theme sombre a light d'un clic.

Contrairement a Firefox, chrome ne prend pas en compte le theme mode de l'utilisateur à la volée.

Chrome n'interprete pas le color-prefers-scheme correctement, même si le theme est configuré sur Dark.

Pour lancer chrome en mode dark,

  google-chrome-stable --force-dark-mode
@Jibbarth
Jibbarth / 1.PHP_OAuth_CLI.md
Last active September 23, 2021 14:57
⚡Recreate Github CLI OAuth feature in a Symfony command ⚡
View 1.PHP_OAuth_CLI.md

⚡Recreate Github CLI OAuth feature in a Symfony command ⚡

Github recently released a CLI tool to manage issues and PR directly from your terminal. As I work on some open source projects, I downloaded it to give a try.

And at first launch, the CLI ask to connect by using OAuth. It propose to press "Enter" to open github.com in my browser, and catch correctly the access_token.

That .. blown my mind 🤯 I didn't expect we can connect through terminal like this. So, as it's open source, I dived into the code source.

@Jibbarth
Jibbarth / Managing personal and work git email.md
Last active May 3, 2020 15:12
Automatically managing personal and work git email
View Managing personal and work git email.md

In order to differentiate your professional and personal email address when working on git repositories, here is how I proceeded.

1. Create a global git hooks folder

Create a folder where you will drop the hooks that should apply to each repository. And set the core.hooksPath on this folder

git config --global core.hooksPath /path/to/my/centralized/hooks
@Jibbarth
Jibbarth / 00-Add_Composer.md
Last active January 31, 2023 11:29
Composering a PrestaShop
View 00-Add_Composer.md

Note : This is a guide for PS 1.6.x because 1.7 provide a composer.json

How to use composer in PrestaShop

The PHP World is full of talentued developers. They create very usefull and powerfull libraries. In PrestaShop, developers often have to reimplement them. Unless use composer !

Init a composer

First, you have to install composer to your system. I don't teach you how to do this, read the doc.

@Jibbarth
Jibbarth / convertPdf.php
Created June 1, 2017 13:24
Convert pdf / PHP / Imagick
View convertPdf.php
$sPathName = realpath($oFile->getPathname());
$oIm = new Imagick($sPathName);
$iNoOfPagesInPDF = $oIm->getNumberImages();
if ($iNoOfPagesInPDF) {
$aPdfPagePath = [];
for ($i = 0; $i < $iNoOfPagesInPDF; $i++) {
$sUrl = $sPathName . '[' . $i . ']';
$sPath = '/tmp/' . $oFile->getFilename() . '_' . ($i + 1) . '.pdf';
@Jibbarth
Jibbarth / ieVersion.js
Last active April 4, 2017 10:14
Get Internet Explorer version and get is Edge Navigator in javascript
View ieVersion.js
/**
* Gets the internet explorer version.
*
* @return {int} The internet explorer version.
*/
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;