Open given block if it is valid.

@param string $name
@param array  $args
969142
public function open($name, array $args = [])
    {
        if (! is_string($name)) {
            throw new InvalidArgumentException('Foil block name must be in a string.');
        }
        if (! array_key_exists($name, $this->blocks)) {
            throw new InvalidArgumentException("{$name} is not a registered Foil block.");
        }
        /** @var \Foil\Blocks\Block $buffer */
        $buffer = $this->blocks[$name];
        $buffer->open($args);
        $this->buffers->push([$buffer, $name]);
    }
555798
protected function invokeCommand($command_name, array $args = []) {
    $this->invokeDepth++;

    if (!$this->isCommandDisabled($command_name)) {
      /** @var \Acquia\Blt\Robo\Application $application */
      $application = $this->getContainer()->get('application');
      $command = $application->find($command_name);

      $input = new ArrayInput($args);
      $input->setInteractive($this->input()->isInteractive());
      $prefix = str_repeat(">", $this->invokeDepth);
      $this->output->writeln("<comment>$prefix $command_name</comment>");
      $exit_code = $application->runCommand($command, $input, $this->output());
      $this->invokeDepth--;

      // The application will catch any exceptions thrown in the executed
      // command. We must check the exit code and throw our own exception. This
      // obviates the need to check the exit code of every invoked command.
      if ($exit_code) {
        throw new BltException("Command `$command_name {$input->__toString()}` exited with code $exit_code.");
      }
    }
  }
805536
public function block($name)
    {
        $this->currentBlock = $name;

        $this->getBlockQueue()->push($name);

        // Start an output buffer.
        ob_start();
    }
99514
protected function format($name, array $args = null)
    {
        $result = ['name' => $name];
        if ($args !== null) {
            $result['args'] = $args;
        }

        return $result;
    }
1348578
protected function cutArgument($name, &$args)
    {
        if (isset($args[$name])) {
            $result = $args[$name];
            unset($args[$name]);
            return $result;
        }

        return null;
    }
1356965
public function toRoute($name, array $args = [], $code = 307)
    {
        $to = $this->getRoute($name, $args);

        header("location: {$to}", true, $code);
        exit;
    }
184727
private function _openFile($toWrite, $extension, $name)
    {
        $shp_name = $this->_getFilename($extension);
        $result = @fopen($shp_name, ($toWrite ? 'wb+' : 'rb'));
        if (! $result) {
            $this->setError(sprintf('It wasn\'t possible to open the %s file "%s"', $name, $shp_name));

            return false;
        }

        return $result;
    }
1251451
public static function render($name, $args = array())
    {
        global $PPHP;

        array_merge_assoc(
            self::$_stash,
            $args,
            array(
                'config' => $PPHP['config'],
                'session' => $_SESSION,
                'req' => grab('request')
            )
        );
        try {
            self::$_safeBody .= self::$_twig->render($name, self::$_stash);
        } catch (\Exception $e) {
            echo $e->getMessage();
        };
    }
482865
protected function process_block_rule($name, $block) {
        $this->rulestack[] = array('callback' => method_exists($this, $name."_block_rule") ? $name."_block_rule" : null, 'rule' => $block);

        $this->string = preg_replace_callback($block['expression'], array($this, 'block_callback'), $this->string);

        array_pop($this->rulestack);
    }
483957
protected function delegate($name, ...$args)
    {
        if (!count($args)) {
            $args[] = $this->getData();
        }

        $name = str_replace('.', '_', $name);

        $name = StringNormalise::toCamelCase($name);

        if (is_callable([$this, $name])) {
            return $this->$name(...$args);
        }

        return null;
    }
957034
private function enablePragma($name)
    {
        $this->pragmas[$name] = true;

        switch ($name) {
            case Mustache_Engine::PRAGMA_BLOCKS:
                $this->pragmaBlocks = true;
                break;

            case Mustache_Engine::PRAGMA_FILTERS:
                $this->pragmaFilters = true;
                break;
        }
    }
