Exemplo n.º 1
0
 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @param bool $forceRefresh
  * @return \Phinx\Config\Config
  */
 public function getConfig($forceRefresh = false)
 {
     if ($this->configuration && $forceRefresh === false) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(['\\', '/', '.'], '_', $plugin);
     $connection = $this->getConnectionName($this->input);
     $connectionConfig = ConnectionManager::config($connection);
     $adapterName = $this->getAdapterName($connectionConfig['driver']);
     $config = ['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $adapterName, 'host' => isset($connectionConfig['host']) ? $connectionConfig['host'] : null, 'user' => isset($connectionConfig['username']) ? $connectionConfig['username'] : null, 'pass' => isset($connectionConfig['password']) ? $connectionConfig['password'] : null, 'port' => isset($connectionConfig['port']) ? $connectionConfig['port'] : null, 'name' => $connectionConfig['database'], 'charset' => isset($connectionConfig['encoding']) ? $connectionConfig['encoding'] : null, 'unix_socket' => isset($connectionConfig['unix_socket']) ? $connectionConfig['unix_socket'] : null]]];
     if ($adapterName === 'mysql') {
         if (!empty($connectionConfig['ssl_key']) && !empty($connectionConfig['ssl_cert'])) {
             $config['environments']['default']['mysql_attr_ssl_key'] = $connectionConfig['ssl_key'];
             $config['environments']['default']['mysql_attr_ssl_cert'] = $connectionConfig['ssl_cert'];
         }
         if (!empty($connectionConfig['ssl_ca'])) {
             $config['environments']['default']['mysql_attr_ssl_ca'] = $connectionConfig['ssl_ca'];
         }
     }
     return $this->configuration = new Config($config);
 }
 public function it_throws_exception_on_invalid_url(Input $input, Output $output)
 {
     $input->bind(Argument::any())->willReturn();
     $input->isInteractive()->willReturn(false);
     $input->validate()->willReturn();
     $input->getArgument("url")->willReturn("i_am_an_invalid_url");
     $this->shouldThrow(\Exception::class)->during("run", [$input, $output]);
 }
    /**
     * @param Input $input
     */
    public function __invoke(Input $input)
    {
        $this->climate->br();
        $name = $input->getArgument('name');
        if (FALSE === strstr($name, '/')) {
            $name = 'middleout/arhitect-' . $name;
        }
        $ownerName = explode('/', $name);
        $packageName = $ownerName[1];
        $ownerName = $ownerName[0];
        $this->climate->yellow('Installing Arhitect Package ' . $ownerName . '/' . $packageName);
        $version = '';
        $inputVersion = $input->getArgument('version');
        if ($inputVersion) {
            $version = ':' . $inputVersion;
        }
        $preferDev = ' require ';
        $inputVersion = $input->getOption('dev');
        if ($inputVersion) {
            $preferDev = ' require --dev ';
        }
        $this->climate->darkGray("composer" . $preferDev . $name . $version . ' --prefer-dist');
        $result = shell_exec("composer" . $preferDev . $name . $version . ' --prefer-dist');
        $this->climate->yellow($result);
        $configOwnerName = $ownerName;
        $configPackageName = $packageName;
        if ($configOwnerName == 'middleout') {
            $configOwnerName = 'arhitect';
            $configPackageName = str_replace('arhitect-', '', $configPackageName);
        }
        $path = getcwd() . '/vendor/' . $ownerName . '/' . $packageName . '/app/config';
        $path = str_replace('config/middleout/arhitect-', 'config/arhitect/', $path);
        if (is_dir($path)) {
            $this->copy($path, $this->configuration->getApplicationPath() . '/config/' . $configOwnerName);
        }
        $readme = getcwd() . '/vendor/' . $ownerName . '/' . $packageName . '/post-install.md';
        if (is_file($readme)) {
            $postInstallMessage = file_get_contents($readme);
        }
        $this->climate->br(2);
        if (!$postInstallMessage) {
            $this->climate->green(<<<ART
               ______________________________________
      ________|                                      |_______
      \\       |            MODULE INSTALLED          |      /
       \\      |    Let the coding session begin !    |     /
       /      |______________________________________|     \\
      /__________)                                (_________\\

ART
);
        } else {
            $this->climate->green('Module installed. The developer would like to tell you the following:');
            $this->climate->br(2);
            $this->climate->yellow($postInstallMessage);
        }
        $this->climate->br(2);
    }
 private function executeCommand(Command $command, Input $input)
 {
     $command->setApplication($this->application);
     $input->setInteractive(false);
     if ($command instanceof ContainerAwareCommand) {
         $command->setContainer($this->client->getContainer());
     }
     $command->run($input, new NullOutput());
 }
Exemplo n.º 5
0
 /**
  * @param Input $input
  */
 public function __invoke(Input $input)
 {
     $file = NULL;
     $testSuite = $input->getArgument('testSuite');
     if (FALSE !== strstr($testSuite, '.php')) {
         $file = $testSuite;
         $testSuite = NULL;
     }
     $debug = (bool) $input->getArgument('debug');
     passthru("phpunit -c app/config/arhitect/phpunit.xml " . ($testSuite ? '--testsuite ' . $testSuite : '') . ($file ? $file : '') . ($debug ? ' --debug' : ''));
     $this->climate->green('Tests have run!');
 }
Exemplo n.º 6
0
    /**
     * @param Input $input
     */
    public function __invoke(Input $input)
    {
        $this->climate->br();
        $name = $input->getArgument('name');
        if (FALSE === strstr($name, '/')) {
            $name = 'middleout/arhitect-' . $name;
        }
        $ownerName = explode('/', $name);
        $packageName = $ownerName[1];
        $ownerName = $ownerName[0];
        $this->climate->yellow('Updating Arhitect Package ' . $ownerName . '/' . $packageName);
        $version = '';
        $inputVersion = $input->getArgument('version');
        if ($inputVersion) {
            $version = ':' . $inputVersion;
        }
        $preferDev = ' require ';
        $inputVersion = $input->getOption('dev');
        if ($inputVersion) {
            $preferDev = ' require --dev ';
        }
        $this->climate->darkGray("composer" . $preferDev . $name . $version . ' --prefer-dist');
        $result = shell_exec("composer" . $preferDev . $name . $version . ' --prefer-dist');
        $this->climate->yellow($result);
        $configOwnerName = $ownerName;
        $configPackageName = $packageName;
        if ($configOwnerName == 'middleout') {
            $configOwnerName = 'arhitect';
            $configPackageName = str_replace('arhitect-', '', $configPackageName);
        }
        $path = getcwd() . '/vendor/' . $ownerName . '/' . $packageName . '/app/config/' . $configOwnerName . '/' . $configPackageName;
        $path = str_replace('config/middleout/arhitect-', 'config/arhitect/', $path);
        if (is_dir($path)) {
            $this->copy($path, $this->configuration->getApplicationPath() . '/config/' . $configOwnerName . '/' . $configPackageName);
        }
        $this->climate->br(2);
        $this->climate->green(<<<ART
           ______________________________________
  ________|                                      |_______
  \\       |            MODULE UPDATED            |      /
   \\      |  Let the coding session continue :)  |     /
   /      |______________________________________|     \\
  /__________)                                (_________\\

ART
);
        $this->climate->br(2);
    }
