/**
  * Parses the contents of a given YAML file.
  *
  * @param $filePath
  * @throws Exceptions\FileReaderException
  * @return array
  */
 public static function parse($filePath)
 {
     try {
         $data = self::load($filePath);
         if (!empty($data)) {
             //Try to process the yaml file with the PHP function, if installed
             if (function_exists("yaml_parse")) {
                 $dataArray = yaml_parse($data);
                 if (is_array($dataArray)) {
                     return $dataArray;
                 }
             } else {
                 try {
                     $yml = new \Symfony\Component\Yaml\Yaml();
                     return $yml->parse($data);
                 } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
                     //Do nothing. Fire exception after the if-else statement.
                 }
             }
             throw new FileReaderException('The file does not contain valid well formatted YAML data.');
         } else {
             throw new FileReaderException('No data has been loaded. Use the load($filePath) method before using getData().');
         }
     } catch (FileReaderException $e) {
         throw new FileReaderException($e);
     }
 }
Example #2
0
 /**
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  */
 public function __construct(Request $request)
 {
     $queryDecorator = new QueryDecorator($this->_getQuery());
     $this->_query = $queryDecorator->decorate($request, $this->_getUrlParamsMapper());
     $this->_curl = new AnonymousCurl();
     $reader = new \Symfony\Component\Yaml\Yaml();
     $this->_config = $reader->parse(__DIR__ . '/../Resources/config/cache.yml');
 }
 public static function parse($content)
 {
     if (self::$native === false) {
         $yaml = new \Symfony\Component\Yaml\Yaml();
         return new Collection($yaml->parse($content));
     } else {
         return new Collection(yaml_parse($content));
     }
 }
Example #4
0
 /**
  * @return bool|void
  */
 public static function make_manifest()
 {
     $files = self::get_file_manifest();
     $configs = array();
     foreach ($files as $path => $info) {
         if ($info['extension'] == 'yml' || $info['extension'] == 'yaml') {
             $configs = array_merge($configs, Symfony\Component\Yaml\Yaml::parse(file_get_contents($path)));
         }
     }
     file_put_contents(TEMP_PATH . '/config_manifest', serialize($configs));
     self::$config_manifest = $configs;
 }
Example #5
0
 public static function loadConfig($path)
 {
     $path = realpath($path);
     if (!isset(self::$Configs[$path])) {
         $yaml = new \Symfony\Component\Yaml\Yaml();
         if (file_exists($path)) {
             self::$Configs[$path] = $yaml->parse($path);
         } else {
             throw new \Symfony\Component\Filesystem\Exception\FileNotFoundException();
         }
     }
     return self::$Configs[$path];
 }
Example #6
0
 /**
  * Register the bundles (and by the way the modules).
  *
  * @return array|\Symfony\Component\HttpKernel\Bundle\BundleInterface[]
  * @throws RuntimeException
  * @throws Symfony\Component\Debug\Exception\FatalErrorException
  */
 public function registerBundles()
 {
     /*
      * Basic bundles, required to load the website
      */
     $bundles = array(new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Knp\Bundle\TimeBundle\KnpTimeBundle(), new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(), new FOS\JsRoutingBundle\FOSJsRoutingBundle(), new FrequenceWeb\Bundle\CalendRBundle\FrequenceWebCalendRBundle(), new FM\BbcodeBundle\FMBbcodeBundle(), new Sonata\IntlBundle\SonataIntlBundle(), new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new Minifier\MinifierBundle(), new Etu\Core\CoreBundle\EtuCoreBundle(), new Etu\Core\UserBundle\EtuUserBundle(), new Etu\Core\ApiBundle\EtuCoreApiBundle());
     if (in_array($this->getEnvironment(), array('dev', 'test'))) {
         $bundles[] = new Elao\WebProfilerExtraBundle\WebProfilerExtraBundle();
         $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
         $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
         $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
     }
     /*
      * Modules bundles, loaded dynamically from app/config/modules.yml
      */
     $modules = Symfony\Component\Yaml\Yaml::parse($this->getRootDir() . '/config/modules.yml');
     if (isset($modules['modules'])) {
         if (!is_array($modules['modules'])) {
             throw new FatalErrorException('Key "modules" in app/config/modules.yml must be an array');
         }
         foreach ($modules['modules'] as $module) {
             $bundleFile = 'src/' . str_replace('\\', '/', $module) . '.php';
             if (!class_exists($module, false)) {
                 if (file_exists($this->getRootDir() . '/../' . $bundleFile)) {
                     require $this->getRootDir() . '/../' . $bundleFile;
                 } else {
                     throw new \RuntimeException(sprintf('Module "%s" can not be loaded (file "%s" not found)', $module, $bundleFile));
                 }
             }
             if (class_exists($module, false)) {
                 $module = new ReflectionClass($module);
                 $module = $module->newInstance();
                 if ($module instanceof Module) {
                     $bundles[] = $module;
                     $this->registerModuleDefinition($module);
                 } else {
                     throw new FatalErrorException(sprintf('Module "%s" must be an instance of Etu\\Core\\CoreBundle\\Framework\\Definition\\Module.', get_class($module)));
                 }
             } else {
                 throw new \RuntimeException(sprintf('Module "%s" can not be loaded (class not found)', $module));
             }
         }
     }
     $this->checkModulesIntegrity();
     return $bundles;
 }
