Generate a HTML API.

@param array $options
@param bool  $fromGenerate

@throws ConfigException
@throws Exception
761730
public function api(array $options = [], $fromGenerate = false)
    {
        if (!$fromGenerate) {
            $this->generate();
        }

        $templatesPath = $this->templatesPath;
        if (null === $templatesPath) {
            // fallback
            $templatesPath = \dirname(__DIR__).'/templates';
        }

        $documentator = new Documentation($this->files, $this->config, $templatesPath, $options);
        $documentator->setLogger($this->logger);

        $this->logger->info('Generating API into '.$documentator->getOutputDirectory());
        $documentator->build();
    }
608481
private function createRouteGenerator($options = array())
    {
        $options = array_replace(array(
                'routeName'     => null,
                'routeParams'   => array(),
                'pageParameter' => '[page]',
            ), $options);

        $router = $this->container->get('router');

        if (null === $options['routeName']) {
            $request = $this->container->get('request');

            $options['routeName'] = $request->attributes->get('_route');
            if ('_internal' === $options['routeName']) {
                throw new \Exception('PagerfantaBundle can not guess the route when used in a subrequest');
            }
            
            // make sure we read the route parameters from the passed option array            
            $defaultRouteParams = array_merge($request->query->all(), $request->attributes->get('_route_params'));

            if (array_key_exists('routeParams', $options)) {
                $options['routeParams'] = array_merge($defaultRouteParams, $options['routeParams']);
            } else {
                $options['routeParams'] = $defaultRouteParams;
            }   
        }

        $routeName = $options['routeName'];
        $routeParams = $options['routeParams'];
        $pagePropertyPath = new PropertyPath($options['pageParameter']);

        return function($page) use($router, $routeName, $routeParams, $pagePropertyPath) {
            $propertyAccessor = PropertyAccess::getPropertyAccessor();
            $propertyAccessor->setValue($routeParams, $pagePropertyPath, $page);

            return $router->generate($routeName, $routeParams);
        };
    }
975098
public function fromArray($options)
    {
        if (isset($options['InsertSlateOnAdMarker'])) {
            Validate::isBoolean($options['InsertSlateOnAdMarker'], 'options[InsertSlateOnAdMarker]');
            $this->_insertSlateOnAdMarker = (bool) $options['InsertSlateOnAdMarker'];
        }

        if (isset($options['DefaultSlateAssetId'])) {
            Validate::isString($options['DefaultSlateAssetId'], 'options[DefaultSlateAssetIdUrl]');
            $this->_defaultSlateAssetId = $options['DefaultSlateAssetId'];
        }
    }
737570
public function generate($markup, $options = array()) {
        // 1 - write the content to the temp file
        $tempPath = $this->tempDirectory . '/' . uniqid();
        $tempPathOut = $tempPath . '-output';

        if( $markup instanceof MarkupInterface ) {
            $content = $markup->getContent();
        } else {
            $content = $markup;
        }

        // Store the content to the proper file
        file_put_contents($tempPath, $content);

        // Start building the command line
        $arguments = array('rst2html');

        if( $this->templatePath !== null ) {
            $arguments []= '--template=' . $this->templatePath;
        }

        if( $this->syntaxHighlight !== null ) {
            $arguments []= '--syntax-highlight=' . $this->syntaxHighlight;
        }

        if( $this->noSourceLinks != false ) {
            $arguments []= '--no-source-link';
        }

        if( $this->quiet != false ) {
            $arguments []= '--quiet';
        }

        if( $this->noDebug != false ) {
            $arguments []= '--no-debug';
        }

        $arguments []= $tempPath;
        $arguments []= $tempPathOut;

        // Get the builder
        $builder = new ProcessBuilder($arguments);

        // Build the process
        $process = $builder->getProcess();
        $process->setTimeout(3600);

        // Execute
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return file_get_contents($tempPathOut);
    }
