Dump minified assets for prod environment under the web root directory.

@param $event Event A instance
353767
public static function dumpAssets(Event $event)
    {
        $options = self::getOptions($event);
        $consoleDir = static::getConsoleDir($event, 'install assets');

        if (null === $consoleDir) {
            return;
        }

        $webDir = $options['symfony-web-dir'];
        $command = 'assetic:dump';

        // if not set falls back to default behaviour of console commands (using SYMFONY_ENV or fallback to 'dev')
        if (!empty($options['ezpublish-asset-dump-env'])) {
            $event->getIO()->write('<error>Use of `ezpublish-asset-dump-env` is deprecated, use SYMFONY_ENV to set anything other then dev for all commands</error>');

            if ($options['ezpublish-asset-dump-env'] === 'none') {
                // If asset dumping is skipped, output help text on how to generate it if needed
                return self::dumpAssetsHelpText($event);
            }

            $command .= ' --env=' . escapeshellarg($options['ezpublish-asset-dump-env']);
        }

        if (!is_dir($consoleDir)) {
            echo 'The symfony console directory (' . $consoleDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL;

            return;
        }

        if (!is_dir($webDir)) {
            echo 'The symfony-web-dir (' . $webDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL;

            return;
        }

        static::executeCommand($event, $consoleDir, $command . ' ' . escapeshellarg($webDir));
    }
1162786
public static function postInstall(Event $event)
    {
        static::init();

        $event->getIO()->write('<info>Writing resources.lock file</info>');

        $installed = json_decode(file_get_contents(static::$vendorPath.'/composer/installed.json'));

        $data = [];

        $finder = (new Finder)
            ->directories()
            ->ignoreVCS(true)
            ->in(static::$resourcesPath.'/packages');

        foreach ($installed as $package) {
            if ( ! property_exists($package, 'extra')) continue;

            $extra = $package->extra;

            if ( ! property_exists($extra, 'resources')) continue;

            $resources = $extra->resources;

            foreach ($resources as $resource => $namespaces) {
                foreach ($namespaces as $namespace => $path) {
                    $finder->exclude($namespace);

                    $data[$resource][$namespace] = $path;
                }
            }
        }

        // We turn the iterator to an array to
        // prevent an exception when we delete the directorys
        foreach (iterator_to_array($finder) as $file) {
            \Filesystem::deleteDirectory($file->getPathname());
        }

        file_put_contents(static::$resourcesPath.'/resources.lock', json_encode($data, JSON_PRETTY_PRINT));
    }
1195505
public function renderToolbar($event = null)
    {
        if (!$this->checkAccess() || Yii::$app->getRequest()->getIsAjax()) {
            return;
        }

        $baseDebugUrl = Url::toRoute(['/' . $this->id . '/default/toolbar']);
        $baseDebugUrl = Html::encode($baseDebugUrl);
        $currentTag = $this->logTarget->tag;
        echo "<div id='yii-debug-toolbar' data-url='$baseDebugUrl' style='display:none' class='yii-debug-toolbar-bottom'></div>";
        echo "<script type='text/javascript'>window.yii2debugBaseDebugUrl = '$baseDebugUrl';window.yii2debugCurrentTag = '$currentTag';</script>";

        if ($this->includeAssets) {
            /* @var $view View */
            $view = isset($event->sender) ? $event->sender : new View();
            echo '<style>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar.css') . '</style>';
            echo '<style>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar-custom.css') . '</style>';
            echo '<script>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar.js') . '</script>';
        }
    }
811390
public static function installAssets(Event $event, $checkForCreateProject = true)
    {
        /*
         * Ugly hack to prevent application from being booted before configureProject can be called.
         */
        global $argv;
        if ($checkForCreateProject && strpos(implode(' ', $argv), 'create-project') > 0) {
            return;
        }

        static::runUpdateProjectFromAssets($event);

        $syncer = DirectorySyncer::fromEvent($event);
        $syncer->sync('bolt_assets', 'bolt_assets', true, ['css', 'fonts', 'img', 'js']);
    }