Example #7
0
 protected function exportModuleDependencies($io, $module, $dependencies)
 {
     $yaml = new \Symfony\Component\Yaml\Yaml();
     $info_file = file_get_contents($this->getSite()->getModuleInfoFile($module));
     $info_yaml = $yaml->parse($info_file);
     if (empty($info_yaml['dependencies'])) {
         $info_yaml['dependencies'] = $dependencies;
     } else {
         $info_yaml['dependencies'] = array_unique(array_merge($info_yaml['dependencies'], $dependencies));
     }
     if (file_put_contents($this->getSite()->getModuleInfoFile($module), $yaml->dump($info_yaml))) {
         $io->info('[+] ' . sprintf($this->trans('commands.config.export.view.messages.depencies-included'), $this->getSite()->getModuleInfoFile($module)));
         foreach ($dependencies as $dependency) {
             $io->info('   [-] ' . $dependency);
         }
     } else {
         $io->error($this->trans('commands.site.mode.messages.error-writing-file') . ': ' . $this->getSite()->getModuleInfoFile($module));
         return [];
     }
 }
Example #8
0
 /**
  * Adds a new yaml file to the dataset.
  * @param string $yamlFile
  */
 public function addYamlFile($yamlFile)
 {
     $data = Symfony\Component\Yaml\Yaml::parse($yamlFile);
     foreach ($data as $tableName => $rows) {
         if (!isset($rows)) {
             $rows = array();
         }
         if (!is_array($rows)) {
             continue;
         }
         if (!array_key_exists($tableName, $this->tables)) {
             $columns = $this->getColumns($rows);
             $tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
             $this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_DefaultTable($tableMetaData);
         }
         foreach ($rows as $row) {
             $this->tables[$tableName]->addRow($row);
         }
     }
 }
Example #9
0
 protected function loadFile($filePath)
 {
     $yml = array();
     $dirname = dirname($filePath);
     $yaml = new \Symfony\Component\Yaml\Yaml();
     $res = $yaml->parse($filePath);
     foreach ($res as $key => $value) {
         if ($key == 'include') {
             foreach ($value as $file) {
                 $file = preg_replace_callback('`\\${env\\.([^}]+)}`i', function ($matches) {
                     return getenv($matches[1]);
                 }, $file);
                 $subYml = $this->loadFile($dirname . '/' . $file);
                 $yml = Arrays::mergeRecursiveUnique($yml, $subYml);
             }
         } else {
             $yml = Arrays::mergeRecursiveUnique($yml, array($key => $res[$key]));
         }
     }
     return $yml;
 }
Example #10
0
 protected function overrideServices($env, $output)
 {
     $services_settings = $this->getServicesSettings($env);
     $directory = $this->getDrupalHelper()->getRoot() . '/' . \Drupal::service('site.path');
     $settings_services_file = $directory . '/services.yml';
     if (!file_exists($settings_services_file)) {
         // Copying default services
         $default_services_file = $this->getDrupalHelper()->getRoot() . '/sites/default/default.services.yml';
         if (!copy($default_services_file, $directory . '/services.yml')) {
             $output->writeln(' <error>' . $this->trans('commands.site.mode.messages.error-copying-file') . ': ' . $directory . '/services.yml' . '</error>');
             return [];
         }
     }
     $yaml = new \Symfony\Component\Yaml\Yaml();
     $content = file_get_contents($directory . '/services.yml');
     $services = $yaml->parse($content);
     $result = [];
     foreach ($services_settings as $service => $parameters) {
         foreach ($parameters as $parameter => $value) {
             $services['parameters'][$service][$parameter] = $value;
             // Set values for output
             $result[$parameter]['service'] = $service;
             $result[$parameter]['parameter'] = $parameter;
             if (is_bool($value)) {
                 $value = $value ? 'true' : 'false';
             }
             $result[$parameter]['value'] = $value;
         }
     }
     if (file_put_contents($directory . '/services.yml', $yaml->dump($services))) {
         $output->writeln('<info>' . sprintf($this->trans('commands.site.mode.messages.services-file-overwritten'), $directory . '/services.yml') . '</info>');
     } else {
         $output->writeln(' <error>' . $this->trans('commands.site.mode.messages.error-writing-file') . ': ' . $directory . '/services.yml' . '</error>');
         return [];
     }
     sort($result);
     return $result;
 }
