Load a view.

@param string $name
@param string $extension

@return $this
@throws InvalidArgumentException
346118
public function load($name, $extension = 'html')
    {
        // Get view file path
        $this->view = $this->getViewFilePath($name, $extension);

        // Check if there is a valid view
        if (empty($this->view)) {
            throw new InvalidArgumentException(__METHOD__ . sprintf(': The view file [%s] is a not valid view.', $this->getViewFile($name, $extension)));
        }

        return $this;
    }
1299147
public function renderView($name, $data = array(), $return = FALSE)
    {
        $file = $this->getViewPath($name);
        return $this->loadView($file, $data, $return);
    }
950112
public static function fromExtension(string $extension): MediaType
    {
        if (!self::isKnownExtension($extension)) {
            throw new \InvalidArgumentException(sprintf('Unknown extension "%s" given.', $extension));
        }

        return new self(self::$knownTypes[strtolower($extension)]);
    }
881829
protected function loader($name)
    {
        if (false !== \strpos('.', $name)) {
            throw new Exceptions\Invalid($name);
        }

        if (isset($this->loaders[$name])) {
            return $this->loaders[$name];
        }

        foreach ($this->extensions as $extension) {
            try {
                $path = $this->buildPath($name, $extension);
                $this->loaders[$name] = FileLoader::load($path);

                return $this->loaders[$name];
            } catch (NotFound\Path $argumentException) {
                continue;
            }
        }

        throw new NotFound\Path($this->root . $name);
    }
803495
protected function click($name)
    {
        $link = $this->crawler()->selectLink($name);

        if (! count($link)) {
            $link = $this->filterByNameOrId($name, 'a');

            if (! count($link)) {
                throw new InvalidArgumentException(
                    "Could not find a link with a body, name, or ID attribute of [{$name}]."
                );
            }
        }

        $this->visit($link->link()->getUri());

        return $this;
    }
1192149
protected function loadExtension($name, $useSettings, Config $config)
    {
        if ($config->hasItem('_loaded', $name)) {
            return $this;
        }

        if (!is_array($useSettings)) {
            $useSettings = [];
        }

        $namespaces = $config->get('namespaces', []);

        if (!is_array($namespaces)) {
            $namespaces = [];
        }

        $namespaces[] = "Itq\\Dev";

        $found = false;

        foreach ($namespaces as $namespace) {
            $pattern = sprintf('%s\\Extension\\{Name}\\{Name}Extension', $namespace);
            $class = str_replace('{Name}', str_replace(' ', '', ucwords(str_replace('-', ' ', $name))), $pattern);
            if (!class_exists($class)) {
                continue;
            }
            $found = $class;
        }

        if (false === $found) {
            throw new \RuntimeException(sprintf("Unknown extension '%s'", $name), 412);
        }

        /** @var ExtensionInterface $extension */
        $extension = new $found($useSettings);

        if (!($extension instanceof ExtensionInterface)) {
            throw new \RuntimeException(
                sprintf("%s must be a valid extension (found: %s)", $name, get_class($extension)),
                412
            );
        }

        $this->addExtension($extension);

        $available = $extension->isAvailable($config);

        if ($available) {
            $r = new \ReflectionClass($extension);
            $config->setDefaultItem('_shell_scripts_dirs', $name, dirname($r->getFileName()).'/Resources/shell-scripts');
            foreach ($extension->getConfigLoaders() as $loader) {
                $loader->load($config);
            }
        }

        $config->setItem('_loaded', $name, $available);

        $this->loadExtensions($config);

        return $this;
    }
75033
public function expose($name, $function = null, $as = 'function')
    {
        $this->assertViewVariableName($name);
        
        if ($as === 'function') {
            $function = new \Twig_SimpleFunction($name, $function ?: $name);
            $this->getTwig()->addFunction($function);
        } elseif ($as === 'filter') {
            $filter = new \Twig_SimpleFilter($name, $function ?: $name);
            $this->getTwig()->addFilter($filter);
        } else {
            $not = is_string($as) ? "'$as'" : gettype($as);
            throw new \InvalidArgumentException("You can create either a 'function' or 'filter', not a $not");
        }

        return $this;
    }
589918
public static function loadCoreView(string $name) {
      $base = __DIR__ . '/../../Views/';
      if (!file_exists($base . $name . '.view')) {
        throw new \Nuki\Exceptions\Base('The view file "' . $name . '" does not exist.');
      }
      
      return file_get_contents($base . $name . '.view');
    }
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]);
    }
923124
private function loadExtensions($extensions)
    {
        $extensions = Arr::wrap($extensions);

        foreach ($extensions as $extension) {
            $extension = 'ext'.$extension;

            if (method_exists($this, $extension)) {
                $this->$extension();
            }
        }
    }
553726
protected function loadContext($name = null) {
		$context = parent::loadContext($name);
		if (isset($context['iterator'])) {
			$this->iterator = $context['iterator'];
		} else if (isset($context['array'])) {
			$this->iterator = new \ArrayIterator($context['array']);
		} else {
			throw new \BadMethodCallException('Invalid context, iterator or array not set');
		}
		return $context;
	}
97642
protected function resolveRenderer(string $extension): RendererInterface
	{
		if(!isset($this->rendererInstances[$extension]))
		{
			$this->rendererInstances[$extension] = $this->rendererFactory($this->renderers[$extension]);
		}

		return $this->rendererInstances[$extension];
	}
435038
protected function requireOption($name)
    {
        if (!isset($this->options[$name])) {
            throw new InvalidArgumentException("The option: '$name' is required");
        }
        return $this->options[$name];
    }
1295429
public function get($name)
    {
        if (!isset($this->adapters[$name])) {
            throw new \InvalidArgumentException(sprintf('No Adapter with name "%s" is registered.', $name));
        }

        return $this->adapters[$name];
    }
980093
public function startBlock($name)
    {
        if (in_array($name, $this->openBlocks)) {
            throw new InvalidArgumentException(sprintf('A block "%s" is already started.', $name));
        }

        $this->openBlocks[] = $name;

        if (!isset($this->blocks[$name])) {
            $this->blocks[$name] = null;
        }

        ob_start();
        ob_implicit_flush(0);
    }
594138
protected function set($name, \Closure $extension)
    {
        $this->getExtensions()->set($name, $extension);
        
        return $this;
    }
611742
public function start($name)
    {
        if (\in_array($name, $this->openSlots)) {
            throw new \InvalidArgumentException(sprintf('A slot named "%s" is already started.', $name));
        }

        $this->openSlots[] = $name;
        $this->slots[$name] = '';

        ob_start();
        ob_implicit_flush(0);
    }