/**
  * Generate a random key for the application.
  *
  * @param  string $cipher
  *
  * @return string
  */
 protected function getRandomKey($cipher)
 {
     if ($cipher === 'AES-128-CBC') {
         return Str::random(16);
     }
     return Str::random(32);
 }
Exemplo n.º 2
0
 public function handle()
 {
     $name = $this->ask('Directory name');
     $displayName = $this->ask('Display name');
     $name = Str::slugify($name);
     $this->generate($name, ['config.php.stub' => 'config.php'], ['displayName' => $displayName]);
     $this->comment('All done sire!');
 }
 /**
  * callExtension method
  *
  * @private
  *
  * @param $name
  * @param $parameters
  *
  * @return mixed
  */
 protected function callExtension($name, $parameters)
 {
     $callback = static::$extensions[$name];
     if ($callback instanceof Closure) {
         return call_user_func_array($callback->bindTo($this, get_class($this)), $parameters);
     } elseif (is_string($callback) && Str::contains($callback, '@')) {
         return $this->callClassBasedExtension($callback, $parameters);
     }
 }
Exemplo n.º 4
0
 protected function callFunctionExtension($name, $parameters)
 {
     $callback = $this->extensionFunctions[$name];
     if ($callback instanceof Closure) {
         return call_user_func_array($callback->bindTo($this, get_class($this)), $parameters);
     } elseif (is_string($callback)) {
         if (Str::contains($callback, '@')) {
         }
         return $this->createClassExtension($callback, $parameters);
     }
 }
Exemplo n.º 5
0
 public function parse()
 {
     $c = new ConsoleColor();
     $o = '';
     $b = [];
     foreach ($this->attributes as $a => $v) {
         $a = Str::underscored($a);
         $b[] = $a;
         if (is_string($v)) {
             $o .= $c->apply($b, $v);
             $b = [];
         }
     }
     return $o;
 }
Exemplo n.º 6
0
 /**
  * Removes indentation
  *
  * @param string $text The markdown text
  * @return mixed
  */
 protected function transform($text)
 {
     $firstLine = explode("\n", $text, 1);
     $firstLine = Str::toSpaces($firstLine[0], 4);
     preg_match('/([\\s]*).*/', $firstLine, $firstLineSpacesMatches);
     if (isset($firstLineSpacesMatches[1])) {
         $spaceMatcher = "";
         for ($i = 0; $i < strlen($firstLineSpacesMatches[1]); $i++) {
             $spaceMatcher .= "\\s";
         }
         $spaceMatcher = '/^' . $spaceMatcher . '(.*)/m';
         $newText = preg_replace($spaceMatcher, '$1', $text);
         return $newText;
     }
     return $text;
 }
Exemplo n.º 7
0
 public function render($str, array $vars = [])
 {
     $__tmp_stub_file = Str::random() . uniqid(time(), false);
     !$this->fs->exists($this->cachePath) && $this->fs->makeDirectory($this->cachePath, 0755, true);
     $__tmp_stub_path = Path::join($this->cachePath, $__tmp_stub_file);
     $this->fs->put($__tmp_stub_path, $this->compiler->compileString($str));
     $__env = $this->getViewFactory();
     if (is_array($vars) && 0 !== count($vars)) {
         extract($vars);
     }
     ob_start();
     include $__tmp_stub_path;
     $var = ob_get_contents();
     ob_end_clean();
     $this->fs->delete($__tmp_stub_path);
     return $var;
 }
Exemplo n.º 8
0
 protected function write($content, $name = null)
 {
     $tmpDir = storage_path('blade-extensions');
     if (!$this->files->exists($tmpDir)) {
         $this->files->makeDirectory($tmpDir);
     }
     if (is_null($name)) {
         $name = Str::slugify($this->viewPath) . '__' . uniqid(time(), true);
     }
     $path = Path::join($tmpDir, $name);
     $this->files->put($path, $content);
     return [$name, $path];
 }
Exemplo n.º 9
0
 public function getSlug()
 {
     return \Sebwite\Support\Str::slug($this->getName());
 }
Exemplo n.º 10
0
 /**
  * Resolves and creates the documents menu from the parsed menu.yml
  *
  * @param array  $items The array converted from yaml
  * @param string $parentId
  *
  * @return \Codex\Core\Menus\Menu
  */
 protected function setupSidebarMenu($items, $parentId = 'root')
 {
     /**
      * @var Menus\Menu $menu
      */
     $menu = $this->getCodex()->getMenus()->add('sidebar');
     foreach ($items as $item) {
         $link = '#';
         if (array_key_exists('document', $item)) {
             // remove .md extension if present
             $path = Str::endsWith($item['document'], '.md', false) ? Str::remove($item['document'], '.md') : $item['document'];
             $link = $this->codex->url($this, $this->getRef(), $path);
         } elseif (array_key_exists('href', $item)) {
             $link = $item['href'];
         }
         $id = md5($item['name'] . $link);
         $node = $menu->add($id, $item['name'], $parentId);
         $node->setAttribute('href', $link);
         $node->setAttribute('id', $id);
         if (isset($item['icon'])) {
             $node->setMeta('icon', $item['icon']);
         }
         if (isset($item['children'])) {
             $this->setupSidebarMenu($item['children'], $id);
         }
     }
     return $menu;
 }