Exemplo n.º 7
0
 public function update_article()
 {
     $data = Input::all();
     unset($data['_token']);
     $estate = Article::find($data['article_id'])->update($data);
     return redirect()->back()->with('message', "Новость \"{$article->title}\" #{$article->article_id} изменена успешно!");
 }
Exemplo n.º 8
0
 public static function getVariable(Input $input = null, $default = '', $optionName = false, $envName = false)
 {
     $value = null;
     if ($optionName && $input && $input->hasOption($optionName)) {
         $value = $input->getOption($optionName);
     }
     if ($value === null) {
         if ($envName) {
             $value = getenv($envName);
         }
         if (!$value) {
             $value = $default;
         }
     }
     return $value === null ? '' : $value;
 }
Exemplo n.º 9
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     if (!Input::get('name') or !Input::get('done') or !Input::get('priority')) {
         return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY)->respondWithError('Parameters failed validation for a tag.');
     }
     Tag::create(Input::all());
     return $this->respondCreated('Tag successfully created.');
 }
Exemplo n.º 10
0
 public function __construct(array $argv = null, InputDefinition $definition = null)
 {
     if (null === $argv) {
         $argv = $_SERVER['argv'];
     }
     array_shift($argv);
     $this->tokens = $argv;
     parent::__construct($definition);
 }
 public function testExecuteWrongNameSpecified()
 {
     $this->expectContainerGetManagerRegistryAndProcessHandler();
     $id = 1;
     $this->input->expects($this->exactly(2))->method('getOption')->willReturnMap([['id', $id], ['name', 'wrong_name']]);
     $processTrigger = $this->createProcessTrigger($id);
     $this->repo->expects($this->once())->method('find')->with($id)->willReturn($processTrigger);
     $this->processHandler->expects($this->never())->method($this->anything());
     $this->command->execute($this->input, $this->output);
     $this->assertAttributeEquals(['Trigger not found in process definition "wrong_name"'], 'messages', $this->output);
 }
Exemplo n.º 12
0
 /**
  * Constructor.
  *
  * @param array           $argv       An array of parameters from the CLI (in the argv format)
  * @param InputDefinition $definition A InputDefinition instance
  *
  * @api
  */
 public function __construct(InputDefinition $definition = null, $removeOptions = false, $strict = false)
 {
     $argv = $_SERVER['argv'];
     // strip the application name
     array_shift($argv);
     // strip the command name
     $this->commandName = array_shift($argv);
     $this->tokens = $argv;
     $this->removeOptions = (bool) $removeOptions;
     $this->strict = (bool) $strict;
     parent::__construct($definition);
 }
Exemplo n.º 13
0
 /**
  * Renders a template $template into $outputFile with the given templates directory $templates and input $data.
  *
  * @param Input $input
  * @param string $outputFile
  * @param string $template
  * @param string $templates
  * @param array $data
  */
 protected function renderTemplate($input, $outputFile, $template, $templates, $data = [])
 {
     $paths = [$templates];
     if ($templates = $input->getOption('templates')) {
         $paths[] = $templates;
     }
     $paths = array_filter($paths);
     $loader = new Twig_Loader_Filesystem($paths);
     $twig = new Twig_Environment($loader);
     $template = $twig->loadTemplate($template);
     $dataOption = $input->getOption('data');
     if (file_exists($dataOption)) {
         $dataOption = file_get_contents($dataOption);
     }
     $dataOption = json_decode(stripcslashes($dataOption), true);
     if (!is_array($dataOption)) {
         $dataOption = [];
     }
     $data = array_merge($data, $dataOption);
     @mkdir(dirname($outputFile), 0755, true);
     file_put_contents($outputFile, $template->render($data));
 }
Exemplo n.º 14
0
 /**
  * Constructor.
  *
  * @param array $parameters An array of parameters
  * @param InputDefinition $definition A InputDefinition instance
  */
 public function __construct(array $parameters, InputDefinition $definition = null)
 {
     $this->parameters = $parameters;
     parent::__construct($definition);
 }