Ejemplo n.º 1
0
 public function handle(Document $document)
 {
     /** @var ParserInterface $parser */
     $parser = app()->build($this->config['parser']);
     $parserName = $parser->getName();
     $parserConfig = $this->config->get($parserName, []);
     $parser->setConfig($parserConfig->toArray());
     $document->setContent($parser->parse($document->getContent()));
 }
Ejemplo n.º 2
0
 public static function registerExtension($class, $name, $extension)
 {
     if (null === static::$resolved) {
         static::$resolved = new Collection();
     }
     \Illuminate\Container\Container::getInstance()->resolving($class, function ($instance) use($name, $extension) {
         $className = get_class($instance);
         $isExtended = static::$resolved->where('className', $className)->where('name', $name)->count() > 0;
         if ($isExtended) {
             return;
         }
         static::$resolved->push(compact('className', 'name'));
         forward_static_call_array($className . '::extend', [$name, $extension]);
     });
 }
Ejemplo n.º 3
0
 /**
  * Run a content processor
  *
  * @param $name
  *
  * @throws \Codex\Exception\CodexException
  */
 protected function runProcessor($name)
 {
     if ($this->processed->has($name)) {
         return;
     }
     $this->processed->set($name, $this->getProcessors()->run($name, $this));
 }
Ejemplo n.º 4
0
 protected function render($with = [])
 {
     $view = view($this->codex->view('processors.buttons'), $this->config->except('buttons', 'groups')->all())->with($with);
     return $view->render();
 }
Ejemplo n.º 5
0
 /**
  * sortAssets method
  *
  * @param array|Collection $all
  *
  * @return \Codex\Support\Collection
  */
 protected function sorter($all = [])
 {
     $all = $all instanceof Collection ? $all : new Collection($all);
     $sorter = new Sorter();
     $sorted = new Collection();
     foreach ($all as $name => $asset) {
         $sorter->addItem($asset['name'], $asset['depends']);
     }
     foreach ($sorter->sort() as $name) {
         $sorted->add($all->where('name', $name)->first());
     }
     return $sorted;
 }
Ejemplo n.º 6
0
 protected function getEnabledPlugins()
 {
     return $this->config->except('js_path', 'css_path', 'plugin_path', 'plugins')->keys()->toArray();
 }
Ejemplo n.º 7
0
 /**
  * all method
  * @return array
  */
 public function all()
 {
     return $this->items->all();
 }
Ejemplo n.º 8
0
 public function toArray()
 {
     return ['processors' => $this->processors->toArray(), 'hooks' => $this->hooks->toArray(), 'plugins' => $this->plugins->toArray(), 'views' => $this->views->toArray()];
 }
Ejemplo n.º 9
0
 /**
  * Get default ref.
  *
  * @return Ref
  */
 public function getDefault()
 {
     return $this->items->get($this->default);
 }
Ejemplo n.º 10
0
 /**
  * Offset to unset
  *
  * @link  http://php.net/manual/en/arrayaccess.offsetunset.php
  *
  * @param mixed $offset <p>
  *                      The offset to unset.
  *                      </p>
  *
  * @return void
  * @since 5.0.0
  */
 public function offsetUnset($offset)
 {
     $this->items->forget($offset);
 }