892255
function (data, option, callback) {
    var html = '';
    var self = this;
    var fn = self.fn;
    var config = self.config;
    if (typeof option === 'function') {
      callback = option;
      option = null;
    }
    option = option || {};
    callback = callback || function (error, ret) {
      if (error) {
        if (!(error instanceof Error)) {
          error = new Error(error);
        }
        throw error;
      }
      html = ret;
    };
    var name = self.config.name;
    if (!name && fn && fn.TPL_NAME) {
      name = fn.TPL_NAME;
    }
    var scope;
    if (data instanceof Scope) {
      scope = data;
    } else {
      scope = new Scope(data);
    }
    var buffer = new XTemplateRuntime.LinkedBuffer(callback, config).head;
    var tpl = new TplWrap(name, {
      commands: option.commands
    }, self, scope, buffer, name, fn);
    buffer.tpl = tpl;
    if (!fn) {
      config.loader.load(tpl, function (err, fn) {
        if (fn) {
          tpl.fn = self.fn = fn;
          renderTpl(tpl);
        } else if (err) {
          buffer.error(err);
        }
      });
      return html;
    }
    renderTpl(tpl);
    return html;
  }
1195053
public function stubs($fromGenerate = false)
    {
        if (!$fromGenerate) {
            $this->generate();
        }

        $this->logger->info('Generating stubs...');
        $stubsGenerator = new Stubs\Generator($this->files, $this->config);

        $path = $this->config->get('path', 'stubs');
        $path = str_replace('%version%', $this->config->get('version'), $path);
        $path = str_replace('%namespace%', ucfirst($this->config->get('namespace')), $path);

        $stubsGenerator->generate($path);
    }
674425
public function loadHtml($html, $options = null)
    {
        return $this->load($html, false, Document::TYPE_HTML, $options);
    }
36670
public function setOptions(array $options)
    {
        if (isset($options['label'])) {
            $this->setLabel($options['label']);
        }

        if ($this instanceof FormElementInterface) {
            if (isset($options['defaultValue'])) {
                $this->setDefaultValue($options['defaultValue']);
            }

            if (isset($options['properties'])) {
                foreach ($options['properties'] as $key => $value) {
                    $this->setProperty($key, $value);
                }
            }
        }

        if (isset($options['rendererClassName'])) {
            $this->setRendererClassName($options['rendererClassName']);
        }

        if (isset($options['renderingOptions'])) {
            foreach ($options['renderingOptions'] as $key => $value) {
                $this->setRenderingOption($key, $value);
            }
        }

        if (isset($options['validators'])) {
            foreach ($options['validators'] as $validatorConfiguration) {
                $this->createValidator($validatorConfiguration['identifier'], isset($validatorConfiguration['options']) ? $validatorConfiguration['options'] : []);
            }
        }

        FormArrays::assertAllArrayKeysAreValid($options, array('label', 'defaultValue', 'properties', 'rendererClassName', 'renderingOptions', 'validators'));
    }
328365
public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS)
    {
        $override = (boolean) ($options & self::TRANSLATION_OVERRIDE);

        if (!$to->hasTranslation() || ($from->hasTranslation() && $override)) {
            $to->setTranslation($from->getTranslation());
        }

        if (!$to->hasPlural() || ($from->hasPlural() && $override)) {
            $to->setPlural($from->getPlural());
        }

        if (!$to->hasPluralTranslations() || ($from->hasPluralTranslations() && $override)) {
            $to->setPluralTranslations($from->getPluralTranslations());
        }
    }
1274240
public function fromOptions(array $options)
    {
        $this->seo = $this->setupSeo($options);
        if (null !== $this->seo) {
            $this->language = $this->seo->getLanguage();
            $this->page = $this->seo->getPage();
        }
    }
1195890
public static void configureGenerator(UriInfo uriInfo, JsonGenerator generator, boolean isDev) {
        MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
        String pretty = params.getFirst("pretty");
        if ("false".equalsIgnoreCase(pretty)) {
            generator.setPrettyPrinter(null);
        } else if (pretty != null && !"false".equalsIgnoreCase(pretty) || isDev) {
            generator.useDefaultPrettyPrinter();
        }
        String unicode = params.getFirst("unicode");
        if (unicode != null && !"false".equalsIgnoreCase(unicode)) {
            generator.enable(JsonGenerator.Feature.ESCAPE_NON_ASCII);
        }
    }
