Loads the composite driver from constants.

@param $level

@return \Stash\Interfaces\DriverInterface
505324
protected function loadConfig($level)
    {
        $app = Application::getFacadeApplication();
        $drivers = [];
        $driverConfigs = $app['config']->get("concrete.cache.levels.{$level}.drivers", []);
        $preferredDriverName = $app['config']->get("concrete.cache.levels.{$level}.preferred_driver", null);

        // Load the preferred driver(s) first
        if (!empty($preferredDriverName)) {
            if (is_array($preferredDriverName)) {
                foreach ($preferredDriverName as $driverName) {
                    $preferredDriver = array_get($driverConfigs, $driverName, []);
                    $drivers[] = $this->buildDriver($preferredDriver);
                }
            } else {
                $preferredDriver = array_get($driverConfigs, $preferredDriverName, []);
                $drivers[] = $this->buildDriver($preferredDriver);
            }
        }
        // If we dont have any perferred drivers or preferred drivers available
        // Build Everything
        if (empty($drivers)) {
            foreach ($driverConfigs as $driverConfig) {
                if (!$driverConfig) {
                    continue;
                }

                $drivers[] = $this->buildDriver($driverConfig);
            }
        }

        // Remove any empty arrays for an accurate count
        array_filter($drivers);
        $count = count($drivers);
        if ($count > 1) {
            $driver = new Composite(['drivers' => $drivers]);
        } elseif ($count === 1) {
            reset($drivers);
            $driver = current($drivers);
        } else {
            $driver = new BlackHole();
        }

        return $driver;
    }
556864
protected function getCallerByLevel($level)
    {
        $level+=1;
        $backtrace=debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, static::MAX_TRACE_LEVEL);
        $caller_class=$backtrace[$level]['class']??'';
        if ($this->dn_class && (is_subclass_of($this->dn_class, $caller_class) || $this->dn_class===$caller_class)) {
            $caller_class=$backtrace[$level+1]['class']??'';
        }
          

        return $caller_class;
    }
122663
public function level($level)
    {
        if (empty($level)) {
            $level = [];
        } elseif (is_string($level)) {
            $level = explode(',', str_replace(' ', '', $level));
        } else {
            $level = is_array($level) ? $level : func_get_args();
        }

        $this->setLevel($level);

        return $this;
    }
886273
public function level($level)
    {
        if ($level === null) {
            return $this;
        }
        
        $this->prepend = '   ' . (str_repeat('  ', $level));
        
        return $this;
    }
871388
public function setLogLevel($level = \Monolog\Logger::DEBUG)
    {
        $this->logLevel = (int) $level;
        return $this;
    }
1088564
public function getXp(int $level)
    {
        $xpTable = $this->getXpTable();

        if (!isset($xpTable[$level])) {
            return false;
        }

        return $xpTable[$level];
    }
696525
public static function toMonologLevel($level): int
    {
        if (is_string($level)) {
            if (defined(__CLASS__.'::'.strtoupper($level))) {
                return constant(__CLASS__.'::'.strtoupper($level));
            }

            throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
        }

        return $level;
    }
601433
public static function toNumberLevel($level)
    {
        if (\is_string($level) && \defined(__CLASS__ . '::' . strtoupper($level))) {
            return \constant(__CLASS__ . '::' . strtoupper($level));
        }

        return $level;
    }
490461
public function loadDrivers(): DriverCollection
    {
        $drivers = new DriverCollection($this);

        foreach ($this->drivers as $name => $driver) {
            $drivers->add($name, $driver);
        }

        return $drivers;
    }
455306
public function level($level = null)
    {
        if ($level !== null) {
            $this->_level = $level;
        }

        return $this->_level;
    }
765927
public function andLevelEquals($level, $alias = null)
    {
        list($alias, $suffix) = $this->getAliasAndSuffix($alias);

        return $this->andWhere($alias.'._level = :level'.$suffix)
                        ->setParameter('level'.$suffix, $level);
    }
804216
private function getLevelOrder(string $level)
    {
        if (! array_key_exists($level, $this->levelOrder)) {
            throw new Exception\InvalidArgumentException(sprintf('Invalid log level %s', $level));
        }

        return $this->levelOrder[$level];
    }