1334030
public function render($name, $args = []) {

        if(strstr($name, '::')) {

            $name = explode('::', $name);
        
        } else {

            $name = [$name, strtolower($name)];
        }


        if($this->set('module[controller]', $name[0])) {

            $module = $this->get('module');

            if(isset($module['name'])) {

                ob_start();

                if(method_exists($instance = $this->controller($module['name'], $name[0]), $name[1])) {

                    if($ref = new \ReflectionMethod($instance, $name[1])) {

                        $ref->invokeArgs($instance, $args);
                    }
                }

                $content = ob_get_contents();

                ob_end_clean();


                return $content;
            }
        }
    }
601880
public function addQuery($name, $args)
    {
        $name = $this->snakeCase($name);

        $this->query[$name] = $args[0];

        return $this;
    }
1226867
public function render($name, array $args = array())
    {
        if ($this->has($name)) {
            $callback = $this->widgets[$name];

            return $this->executeCallback($callback, $args);
        }

        return '';
    }
45
public function checks($name, $arg = null) {
        if (empty($arg)) {
            $this->checks[] = $name;
        } else {
            $this->checks[$name] = $arg;
        }
        return $this;
    }
846028
public function execute($name, $args)
	{
	    if (!$this->__sock) {
	        return null;
	    }
	    
	    $args = (array) $args;
	    if(in_array($name, static::$keyCommands)) {
	        if ($this->options['prefix'] && strpos($args[0], $this->options['prefix']) === false) {
	            $args[0] = $this->options['prefix'] . $args[0];
	        }
	    }
	    
	    /* Build the Redis unified protocol command */
	    array_unshift($args, strtoupper($name));
	    $command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(array($this, 'formatArgument'), $args), CRLF), CRLF);
	    
	    /* Open a Redis connection and execute the command */
	    for ($written = 0; $written < strlen($command); $written += $fwrite) {
	        $fwrite = fwrite($this->__sock, substr($command, $written));
	        if ($fwrite === FALSE) {
	            throw new Exception('Failed to write entire command to stream');
	        }
	    }
	    
	    /* Parse the response based on the reply identifier */
	    $reply = trim(fgets($this->__sock, 512));
	    switch (substr($reply, 0, 1)) {
	        /* Error reply */
	        case '-':
	            throw new RedisException(substr(trim($reply), 4));
	            break;
	            /* Inline reply */
	        case '+':
	            $response = substr(trim($reply), 1);
	            break;
	            /* Bulk reply */
	        case '$':
	            $response = null;
	            if ($reply == '$-1') {
	                break;
	            }
	            $read = 0;
	            $size = substr($reply, 1);
	            do {
	                $block_size = ($size - $read) > 1024 ? 1024 : ($size - $read);
	                $response .= fread($this->__sock, $block_size);
	                $read += $block_size;
	            } while ($read < $size);
	            fread($this->__sock, 2); /* discard crlf */
	            break;
	            /* Multi-bulk reply */
	        case '*':
	            $count = substr($reply, 1);
	            if ($count == '-1') {
	                return null;
	            }
	            $response = array();
	            for ($i = 0; $i < $count; $i++) {
	                $bulk_head = trim(fgets($this->__sock, 512));
	                $size = substr($bulk_head, 1);
	                if ($size == '-1') {
	                    $response[] = null;
	                }
	                else {
	                    $read = 0;
	                    $block = "";
	                    do {
	                        $block_size = ($size - $read) > 1024 ? 1024 : ($size - $read);
	                        $block .= fread($this->__sock, $block_size);
	                        $read += $block_size;
	                    } while ($read < $size);
	                    fread($this->__sock, 2); /* discard crlf */
	                    $response[] = $block;
	                }
	            }
	            break;
	            /* Integer reply */
	        case ':':
	            $response = intval(substr(trim($reply), 1));
	            break;
	        default:
	            throw new RedisException("invalid server response: {$reply}");
	            break;
	    }
	    /* Party on */
	    return $response;
	}
1167007
public static function execute($name, &$args, &$options, $called)
    {
        $moduleClass = 'Xiphe\HTML\modules\\'.ucfirst($name);

        if (is_object(self::$_loadedModules[$name])) {
            self::$_loadedModules[$name]->execute($args, $options, $called);
        } else {
            $Module = new $moduleClass();
            $Module->execute($args, $options, $called);
        }
    }