Liquid::classExists PHP Метод

classExists() публичный статический Метод

Checks if class exists in $_coreClasses array
public static classExists ( string $className ) : boolean
$className string class name
Результат boolean whether the class exists in $_coreClasses
    public static function classExists($className)
    {
        return isset(self::$_coreClasses[$className]) ? true : false;
    }

Usage Example

Пример #1
0
 /**
  * Parses the given tokens
  *
  * @param array $tokens
  */
 public function parse(&$tokens)
 {
     $startRegexp = new LiquidRegexp('/^' . LIQUID_TAG_START . '/');
     $tagRegexp = new LiquidRegexp('/^' . LIQUID_TAG_START . '\\s*(\\w+)\\s*(.*)?' . LIQUID_TAG_END . '$/');
     $variableStartRegexp = new LiquidRegexp('/^' . LIQUID_VARIABLE_START . '/');
     $this->_nodelist = array();
     if (!is_array($tokens)) {
         return;
     }
     $tags = LiquidTemplate::getTags();
     while (count($tokens)) {
         $token = array_shift($tokens);
         if ($startRegexp->match($token)) {
             if ($tagRegexp->match($token)) {
                 // if we found the proper block delimitor just end parsing here and let the outer block proceed
                 if ($tagRegexp->matches[1] == $this->blockDelimiter()) {
                     return $this->endTag();
                 }
                 if (array_key_exists($tagRegexp->matches[1], $tags)) {
                     $tag_name = $tags[$tagRegexp->matches[1]];
                 } else {
                     $tag_name = 'LiquidTag' . ucwords($tagRegexp->matches[1]);
                     // search for a defined class of the right name, instead of searching in an array
                     $tag_name = Liquid::classExists($tag_name) === true ? $tag_name : null;
                 }
                 if (class_exists($tag_name)) {
                     $this->_nodelist[] = new $tag_name($tagRegexp->matches[2], $tokens, $this->_fileSystem);
                     if ($tagRegexp->matches[1] == 'extends') {
                         return true;
                     }
                 } else {
                     $this->unknownTag($tagRegexp->matches[1], $tagRegexp->matches[2], $tokens);
                 }
             } else {
                 throw new LiquidException("Tag {$token} was not properly terminated");
                 // harry
             }
         } elseif ($variableStartRegexp->match($token)) {
             $this->_nodelist[] = $this->_createVariable($token);
         } elseif ($token != '') {
             $this->_nodelist[] = $token;
         }
     }
     $this->assertMissingDelimitation();
 }