536599
public function load_driver($child)
	{
		// Get the subclass prefix
	    $prefix = Factory::getInstance()->config->get('main')->application_prefix;

		if ( ! isset($this->lib_name))
		{
			// Get library name without any prefix
			$this->lib_name = str_replace(array('FW_', $prefix), '{prefix}', get_class($this));
		}

		// Sanitize the library name
		$clean_class = str_replace(array('Application\Library\\','FuzeWorks\Library\\', '{prefix}'), '', $this->lib_name);

		// The child will be prefixed with the parent lib
		$child_name = $this->lib_name.'_'.$child;

		// See if requested child is a valid driver
		if ( ! in_array($child, $this->valid_drivers))
		{
			// The requested driver isn't valid!
			$msg = 'Invalid driver requested: '.$child_name;
			throw new LibraryException($msg, 1);
		}

		// Get package paths and filename case variations to search
		$paths = Factory::getInstance()->libraries->getLibraryPaths();

		// Is there an extension?
		$class_name = str_replace('{prefix}', $prefix, $child_name);
		$found = class_exists($class_name, FALSE);
		if ( ! $found)
		{
			// Check for subclass file
			foreach ($paths as $path)
			{
				// Does the file exist?
				$file = $path.DS.$clean_class.DS.'drivers'.DS.$prefix.$clean_class.'_'.$child.'.php';
				if (file_exists($file))
				{
					// Yes - require base class from BASEPATH
					$basepath = Core::$coreDir . DS. 'Libraries'.DS.$clean_class.DS.'drivers'.DS.$clean_class.'_'.$child.'.php';
					if ( ! file_exists($basepath))
					{
						$msg = 'Unable to load the requested class: FW_'.$child_name;
						throw new LibraryException($msg, 1);
						
					}

					// Include both sources and mark found
					include_once($basepath);
					include_once($file);
					$found = TRUE;
					break;
				}
			}
		}

		// Do we need to search for the class?
		if ( ! $found)
		{
			// Use standard class name
			$class_name = str_replace('{prefix}', 'FW_', $child_name);
			if ( ! class_exists($class_name, FALSE))
			{
				// Check package paths
				foreach ($paths as $path)
				{
					// Does the file exist?
					$file = $path.DS.$clean_class.DS.'drivers'.DS.$clean_class.'_'.$child.'.php';
					if (file_exists($file))
					{
						// Include source
						include_once($file);
						break;
					}
				}
			}
		}

		// Did we finally find the class?
		if ( ! class_exists($class_name, FALSE))
		{
			if (class_exists($child_name, FALSE))
			{
				$class_name = $child_name;
			}
			else
			{
				$msg = 'Unable to load the requested driver: '.$class_name;
				throw new LibraryException($msg, 1);
			}
		}

		// Instantiate, decorate and add child
		$obj = new $class_name();
		$obj->decorate($this);
		$this->$child = $obj;
		return $this->$child;
	}
755487
public function getSubdomain(int $level = null)
    {
        $domain = $this->getDomain();

        if (is_null($domain)) {
            return null;
        }

        $return = substr($this->getHost(), 0, -strlen($this->getDomain()) - 1);

        if (!$return) {
            return null;
        }

        if (is_null($level)) {
            return $return;
        }

        return implode('.', array_slice(
            explode('.', $return),
            $level > 0 ? 0 : $level,
            1
        ));
    }
355774
public function setLevel($level)
    {
        if (is_numeric($level)) {
            $this->_level = (int)$level;
        } else {
            $this->_level = array_search($level, self::$_levels, true);
        }

        return $this;
    }
999053
public static function getLevelName($level)
    {
        static $levels = [
            Logger::LEVEL_ERROR => 'error',
            Logger::LEVEL_WARNING => 'warning',
            Logger::LEVEL_INFO => 'info',
            Logger::LEVEL_TRACE => 'debug',
            Logger::LEVEL_PROFILE_BEGIN => 'debug',
            Logger::LEVEL_PROFILE_END => 'debug',
        ];

        return isset($levels[$level]) ? $levels[$level] : 'error';
    }
80347
public function getMenu($level = 1)
    {
        if ($controller = $this->getCurrentController(PageController::class)) {
            return $controller->getMenu($level)->exclude('HideFromMainMenu', 1);
        }
    }