Example #11
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Pinboard\Logger\DbalLogger;
use Pinboard\Stopwatch\Stopwatch;
$app = new Silex\Application();
$app['params'] = Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__ . '/../config/parameters.yml'));
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
    if (!isset($app['params']['base_url']) || empty($app['params']['base_url'])) {
        $baseUrl = '/';
    } else {
        $baseUrl = $app['params']['base_url'];
    }
    if (substr($baseUrl, -1) != '/') {
        $baseUrl .= '/';
    }
    $twig->addGlobal('base_url', $baseUrl);
    return $twig;
}));
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$dbOptions = array('driver' => 'pdo_mysql', 'dbname' => $app['params']['db']['name'], 'host' => $app['params']['db']['host'], 'user' => $app['params']['db']['user'], 'password' => $app['params']['db']['pass']);
if (isset($app['params']['db']['port'])) {
    $dbOptions['port'] = $app['params']['db']['port'];
}
if (isset($app['params']['db']['unix_socket'])) {
    $dbOptions['unix_socket'] = $app['params']['db']['unix_socket'];
}
Example #12
0
 public function __construct()
 {
     $reader = new \Symfony\Component\Yaml\Yaml();
     $this->_config = $reader->parse(__DIR__ . '/../Resources/config/cache.yml');
 }
