This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/install/ApplicationInstaller/CompileAssets.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2013-10-27 06:40:05 +01:00
<?php
namespace ApplicationInstaller;
2013-10-27 07:25:59 +01:00
use Composer\Script\Event;
use Rails;
2013-10-27 06:40:05 +01:00
/**
* Post-install script ran when installing the system
2013-10-27 07:25:59 +01:00
* using Composer to compile assets.
2013-10-27 06:40:05 +01:00
*/
class CompileAssets
{
2013-10-27 07:25:59 +01:00
static public function compile(Event $event)
2013-10-27 06:40:05 +01:00
{
2013-10-27 06:51:15 +01:00
$railsRoot = __DIR__ . '/../..';
# Create temporary config/config.php file
$file = $railsRoot . '/config/config.php.example';
$target = $railsRoot . '/config/config.php';
copy($file, $target);
2013-10-27 07:25:59 +01:00
# Load rails
2013-10-27 06:51:15 +01:00
require $railsRoot . '/config/boot.php';
2013-10-27 07:25:59 +01:00
# Reset configuration to production, because Rails will load
# development by default when ran from CGI, and Assets won't
# set environment to production itself. Fix this later.
Rails::resetConfig('production');
# Load console
$console = new Console($event->getIO());
# Warn about compiling
$console->write("[Compiling assets]");
# Set console to assets
Rails::assets()->setConsole($console);
# Compile files
Rails::assets()->compileAll();
2013-10-27 06:51:15 +01:00
# Delete temporary config file.
unlink($target);
2013-10-27 06:40:05 +01:00
}
}