/** * Method to test quote(). * * @return void * * @covers Windwalker\String\StringHelper::quote */ public function testQuote() { $this->assertEquals('"foo"', StringHelper::quote('foo')); $this->assertEquals('"foo"', StringHelper::quote('foo', '"')); $this->assertEquals('"foo"', StringHelper::quote('foo', array('"', '"'))); $this->assertEquals('[foo]', StringHelper::quote('foo', array('[', ']'))); }
/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @since 1.0 * @throws \LogicException * @throws \RuntimeException */ public function execute() { // Flip src & dest $dest = $this->config['path.src']; $src = $this->config['path.dest']; $this->config['path.src'] = $src; $this->config['path.dest'] = $dest; // Flip replace array $this->replace = array_flip($this->replace); // Quote by tag variable foreach ($this->replace as &$replace) { $replace = StringHelper::quote($replace, (array) $this->config['tag.variable']); } $this->doAction(new Action\ConvertAction()); }
/** * Do this execute. * * @return mixed */ protected function doExecute() { /** @var CopyOperator $copyOperator */ $copyOperator = $this->container->get('operator.factory')->getOperator('copy'); $src = $this->config['dir.src']; $dest = $this->config['dir.dest']; $list = StringHelper::quote('controller.list.name.cap', $this->config['tagVariables']); $files = array('Controller/%s', 'Field', 'Form/%s', 'Model/%sModel.php.tpl', 'Templates/' . StringHelper::quote('controller.list.name.lower', $this->config['tagVariables']), 'View/%s'); foreach ($files as $file) { $file = sprintf($file, $list); if (!file_exists($src . '/' . $file)) { continue; } $copyOperator->copy($src . '/' . $file, $dest . '/' . $file, $this->config['replace']); } }
/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { $this->config['item_name'] = StringHelper::quote('controller.item.name.cap', $this->config['tagVariables']); $this->config['list_name'] = StringHelper::quote('controller.list.name.cap', $this->config['tagVariables']); $this->doAction(new Subsystem\PrepareAction()); $this->doAction(new Subsystem\CopyItemAction()); // Some dirty things handling $this->doAction(new AddTableNameAction()); $this->doAction(new CopyMigrationAction()); $this->doAction(new AddSeederAction()); if ($this->config['migrate']) { $this->doAction(new MigrateAction()); if ($this->config['seed']) { $this->doAction(new SeedAction()); } } }
/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @since 1.0 * @throws \LogicException * @throws \RuntimeException */ public function execute() { // Flip replace string and path because we are converting code back to template. // Flip src & dest $dest = $this->config['path.src']; $src = $this->config['path.dest']; $this->config['path.src'] = $src; $this->config['path.dest'] = $dest; // Flip replace array $this->replace = array_flip($this->replace); // Quote by tag variable foreach ($this->replace as &$replace) { $replace = StringHelper::quote($replace, (array) $this->config['tag.variable']); } // Do it now. $this->doAction(new Action\ConvertAction()); }
/** * Do this execute. * * @return mixed */ protected function doExecute() { /** @var ConvertOperator $operator */ $operator = $this->container->get('operator.factory')->getOperator('convert'); $replace = ArrayHelper::flatten($this->replace); // Flip replace array because we want to convert template. $replace = array_flip($replace); foreach ($replace as &$val) { $val = StringHelper::quote($val, $operator->getTagVariable()); } // Flip src and dest because we want to convert template. $src = $this->config['dir.src']; $dest = $this->config['dir.dest']; if (is_dir($dest)) { // Remove dir first Folder::delete($dest); } $operator->copy($src, $dest, $replace); }
/** * normalizeBacktrace * * @param array $trace * * @return array */ public static function normalizeBacktrace(array $trace) { $trace = new Data($trace); $args = []; foreach ($trace['args'] as $arg) { if (is_array($arg)) { $arg = 'Array'; } elseif (is_object($arg)) { $arg = ReflectionHelper::getShortName($arg); } elseif (is_string($arg)) { if (Utf8String::strlen($arg) > 20) { $arg = Utf8String::substr($arg, 0, 20) . '...'; } $arg = StringHelper::quote($arg); } elseif (is_null($arg)) { $arg = 'NULL'; } elseif (is_bool($arg)) { $arg = $arg ? 'TRUE' : 'FALSE'; } $args[] = $arg; } return array('file' => $trace['file'] ? $trace['file'] . ' (' . $trace['line'] . ')' : null, 'function' => ($trace['class'] ? $trace['class'] . $trace['type'] : null) . $trace['function'] . sprintf('(%s)', implode(', ', $args))); }