Example #13
0
 /**
  * Sets up a Drupal site for running functional and integration tests.
  *
  * Installs Drupal with the installation profile specified in
  * \Drupal\simpletest\WebTestBase::$profile into the prefixed database.
  *
  * Afterwards, installs any additional modules specified in the static
  * \Drupal\simpletest\WebTestBase::$modules property of each class in the
  * class hierarchy.
  *
  * After installation all caches are flushed and several configuration values
  * are reset to the values of the parent site executing the test, since the
  * default values may be incompatible with the environment in which tests are
  * being executed.
  */
 protected function setUp()
 {
     // When running tests through the Simpletest UI (vs. on the command line),
     // Simpletest's batch conflicts with the installer's batch. Batch API does
     // not support the concept of nested batches (in which the nested is not
     // progressive), so we need to temporarily pretend there was no batch.
     // Backup the currently running Simpletest batch.
     $this->originalBatch = batch_get();
     // Define information about the user 1 account.
     $this->rootUser = new UserSession(array('uid' => 1, 'name' => 'admin', 'mail' => '*****@*****.**', 'pass_raw' => $this->randomMachineName()));
     // The child site derives its session name from the database prefix when
     // running web tests.
     $this->generateSessionName($this->databasePrefix);
     // Reset the static batch to remove Simpletest's batch operations.
     $batch =& batch_get();
     $batch = array();
     // Get parameters for install_drupal() before removing global variables.
     $parameters = $this->installParameters();
     // Prepare installer settings that are not install_drupal() parameters.
     // Copy and prepare an actual settings.php, so as to resemble a regular
     // installation.
     // Not using File API; a potential error must trigger a PHP warning.
     $directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
     copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php');
     copy(DRUPAL_ROOT . '/sites/default/default.services.yml', $directory . '/services.yml');
     // All file system paths are created by System module during installation.
     // @see system_requirements()
     // @see TestBase::prepareEnvironment()
     $settings['settings']['file_public_path'] = (object) array('value' => $this->publicFilesDirectory, 'required' => TRUE);
     $settings['settings']['file_private_path'] = (object) array('value' => $this->privateFilesDirectory, 'required' => TRUE);
     // Save the original site directory path, so that extensions in the
     // site-specific directory can still be discovered in the test site
     // environment.
     // @see \Drupal\Core\Extension\ExtensionDiscovery::scan()
     $settings['settings']['test_parent_site'] = (object) array('value' => $this->originalSite, 'required' => TRUE);
     // Add the parent profile's search path to the child site's search paths.
     // @see \Drupal\Core\Extension\ExtensionDiscovery::getProfileDirectories()
     $settings['conf']['simpletest.settings']['parent_profile'] = (object) array('value' => $this->originalProfile, 'required' => TRUE);
     $settings['settings']['apcu_ensure_unique_prefix'] = (object) array('value' => FALSE, 'required' => TRUE);
     $this->writeSettings($settings);
     // Allow for test-specific overrides.
     $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php';
     if (file_exists($settings_testing_file)) {
         // Copy the testing-specific settings.php overrides in place.
         copy($settings_testing_file, $directory . '/settings.testing.php');
         // Add the name of the testing class to settings.php and include the
         // testing specific overrides
         file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) . "';\n" . 'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';' . "\n", FILE_APPEND);
     }
     $settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
     if (file_exists($settings_services_file)) {
         // Copy the testing-specific service overrides in place.
         copy($settings_services_file, $directory . '/services.yml');
     }
     if ($this->strictConfigSchema) {
         // Add a listener to validate configuration schema on save.
         $yaml = new \Symfony\Component\Yaml\Yaml();
         $services = $yaml->parse($directory . '/services.yml');
         $services['services']['simpletest.config_schema_checker'] = ['class' => 'Drupal\\Core\\Config\\Testing\\ConfigSchemaChecker', 'arguments' => ['@config.typed'], 'tags' => [['name' => 'event_subscriber']]];
         file_put_contents($directory . '/services.yml', $yaml->dump($services));
     }
     // Since Drupal is bootstrapped already, install_begin_request() will not
     // bootstrap again. Hence, we have to reload the newly written custom
     // settings.php manually.
     $class_loader = (require DRUPAL_ROOT . '/autoload.php');
     Settings::initialize(DRUPAL_ROOT, $this->siteDirectory, $class_loader);
     // Execute the non-interactive installer.
     require_once DRUPAL_ROOT . '/core/includes/install.core.inc';
     install_drupal($class_loader, $parameters);
     // Import new settings.php written by the installer.
     Settings::initialize(DRUPAL_ROOT, $this->siteDirectory, $class_loader);
     foreach ($GLOBALS['config_directories'] as $type => $path) {
         $this->configDirectories[$type] = $path;
     }
     // After writing settings.php, the installer removes write permissions
     // from the site directory. To allow drupal_generate_test_ua() to write
     // a file containing the private key for drupal_valid_test_ua(), the site
     // directory has to be writable.
     // TestBase::restoreEnvironment() will delete the entire site directory.
     // Not using File API; a potential error must trigger a PHP warning.
     chmod($directory, 0777);
     $request = \Drupal::request();
     $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', TRUE);
     $this->kernel->prepareLegacyRequest($request);
     // Force the container to be built from scratch instead of loaded from the
     // disk. This forces us to not accidentally load the parent site.
     $container = $this->kernel->rebuildContainer();
     $config = $container->get('config.factory');
     // Manually create and configure private and temporary files directories.
     // While these could be preset/enforced in settings.php like the public
     // files directory above, some tests expect them to be configurable in the
     // UI. If declared in settings.php, they would no longer be configurable.
     file_prepare_directory($this->privateFilesDirectory, FILE_CREATE_DIRECTORY);
     file_prepare_directory($this->tempFilesDirectory, FILE_CREATE_DIRECTORY);
     $config->getEditable('system.file')->set('path.temporary', $this->tempFilesDirectory)->save();
     // Manually configure the test mail collector implementation to prevent
     // tests from sending out emails and collect them in state instead.
     // While this should be enforced via settings.php prior to installation,
     // some tests expect to be able to test mail system implementations.
     $config->getEditable('system.mail')->set('interface.default', 'test_mail_collector')->save();
     // By default, verbosely display all errors and disable all production
     // environment optimizations for all tests to avoid needless overhead and
     // ensure a sane default experience for test authors.
     // @see https://www.drupal.org/node/2259167
     $config->getEditable('system.logging')->set('error_level', 'verbose')->save();
     $config->getEditable('system.performance')->set('css.preprocess', FALSE)->set('js.preprocess', FALSE)->save();
     // Collect modules to install.
     $class = get_class($this);
     $modules = array();
     while ($class) {
         if (property_exists($class, 'modules')) {
             $modules = array_merge($modules, $class::$modules);
         }
         $class = get_parent_class($class);
     }
     if ($modules) {
         $modules = array_unique($modules);
         try {
             $success = $container->get('module_installer')->install($modules, TRUE);
             $this->assertTrue($success, SafeMarkup::format('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
         } catch (\Drupal\Core\Extension\MissingDependencyException $e) {
             // The exception message has all the details.
             $this->fail($e->getMessage());
         }
         $this->rebuildContainer();
     }
     // Restore the original Simpletest batch.
     $batch =& batch_get();
     $batch = $this->originalBatch;
     // Reset/rebuild all data structures after enabling the modules, primarily
     // to synchronize all data structures and caches between the test runner and
     // the child site.
     // @see \Drupal\Core\DrupalKernel::bootCode()
     // @todo Test-specific setUp() methods may set up further fixtures; find a
     //   way to execute this after setUp() is done, or to eliminate it entirely.
     $this->resetAll();
     $this->kernel->prepareLegacyRequest($request);
     // Explicitly call register() again on the container registered in \Drupal.
     // @todo This should already be called through
     //   DrupalKernel::prepareLegacyRequest() -> DrupalKernel::boot() but that
     //   appears to be calling a different container.
     $this->container->get('stream_wrapper_manager')->register();
 }
Example #14
0
      * -> bbapp.cache.dir
      * -> bbapp.log.dir
      * -> bbapp.data.dir
      */
     if (!isset($_POST['debug']) && !isset($_POST['container_dump_directory'])) {
         break;
     }
     $containerDirectory = realpath(__DIR__ . '/..') . '/cache/container';
     if (!is_dir($containerDirectory)) {
         mkdir($containerDirectory, 755);
     }
     $bootstrap = ['debug' => (bool) intval($_POST['debug']), 'container' => ['dump_directory' => $containerDirectory, 'autogenerate' => true]];
     file_put_contents(dirname(__DIR__) . '/repository/Config/bootstrap.yml', $yaml->dump($bootstrap));
     $servicesPath = realpath(__DIR__ . '/../repository/Config/services.yml');
     if (file_exists($servicesPath)) {
         $services = $yaml->parse($servicesPath);
     } else {
         $services = ['parameters'];
     }
     $services['parameters']['bbapp.cache.dir'] = realpath(__DIR__ . '/../cache');
     $services['parameters']['bbapp.log.dir'] = realpath(__DIR__ . '/../log');
     $services['parameters']['bbapp.data.dir'] = realpath(__DIR__ . '/../repository/Data');
     file_put_contents($servicesPath, $yaml->dump($services));
     $step = 3;
 case 3:
     /**
      * doctrine.yml creation
      * dbal:
      *  driver: pdo_mysql|pdo_pgsl|... See (http://doctrine-dbal.readthedocs.org/en/latest/reference/configuration.html#driver)
      *   host: localhost|mysql.domain.com
      *   port: 3306
 public function parseYaml($yamlFile)
 {
     return Symfony\Component\Yaml\Yaml::parse(file_get_contents($yamlFile));
 }
Example #16
0
<?php

$yaml = APP_PATH . '/config.yml';
if (file_exists($yaml) && is_file($yaml) && is_readable($yaml)) {
    $env = getenv('ENVIRONMENT') ?: 'development';
    $configCache = VAR_PATH . "/cache/config/{$env}.json";
    if (file_exists($configCache) && is_file($configCache) && is_readable($configCache) && filemtime($configCache) > filemtime($yaml)) {
        $config = json_decode(file_get_contents($configCache), true);
    } else {
        $config = Symfony\Component\Yaml\Yaml::parse(file_get_contents($yaml));
        if (isset($config[$env])) {
            $config = $config[$env];
            // Slim
            $config['Slim']['mode'] = $env;
            // Logger
            if (isset($config['Slim']['log.level'])) {
                $level = 'Slim\\Log::' . $config['Slim']['log.level'];
                if (defined($level)) {
                    $config['Slim']['log.level'] = constant($level);
                } else {
                    throw new \Exception('Slim log level is incorrect.');
                }
            }
            // View renderer
            $config['Slim']['templates.path'] = APP_PATH . '/templates';
            if (true === $config['Twig']['cache']) {
                $config['Twig']['cache'] = VAR_PATH . '/cache/twig';
            }
            // save config cache file
            file_put_contents($configCache, json_encode($config));
        } else {
Example #17
0
 /**
  * Parses YAML into a PHP array.
  *
  * @param string $value YAML string
  *
  * @return array
  */
 public static function yamlDecode($value)
 {
     return Symfony\Component\Yaml\Yaml::parse($value);
 }
Example #18
0
#!/usr/bin/php
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
Dotenv::load(__DIR__ . '/../');
/**
 * @TODO build this from the yaml file on the fly
 */
$yml = new Symfony\Component\Yaml\Yaml();
$tests = $yml->parse(__DIR__ . '/../behat.yml');
$run = [];
$env = getenv('APP_ENV');
foreach ($tests as $key => $test) {
    if (strpos($key, $env) !== false) {
        $run[] = $key;
    }
}
$failing_test = [];
foreach ($run as $test) {
    $command = "bin/behat --stop-on-failure --no-paths --tags='@api,~@wip' --profile={$test}";
    $run = new \Symfony\Component\Process\Process($command);
    $run->setTimeout(600);
    $run->run(function ($type, $buffer) use($failing_test, $test) {
        if (Symfony\Component\Process\Process::ERR === $type) {
            $failing_test[] = $test;
            //throw new \Exception(sprintf("Test Failed %s", $buffer));
        } else {
            echo $buffer;
        }
    });
    if ($run->getExitCode() != 0) {
        $failing_test[] = $test;
Example #19
0
<?php

$autoload = (require __DIR__ . '/vendor/autoload.php');
// Load configuration file or attempt to build a new one
define("APP_PATH", __DIR__);
define("CONFIG_FILE", APP_PATH . "/" . "config.yml");
if (!is_file(CONFIG_FILE)) {
    echo "Please run the installer first: './install.sh'.\n";
    exit(1);
}
// Build ACME client
$config = Symfony\Component\Yaml\Yaml::parse(file_get_contents(CONFIG_FILE));
$db = $config["db"];
$dsn = "{$db["driver"]}://{$db["user"]}:{$db["pass"]}@{$db["host"]}/{$db["dbname"]}";
$params = array('params' => array('database' => $dsn, 'api' => $config["api"], 'challenge' => $config["challenge"]));
$client = new \Octopuce\Acme\Client($params);
// Build Console
$console = new Symfony\Component\Console\Application("Letsencrypt SSL CLI", "0.1");
$console->add(new \Symfony\Component\Console\Command\HelpCommand());
$console->add(new \Symfony\Component\Console\Command\ListCommand());
//$console->add(new \Octopuce\Acme\Cli\Command\Enumerate(null, $client));
$console->add(new \Octopuce\Acme\Cli\Command\NewAccount(null, $client));
$console->add(new \Octopuce\Acme\Cli\Command\NewOwnership(null, $client));
//$console->add(new \Octopuce\Acme\Cli\Command\ChallengeOwnership(null, $client));
$console->add(new \Octopuce\Acme\Cli\Command\SignCertificate(null, $client));
$console->add(new \Octopuce\Acme\Cli\Command\RevokeCertificate(null, $client));
$console->add(new \Octopuce\Acme\Cli\Command\UpdateCertificate(null, $client));
Example #20
0
 protected function loadInline($inline)
 {
     $yaml = new \Symfony\Component\Yaml\Yaml();
     $res = $yaml->parse($inline);
     return $res;
 }
Example #21
0
<?php

// Register class loader
require_once __DIR__ . '/lib/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespace('Symfony', __DIR__ . '/lib/symfony/src');
$loader->register();
// Read build file
$build = Symfony\Component\Yaml\Yaml::parse(__DIR__ . '/build.yml');
// Build components
mkdir(__DIR__ . "/../build/components", 0777, true);
foreach ($build['components'] as $componentName) {
    // Compute component source path
    $componentSourcePath = __DIR__ . "/../src/{$componentName}.js";
    // Build raw
    file_put_contents(__DIR__ . "/../build/components/{$componentName}.js", render(__DIR__ . '/copyright.php', array('content' => file_get_contents($componentSourcePath))));
    // Build minified
    file_put_contents(__DIR__ . "/../build/components/{$componentName}-min.js", render(__DIR__ . '/copyright.php', array('content' => compress(file_get_contents($componentSourcePath)))));
}
// Build rollups
mkdir(__DIR__ . '/../build/rollups', 0777, true);
foreach ($build['rollups'] as $rollupName => $components) {
    // Compute component source paths
    $componentSourcePaths = array_map(function ($componentName) {
        return __DIR__ . "/../src/{$componentName}.js";
    }, $components);
    // Get component source contents
    $componentSourceContents = implode('', array_map('file_get_contents', $componentSourcePaths));
    // Build rollup
    file_put_contents(__DIR__ . "/../build/rollups/{$rollupName}.js", render(__DIR__ . '/copyright.php', array('content' => compress($componentSourceContents))));
}
Example #22
0
#!/usr/bin/env php
<?php 
echo <<<INFO
To get the most out of this script, run it once as your own user and
once as the web server user: `sudo -u www-data ./bin/check.php`


INFO;
require_once dirname(__DIR__) . '/vendor/autoload.php';
$configPath = dirname(__DIR__) . '/app/config';
if (file_exists($configPath . '/path.php')) {
    $paths = (require $configPath . '/path.php');
} else {
    if (file_exists($configPath . '/path.yml')) {
        $paths = Symfony\Component\Yaml\Yaml::parse($configPath . '/path.php');
    } else {
        echo "ERROR: No path config file found!\n";
        exit(1);
    }
}
$verbose = in_array('-v', $argv) || in_array('--verbose', $argv);
exit(Autarky\Utils\Diagnostic::check($paths, $verbose));
Example #23
0
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';
$parser = new Symfony\Component\Yaml\Yaml();
$global = $parser->parse(dirname(__DIR__) . '/config/global.yml');
$config = $parser->parse(sprintf(dirname(__DIR__) . '/config/%s.yml', $global['environment']));
$security = $parser->parse(dirname(__DIR__) . '/config/security.yml');
$routes = $parser->parse(dirname(__DIR__) . '/config/routes.yml');
$app = new App\Application(array_merge($global, $config, $security, $routes));
/** Doctrine cli-config also uses this bootstrap for db etc, so don't run HTTP stuff if cli is being used **/
isset($cli) ?: $app->run();
 /**
  * Parse and prepare the information in an environment file.
  *
  * @param string $filename
  *   The filename.
  *
  * @return array
  *   The yaml data parsed into a php array.
  */
 private function extractEnv($filename)
 {
     // Load the yaml parser.
     $yaml = new \Symfony\Component\Yaml\Yaml();
     $data = file_get_contents($filename);
     $env = (array) $yaml->parse($data);
     // Add defaults.
     $env += ['modules' => [], 'variables' => [], 'permissions' => [], 'commands' => []];
     // Process data so it can be appropriately merged if this is a composite
     // environment request.
     foreach ($env['modules'] as $status => $modules) {
         $env['modules'][$status] = array_combine($env['modules'][$status], $env['modules'][$status]);
     }
     return $env;
 }
<?php

require_once __DIR__ . '/vendor/libphutil/src/__phutil_library_init__.php';
require_once __DIR__ . '/vendor/autoload.php';
if (count($argv) < 3) {
    echo "Usage: php maniphest_bulk_add.php project_id /path/to/tasks_file\n";
    exit(1);
}
$project = $argv[1];
$tasksFile = $argv[2];
$config = Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__ . '/config.yml'));
$conduit = new ConduitClient($config['PHABRICATOR_URL']);
$conduit->callMethodSynchronous('conduit.connect', ['client' => 'Maniphest Bulk Add', 'clientVersion' => 1, 'user' => $config['USER'], 'certificate' => $config['CONDUIT_CERTIFICATE']]);
$projectQuery = $conduit->callMethodSynchronous('project.query', ['ids' => [$project]]);
if (empty($projectQuery['data'])) {
    echo "Could not find project {$project}";
    exit(1);
}
$targetProject = reset($projectQuery['data']);
$taskIDs = array_filter(array_map(function ($line) {
    preg_match("/\\d+\$/", $line, $matches);
    if (!empty($matches)) {
        return $matches[0];
    }
}, explode("\n", file_get_contents($tasksFile))));
$tasks = $conduit->callMethodSynchronous('maniphest.query', ['ids' => $taskIDs]);
if (count($tasks) !== count($taskIDs)) {
    echo "Couldn't find all the tasks. Aborting :(\n";
    exit(1);
}
foreach ($tasks as $task) {
Example #26
0
<?php

/**
 * 
 * 0 "${APP_PATH}/patch_yaml/patch_yaml.php" 
 * 1 "${APP_PATH}/array.yml" 
 * 2 "$MYSQL_DB_NAME" 
 * 3 "$MYSQL_USER_NAME" 
 * 4 "$MYSQL_USER_PASSWORD"`
 * 
 */
try {
    $autoload = (require_once __DIR__ . '/../vendor/autoload.php');
    $array = Symfony\Component\Yaml\Yaml::parse(file_get_contents($argv[1]));
    $db = $array["db"];
    $db["dbname"] = $argv[2];
    $db["user"] = $argv[3];
    $db["pass"] = $argv[4];
    $array["db"] = $db;
    file_put_contents($argv[1], Symfony\Component\Yaml\Yaml::dump($array, 4, 4, true));
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
    exit(1);
}
echo "OK";
exit(0);
 public function parseYaml($yamlFile)
 {
     return Symfony\Component\Yaml\Yaml::parse($yamlFile);
 }
Example #28
0
<?php

$appDir = dirname(__DIR__);
include_once $appDir . "/vendor/autoload.php";
use Silktide\Syringe\ReferenceResolver;
use Silktide\Syringe\ContainerBuilder;
use Silktide\Syringe\Loader\JsonLoader;
use Silktide\Syringe\Loader\YamlLoader;
// Config data should be brought in using environment variables
// Updating environment variables is a PITA when doing some quick dev, so if we have an
// env.yml file, dump it into $_SERVER, where syringe will pick it up as if it was an actual environment variable
$environmentFile = __DIR__ . "/../env.yml";
if (file_exists($environmentFile)) {
    $yaml = new \Symfony\Component\Yaml\Yaml();
    $array = $yaml->parse(file_get_contents($environmentFile));
    foreach ($array as $key => $value) {
        $_SERVER[$key] = $value;
    }
}
$resolver = new ReferenceResolver();
$loaders = [new JsonLoader(), new YamlLoader()];
$configPaths = [$appDir . "/app/config", $appDir];
$builder = new ContainerBuilder($resolver, $configPaths);
foreach ($loaders as $loader) {
    $builder->addLoader($loader);
}
$builder->setApplicationRootDirectory($appDir);
$builder->addConfigFiles(["dolondro_hotstuff" => $appDir . "/vendor/dolondro/hotstuff/app/config/services.yml"]);
$builder->addConfigFile("services.yml");
Example #29
0
 /**
  * Prepares site settings and services before installation.
  */
 protected function prepareSettings()
 {
     // Prepare installer settings that are not install_drupal() parameters.
     // Copy and prepare an actual settings.php, so as to resemble a regular
     // installation.
     // Not using File API; a potential error must trigger a PHP warning.
     $directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
     copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php');
     // All file system paths are created by System module during installation.
     // @see system_requirements()
     // @see TestBase::prepareEnvironment()
     $settings['settings']['file_public_path'] = (object) ['value' => $this->publicFilesDirectory, 'required' => TRUE];
     $settings['settings']['file_private_path'] = (object) ['value' => $this->privateFilesDirectory, 'required' => TRUE];
     // Save the original site directory path, so that extensions in the
     // site-specific directory can still be discovered in the test site
     // environment.
     // @see \Drupal\Core\Extension\ExtensionDiscovery::scan()
     $settings['settings']['test_parent_site'] = (object) ['value' => $this->originalSite, 'required' => TRUE];
     // Add the parent profile's search path to the child site's search paths.
     // @see \Drupal\Core\Extension\ExtensionDiscovery::getProfileDirectories()
     $settings['conf']['simpletest.settings']['parent_profile'] = (object) ['value' => $this->originalProfile, 'required' => TRUE];
     $settings['settings']['apcu_ensure_unique_prefix'] = (object) ['value' => FALSE, 'required' => TRUE];
     $this->writeSettings($settings);
     // Allow for test-specific overrides.
     $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php';
     if (file_exists($settings_testing_file)) {
         // Copy the testing-specific settings.php overrides in place.
         copy($settings_testing_file, $directory . '/settings.testing.php');
         // Add the name of the testing class to settings.php and include the
         // testing specific overrides
         file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) . "';\n" . 'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';' . "\n", FILE_APPEND);
     }
     $settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
     if (!file_exists($settings_services_file)) {
         // Otherwise, use the default services as a starting point for overrides.
         $settings_services_file = DRUPAL_ROOT . '/sites/default/default.services.yml';
     }
     // Copy the testing-specific service overrides in place.
     copy($settings_services_file, $directory . '/services.yml');
     if ($this->strictConfigSchema) {
         // Add a listener to validate configuration schema on save.
         $yaml = new \Symfony\Component\Yaml\Yaml();
         $content = file_get_contents($directory . '/services.yml');
         $services = $yaml->parse($content);
         $services['services']['simpletest.config_schema_checker'] = ['class' => 'Drupal\\Core\\Config\\Testing\\ConfigSchemaChecker', 'arguments' => ['@config.typed', $this->getConfigSchemaExclusions()], 'tags' => [['name' => 'event_subscriber']]];
         file_put_contents($directory . '/services.yml', $yaml->dump($services));
     }
     // Since Drupal is bootstrapped already, install_begin_request() will not
     // bootstrap again. Hence, we have to reload the newly written custom
     // settings.php manually.
     Settings::initialize(DRUPAL_ROOT, $this->siteDirectory, $this->classLoader);
 }
Example #30
0
 /**
  * @param string $path
  * @return array
  */
 public function parse($path)
 {
     $content = $this->read($path);
     $yaml = new \Symfony\Component\Yaml\Yaml();
     return $yaml->parse($content);
 }