示例#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()));
 }
示例#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]);
     });
 }
示例#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));
 }
示例#4
0
 protected function render($with = [])
 {
     $view = view($this->codex->view('processors.buttons'), $this->config->except('buttons', 'groups')->all())->with($with);
     return $view->render();
 }
示例#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;
 }
示例#6
0
 protected function getEnabledPlugins()
 {
     return $this->config->except('js_path', 'css_path', 'plugin_path', 'plugins')->keys()->toArray();
 }
 /**
  * all method
  * @return array
  */
 public function all()
 {
     return $this->items->all();
 }
示例#8
0
 public function toArray()
 {
     return ['processors' => $this->processors->toArray(), 'hooks' => $this->hooks->toArray(), 'plugins' => $this->plugins->toArray(), 'views' => $this->views->toArray()];
 }
示例#9
0
 /**
  * Get default ref.
  *
  * @return Ref
  */
 public function getDefault()
 {
     return $this->items->get($this->default);
 }
示例#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);
 }