786675
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
    {
        $isCrud = $input->getOption('is-crud');
        
        $formClassNameDetails = $generator->createClassNameDetails(
            $input->getArgument('name'),
            'GraphQL\\Type',
            'Type'
        );

        $formFields = ['fieldFame'];
        $boundClass = $input->getArgument('bound-class');
        $uses = [];
        $boundClassDetails = $generator->createClassNameDetails(
            $boundClass,
            'Entity\\'
        );

        $doctrineEntityDetails = $this->entityHelper->createDoctrineDetails($boundClassDetails->getFullName());
        if (null !== $doctrineEntityDetails) {
            $formFields = $this->mapScalarFields($doctrineEntityDetails->getDisplayFields());

            foreach ($formFields as $fieldUse){
                $uses[$fieldUse['fieldType']] = $fieldUse['fieldType'];
            }
        }

        $boundClassVars = [
            'bounded_class_name' => $boundClassDetails->getShortName(),
            'bounded_full_class_name' => $boundClassDetails->getFullName(),
        ];
    
        $generator->generateClass(
            $formClassNameDetails->getFullName(),
            dirname(dirname(__FILE__)) . '/Resources/skeleton/Type.tpl.php',
            array_merge(
                [
                    'formFields' => $formFields,
                    'uses' => $uses
                ],
                $boundClassVars
            )
        );
    
        $generator->writeChanges();
        
        if(!empty($isCrud)) {
            $serviceClassNameDetails = $this->createService($boundClassVars, $boundClassVars, $input, $generator);
            $resolvers = [
                [
                    'namespace' => 'Query',
                    'suffix' => 'Find',
                    'template' =>  'Resolver.tpl.php',
                ],
                [
                    'namespace' => 'Mutation',
                    'suffix' => 'Create',
                    'template' =>  'Resolver.tpl.php',
                ],
                [
                    'namespace' => 'Mutation',
                    'suffix' => 'Update',
                    'template' =>  'Resolver.tpl.php',
                ],
                [
                    'namespace' => 'Mutation',
                    'suffix' => 'Delete',
                    'template' =>  'Resolver.tpl.php',
                ]
            ];
    
            $actions = [];
            foreach ($resolvers as $resolver) {
                $suffix = $resolver['suffix'] ?? '';
                $queryClassNameDetails = $generator->createClassNameDetails(
                    $input->getArgument('name').$suffix,
                    'GraphQL\\'.$resolver['namespace'].'\\' . $input->getArgument('name')
                );
        
                $generator->generateClass(
                    $queryClassNameDetails->getFullName(),
                    dirname(dirname(__FILE__)) . '/Resources/skeleton/'.$resolver['template'],
                    [
                        'suffix' => $suffix,
                        'entityFullName' => $boundClassDetails->getFullName(),
                        'entityName' => $boundClassDetails->getShortName(),
                        'serviceFullName' => (empty($serviceClassNameDetails))?:$serviceClassNameDetails->getFullName(),
                        'serviceName' => (empty($serviceClassNameDetails))?:$serviceClassNameDetails->getShortName(),
                        'isMutation' => ($resolver['namespace'] == 'Mutation') ? true : false,
                        'form_class_name' => $formClassNameDetails->getShortName(),
                        'form_full_class_name' => $formClassNameDetails->getFullName(),
                        'bounded_class_name' => $boundClassDetails->getShortName(),
                    ]
                );
        
                $actions[$resolver['namespace']][] = [
                    'fullName' => $queryClassNameDetails->getFullName(),
                    'shortName' => Str::getShortClassName($queryClassNameDetails->getFullName())
                ];
        
                $generator->writeChanges();
            }
    
            foreach ($actions as $type => $action){
                $this->registerQueries(
                    $type,
                    $action,
                    $generator
                );
            }
        }
        
        $this->writeSuccessMessage($io);
        $io->text(
            [
                'Next: Create custom query to your type and start using it.',
                'To create custom query or mutation use "maker:graphql:query"',
            ]
        );
    }