1256738
public static function postAutoloadDump(Event $event): void
    {
        $event->getIO()->write('<info>    Packages Auto-Discovery [Executed]</info>');
        $vendorPath = $event->getComposer()->getConfig()->get('vendor-dir');
        $manifestPath = $vendorPath . '/../bootstrap/cache/packages.php';

        self::discoverPackages($vendorPath, $manifestPath);
    }
1182444
public function onAppDownloadedChangeAccessToFiles(Downloaded $event)
    {
        if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
            $this->fs->chmod([
                $event->getPath().'/AnimeDB',
                $event->getPath().'/app/console',
            ], 0755);
        }
    }
333864
public function onVichUploaderPostUpload(Event $event)
    {
        $object = $event->getObject();
        $mapping = $event->getMapping();

        $absoluteDir = $mapping->getUploadDestination().'/'.$mapping->getUploadDir($object);
        $relativeDir = substr_replace($absoluteDir, '', 0, strlen($this->projectDir) + 1);

        $object->setRelativeDir($relativeDir);

        if (false !== strpos($object->getMimeType(), 'image/')) {
            $img = $mapping->getUploadDestination().'/'.$mapping->getUploadDir($object).'/'.$object->getMedia();
            $palette = Palette::fromFilename($img, Color::fromHexToInt('#FFFFFF'));
            $extractor = new ColorExtractor($palette);
            $colors = $extractor->extract();
            $object->setMainColor(Color::fromIntToHex($colors[0]));

            $this->generateCache('/'.$relativeDir.'/'.$object->getMedia());
        }
    }
7019
public function beforeRun($event)
    {
        $id = $this->owner->options['id'];
        $options = Json::htmlEncode($this->getClientOptions());
        $view = $this->owner->getView();
        GridViewAsset::register($view);
        $view->registerJs("jQuery('#$id').yiiGridView($options);");
    }
1252659
public static function postUpdate( \Composer\Script\Event $event )
    {
        $_composer = $event->getComposer();
        $_package = $_composer->getPackage();
        // do stuff
    }
1337697
public static function execute(Event $event) {
    $io = $event->getIO();

    // Search upwards for a composer.json which depends on acquia/lightning.
    $io->write('Searching for root package...');

    $file = static::getRootPackage();

    $package = $file->read();

    // Add the Asset Packagist repository if it does not already exist.
    if (isset($package['repositories'])) {
      $repository_key = NULL;

      foreach ($package['repositories'] as $key => $repository) {
        if ($repository['type'] == 'composer' && strpos($repository['url'], 'https://asset-packagist.org') === 0) {
          $repository_key = $key;
          break;
        }
      }

      if (is_null($repository_key)) {
        $package['repositories']['asset-packagist'] = [
          'type' => 'composer',
          'url' => 'https://asset-packagist.org',
        ];
      }
    }

    // oomphinc/composer-installers-extender is required by Lightning and
    // depends on composer/installers, so it does not need to be specifically
    // included.
    unset(
      $package['require']['composer/installers'],
      $package['require']['oomphinc/composer-installers-extender']
    );

    $package['extra']['installer-types'][] = 'bower-asset';
    $package['extra']['installer-types'][] = 'npm-asset';
    $package['extra']['installer-paths']['docroot/libraries/{$name}'][] = 'type:bower-asset';
    $package['extra']['installer-paths']['docroot/libraries/{$name}'][] = 'type:npm-asset';

    $file->write($package);
    $io->write('Successfully updated your root composer.json file. Switch back to your project root and run "composer update".');
  }
