Skip to content
Extraits de code Groupes Projets
Security.php 1,21 ko
Newer Older
namespace SpipLeague\Composer;

use Composer\Script\Event;
use Composer\Package\Link;

/**
 * Script for post-install-cmd and post-update-cmd.
 */
class Security
{
    /**
     * To move the safety screen after download in the config directory of the project.
JamesRezo's avatar
JamesRezo a validé
     * @deprecated 0.8
    public static function copySafetyScreen(Event $event): void
        $search = array_filter(
marcimat's avatar
marcimat a validé
            $event->getComposer()
                ->getPackage()
                ->getRequires(),
marcimat's avatar
marcimat a validé
            fn(Link $link) => $link->getTarget() === 'spip/security',
        );
        if (empty($search)) {
marcimat's avatar
marcimat a validé
            $event->getIO()
                ->warning('spip/security is not installed.');
marcimat's avatar
marcimat a validé
        $event->getIO()
            ->write('Updating the safety screen ...');
        $vendorDir = $event->getComposer()
            ->getConfig()
            ->get('vendor-dir');
marcimat's avatar
marcimat a validé
            \copy($vendorDir . '/spip/security/ecran_securite.php', $vendorDir . '/../config/ecran_securite.php');
            $event->getIO()
                ->write('Done.');
        } catch (\Throwable $th) {
marcimat's avatar
marcimat a validé
            $event->getIO()
                ->error($th->getMessage());