use Client\Project; use Client\Console; return array('arg0' => 'db:seed', 'command' => 'db:seed [<seed-file>]', 'description' => 'Seed collections from YAML files.', 'run' => function ($args) use($commands) { $seed_file = '*.yaml'; if ($args[1] !== null) { $seed_file = $args[1] . '.yaml'; } $client = new Client(); foreach (Utils::glob(Project::root(Project::DIRECTORY_NAME) . '/seeds/' . $seed_file) as $yaml_file) { $collection = basename($yaml_file, '.yaml'); $parser = new Symfony\Component\Yaml\Parser(); $options = $parser->parse(file_get_contents($yaml_file)); if (isset($options['truncate']) && $options['truncate']) { echo "Truncating '{$collection}'... "; try { $truncate = $client->delete('collection/' . $collection); if (count($truncate) > 0) { echo "Success."; } } catch (Exception $e) { echo "Failed."; } echo PHP_EOL; } if (isset($options['data']) && $options['data']) { $current_row = 0; $total_rows = count($options['data']); foreach ($options['data'] as $data) { // Look for special data fields foreach ($data as $field => $value) { if (preg_match('/\\!upload ([^$]+)/', $value, $file)) {
<?php use Client\Client; use Client\Project; use Client\Console; return array('arg0' => 'cache:clear', 'command' => 'cache:clear', 'description' => 'Clear application cache.', 'run' => function ($args) use($commands) { $client = new Client(); $response = $client->delete("apps/cache"); if ($response->success) { Console::output("Cache cleared successfully."); } else { throw new Exception("Some error ocurred when clearing the cache."); } });