786894
public function renderToolbar($event)
    {
        if (!$this->checkAccess() || Yii::$app->getRequest()->getIsAjax()) {
            return;
        }

        /* @var $view View */
        $view = $event->sender;
        echo $view->renderDynamic('return Yii::$app->getModule("' . $this->id . '")->getToolbarHtml();');

        // echo is used in order to support cases where asset manager is not available
        echo '<style>' . $view->renderPhpFile(__DIR__ . '/assets/css/toolbar.css') . '</style>';
        echo '<script>' . $view->renderPhpFile(__DIR__ . '/assets/js/toolbar.js') . '</script>';
    }
167662
public function onPackageAfterExecute(Event $event)
    {
        /**
         * @var AbstractPackage    $package
         * @var AbstractController $controller
         */
        $package    = $event['package'];
        $controller = $event['controller'];

        /**
         * @var Container $container
         * @var Collector $collector
         * @var Profiler  $profiler
         */
        $container = $package->getContainer();
        $collector = $container->get('debugger.collector');
        $profiler  = $container->get('profiler');

        $collector['controller.main'] = get_class($controller);

        $collector->push('controller.executed', [
            'controller' => get_class($controller),
            'task' => $event['task'],
            'input' => $controller->getInput()->toArray(),
            'variables' => $event['variables'],
        ]);

        $name = $package->getName();

        $profiler->mark(__FUNCTION__ . ' / ' . $name . ' (' . uniqid() . ')', [
            'tag' => 'package.process',
        ]);
    }
821076
public static function run($event)
    {
        static::$io = $event->getIO();
        static::$composer = $event->getComposer();

        // Set the root theme folder dir.
        static::set_root();

        // Display snap logo!
        static::write_intro();

        $strategy = static::$io->select(
            "\n<comment>Please choose a templating system for your theme:</comment>",
            static::$strategies,
            0
        );

        switch ($strategy) {
            case '0':
                static::$io->write("<info>Setup finished.\nEnjoy SnapWP!</info>");
                exit;
                break;

            case '1':
                static::install_blade();
                break;
        }
    }
1186656
public function onPreAutoloadDump(Event $event)
    {
        $basePath = $this->getBasePath($event);
        $lockPath = "{$basePath}/pre.lock";

        $shouldOptimize = $this->shouldOptimize($event);

        if ($shouldOptimize) {
            file_put_contents($lockPath, time());

            if (!file_exists("{$basePath}/vendor/autoload.php")) {
                return;
            }

            require_once "{$basePath}/vendor/autoload.php";

            $directory = new RecursiveDirectoryIterator($basePath);

            $files = new RecursiveIteratorIterator(
                $directory, RecursiveIteratorIterator::SELF_FIRST
            );

            foreach ($files as $file) {
                if (stripos($file, "{$basePath}/vendor") === 0) {
                    continue;
                }

                if ($file->getExtension() !== "pre") {
                    continue;
                }

                $pre = $file->getPathname();
                $php = preg_replace("/pre$/", "php", $pre);

                compile(
                    $pre, $php, $format = true, $comment = false
                );
            }
        } else {
            if (file_exists($lockPath)) {
                unlink($basePath . "/pre.lock");
            }
        }
    }
602046
public function attach($event)
    {
        $this->attachRows($event);
        $this->attachSeo($event);
        $this->attachAnonsModule($event);
    }
1018071
public function saveAttributes($event)
    {
        $isAppInSourceLanguage = Yii::$app->sourceLanguage === Yii::$app->language;

        foreach ($this->translateAttributes as $attribute) {
            if (!$this->owner->isAttributeChanged($attribute)) {
                continue;
            }

            if ($isAppInSourceLanguage || !$this->saveAttributeValueAsTranslation($attribute)) {
                Language::saveMessage($this->owner->attributes[$attribute], $this->category);
            }
        }
    }
587333
public static function configureProject(Event $event)
    {
        DirectoryConfigurator::fromEvent($event)->run();
        BundleConfigurator::fromEvent($event)->run();

        // Install assets here since they they were skipped above
        static::installAssets($event, false);
    }