Registers handlebars script with V8Js

This *must* be called before the first call to self::create()
@param string $source
@param boolean $runtime
182773
public static function registerHandlebarsExtension($source, $runtime = false)
    {
        if (!self::isRegistered($runtime)) {
            $extension = $runtime ? self::EXTN_RUNTIME : self::EXTN_HANDLEBARS;
            V8Js::registerExtension($extension, $source, [], false);
        }
    }
173956
public function addDataSource($name, AbstractDataSource $dataSource)
    {
        if ($this->hasDataSource($name)) {
            throw new \RuntimeException(sprintf('A previous data source exists with the same name: "%s".', $name));
        }

        $this->dataSources[$name] = $dataSource;
    }
834806
public function incrementJob($job, $runtime)
    {
        $this->connection()->eval(LuaScripts::updateMetrics(), 2,
            'job:'.$job, 'measured_jobs', str_replace(',', '.', $runtime)
        );
    }
930216
public function create(string $key = null)
    {
        if ($key) {
            $this->setStorageKey($key);
        }

        if ($this->exists()) {
            throw new \RuntimeException('Cannot create new object (Already exists)');
        }

        return $this->save();
    }
931568
public function execute()
	{
		$this->connect();

		if (!is_object($this->connection))
		{
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg)
			);
			throw new \RuntimeException($this->errorMsg, $this->errorNum);
		}

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		if ($this->limit > 0 || $this->offset > 0)
		{
			// @TODO
			$sql .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
		}

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query.
		$this->executed = false;

		if ($this->prepared instanceof \PDOStatement)
		{
			// Bind the variables:
			if ($this->sql instanceof PreparableInterface)
			{
				$bounded =& $this->sql->getBounded();

				foreach ($bounded as $key => $obj)
				{
					$this->prepared->bindParam($key, $obj->value, $obj->dataType, $obj->length, $obj->driverOptions);
				}
			}

			$this->executed = $this->prepared->execute();
		}

		// If an error occurred handle it.
		if (!$this->executed)
		{
			// Get the error number and message before we execute any more queries.
			$errorNum = (int) $this->connection->errorCode();
			$errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (\RuntimeException $e)
				// If connect fails, ignore that exception and throw the normal exception.
				{
					// Get the error number and message.
					$this->errorNum = (int) $this->connection->errorCode();
					$this->errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

					// Throw the normal query exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg)
					);
					throw new \RuntimeException($this->errorMsg, $this->errorNum);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}
			else
			// The server was not disconnected.
			{
				// Get the error number and message from before we tried to reconnect.
				$this->errorNum = $errorNum;
				$this->errorMsg = $errorMsg;

				// Throw the normal query exception.
				$this->log(
					Log\LogLevel::ERROR,
					'Database query failed (error #{code}): {message}',
					array('code' => $this->errorNum, 'message' => $this->errorMsg)
				);
				throw new \RuntimeException($this->errorMsg, $this->errorNum);
			}
		}

		return $this->prepared;
	}
191853
public function create($uri, $content)
    {
        $uri = '/' . trim($uri, '/');

        foreach ($this->patterns as $pattern => $key) {
            if (preg_match($pattern, $uri)) {
                return call_user_func($this->builders[$key], (array) $content);
            }
        }

        throw new RuntimeException(sprintf('Cannot create resource by URI "%s"', $uri));
    }
426523
protected function trigger($sql, $runtime, $options = [])
    {
        if (!empty(self::$event)) {
            foreach (self::$event as $callback) {
                if (is_callable($callback)) {
                    call_user_func_array($callback, [$sql, $runtime, $options]);
                }
            }
        }
        return null;
    }
773677
public function register()
    {
        $this->app->singleton('Feeds', function () {
            $config = config('feeds');

            if (! $config) {
                throw new \RunTimeException('Feeds configuration not found. Please run `php artisan vendor:publish`');
            }

            return new FeedsFactory($config);
        });
    }