80080
public function buildTreeHtml($keys = [], $items = [], $config = [], $selected = []) {
        $configDefault = [
            'id' => 'nestable',
            'class' => 'dd',
            'containerClass' => 'dd-list',
            'itemClass' => 'dd-item',
            'labelClass' => 'dd-handle',
            'actions' => [],
        ];
        $config = array_merge($configDefault, $config);

        // root items
        $asRoot = false;
        if (empty($items)) {
            $asRoot = true;
            $items[] = [
                '_id' => $this->owner->getAttribute('_id'),
                'name' => $this->owner->getAttribute('name'),
                'lft' => $this->owner->getAttribute($this->leftAttribute),
                'rgt' => $this->owner->getAttribute($this->rightAttribute),
            ];
            $children = $this->children()->all();
            foreach ($children as $child) {
                $items[] = [
                    '_id' => $child->owner->getAttribute('_id'),
                    'name' => $child->owner->getAttribute('name'),
                    $this->leftAttribute => $child->owner->getAttribute($this->leftAttribute),
                    $this->rightAttribute => $child->owner->getAttribute($this->rightAttribute),
                ];
            }
            $keys = $this->buildTreeKeys($items);
        }
        
        $list = Html::beginTag('ol', ['class' => $config['containerClass']]);
        foreach ($keys as $key => $row) {
            if (isset($config['actions'])) {
                $actions = str_replace ('{_id}', $items[$key]['_id'], $config['actions']);

                if (is_array($selected) && in_array($items[$key]['_id'], $selected)) {
                    $actions = str_replace ('{check}', 'checked', $actions);
                }
            }

            if (count($row)) {
                $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name']  . '</div>' . $this->buildTreeHtml($row, $items, $config, $selected), ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]);
            } else {
                $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name'] . '</div>', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]);
            }
        }
        $list .= Html::endTag('ol');

//        if (strpos($list, Html::beginTag('li', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']])) === false) {
//            $list = '';
//        }
        
        if ($asRoot){
            $list = Html::tag('div', $list, ['id' => $config['id'], 'class' => $config['class']]);
        }
        return $list;
    }
879725
function UI(options) {
  if (!(this instanceof UI)) {
    var ui = Object.create(UI.prototype);
    UI.apply(ui, arguments);
    return ui;
  }
  debug('initializing from <%s>', __filename);
  this.options = utils.createOptions(options);
  this.appendedLines = 0;
  this.height = 0;
  this.initInterface();
}
1045714
function getGeneratorConfig(options) {
  const { tag, classNames } = parseSelector(options.baseSelector)
  const config = {
    files           : options.paths,
    dest            : options.outputDir,
    types           : options.types,
    codepoints      : options.codepointsMap,
    startCodepoint  : options.startCodepoint || 0xF101,
    cssDest         : options.cssPath,
    cssFontsUrl     : getCssFontsUrl(options),
    htmlDest        : options.htmlPath,
    cssTemplate     : options.cssTemplate  || TEMPLATES.css,
    htmlTemplate    : options.htmlTemplate || TEMPLATES.html,
    templateOptions : {
      baseTag             : tag || options.baseTag || 'i',
      baseSelector        : options.baseSelector || null,
      baseClassNames      : classNames.join(' '),
      classPrefix         : (options.classPrefix || 'icon') + '-',
      htmlCssRelativePath : path.relative(
        path.dirname(getResolvedPath(options, 'html')),
        getResolvedPath(options, 'css')
      )
    }
  }

  // Normalise and add available optional configurations
  OPTIONAL_PARAMS.forEach(key => {
    if (typeof options[key] !== 'undefined') {
      // Parse numeric values
      if (`${ parseFloat(options[key]) }` === `${ options[key] }`) {
        options[key] = parseFloat(options[key])
      }

      config[key] = options[key]
    }
  })

  return config
}
1265200
private function generateMessageBody($from, $number, $composeMessage)
    {
        $aux = [
            'from'           => $from,
            'to'             => $number['number'],
            'msg'            => $composeMessage,
            'callbackOption' => $this->callbackOption,
        ];

        if (!is_null($number['carrier'])) {
            $aux['id'] = $number['carrier'];
        }

        return $aux;
    }
871459
protected function render($template, array $params = array(), array $options = array())
    {
        $renderer = $this->serviceLocator->get('templating');

        // Helpers
        if (isset($options['helpers'])) {
            foreach ($options['helpers'] as $helper) {
                $renderer->addHelper($helper);
            }
        }

        return $renderer->render($template, $params);
    }