777927
function register(handlebars) {
  handlebars.registerHelper('dynamic-include', function(templateName, context) {
    var templateFile = '_includes/' + templateName + '.hbs';
    var templateMatter = matter.read(templateFile);
    var compiledTemplate = handlebars.compile(templateMatter.content);
    var data = extend({}, context.data.root);
    Object.keys(context.hash)
            .forEach(function(key) {
              if (context.data.root[context.hash[key]]) {
                data[key] = context.data.root[context.hash[key]];
              }
            });
    return compiledTemplate(data);
  });
}
254931
public function create($alias, $source, $dependencies = [], $options = [])
    {
        $assetType = isset($options['type']) ? $options['type'] : '';

        if (isset($this->_customTypes[$assetType])) {
            $assetType = $this->_customTypes[$assetType];

        } elseif (is_callable($source)) {
            $assetType = 'Callback';

        } elseif (is_string($source)) {
            $ext = strtolower(FS::ext($source));

            if ($ext === 'js') {
                $assetType = 'JsFile';

            } elseif ($ext === 'css') {
                $assetType = 'CssFile';

            } elseif ($ext === 'less') {
                $assetType = 'LessFile';

            } elseif ($ext === 'jsx') {
                $assetType = 'JsxFile';
            }

        } elseif (is_array($source)) {
            $assetType = 'Collection';
        }

        $className = __NAMESPACE__ . '\\Asset\\' . $assetType;
        if (class_exists($className)) {
            $options = is_array($options) ? new Data($options) : $options;
            return new $className($this->getManager(), $alias, $source, $dependencies, $options);
        }

        throw new Exception('Undefined asset type: ' . print_r($source, true));
    }
47116
def runtime
      @runtime ||= ExecJS::ExternalRuntime.new(
        name:        'Node.js (V8)',
        command:     ['nodejs', 'node'],
        runner_path: File.expand_path('../runtime/runner.js', __FILE__)
        )
    end
374449
public static function compile(Context $context, Source $source, int $options = ScriptCompiler::OPTION_NO_COMPILE_OPTIONS): Script
    {
    }
145815
public function activate(): void
    {
        if ($this->stopBuffering) {
            $this->buffering = false;
        }
        if (!$this->handler instanceof HandlerInterface) {
            $record = end($this->buffer) ?: null;

            $this->handler = call_user_func($this->handler, $record, $this);
            if (!$this->handler instanceof HandlerInterface) {
                throw new \RuntimeException("The factory callable should return a HandlerInterface");
            }
        }
        $this->handler->handleBatch($this->buffer);
        $this->buffer = [];
    }
983568
public static function register($debug = TRUE, $charset = 'UTF-8') {

		if(self::$handler) {
			throw new \RuntimeException('Exception handler already registered.');
		}
		
		self::$handler = new static($debug, $charset);
			
		set_exception_handler(array(self::$handler, 'handle'));

		return self::$handler;

	}
1121374
private function initializeDataContainer($table, $field)
    {
        // Define the current ID
        if (!defined('CURRENT_ID')) {
            define('CURRENT_ID', $table ? \Session::getInstance()->get('CURRENT_ID') : $field);
        }

        static::loadDataContainer($table);

        $this->dca     = &$GLOBALS['TL_DCA'][$table];
        $driverClass   = 'DC_' . $this->dca['config']['dataContainer'];
        $dataContainer = new $driverClass($table);

        $dataContainer->field = $field;

        if (!isset($this->dca['fields'][$field]) || $this->dca['fields'][$field]['inputType'] != 'icon') {
            throw new \RuntimeException('Invalid call. Field does not exists or is not an icon wizard');
        }

        $values = $dataContainer->activeRecord->$field;

        // Call the load_callback
        if (is_array($this->dca['fields'][$field]['load_callback'])) {
            foreach ($this->dca['fields'][$field]['load_callback'] as $callback) {
                $values = $this->triggerCallback($callback, array($values, $dataContainer));
            }
        }

        // support options callback
        if (isset($this->dca['fields'][$field]['options_callback'])) {
            $this->dca['fields'][$field]['options'] = $this->triggerCallback(
                $this->dca['fields'][$field]['options_callback'],
                array($dataContainer)
            );
        }

        return $dataContainer;
    }
128584
public function onInitialize(ResourceEventInterface $event)
    {
        $page = $this->getPageFromEvent($event);

        $parent = $page->getParent();
        if ($parent && $parent->isLocked()) {
            throw new RuntimeException("Cannot create child page under a locked parent page.");
        }
    }
319869
public function _initialize(Handlebars $handlebars = null, Tables $table = null)
    {
        parent::_initialize();
        $this->tablePrefix = $this->config['tablePrefix'];
        $this->handlebars = $handlebars ?: new Handlebars();
        $this->tables = $table ?: new Tables();
    }