Ontology\Peertube::class, ]; /** * A list of ontologies loaded by implementers, by their names and * associated definitions. * * @var array */ private static $externals = []; /** * Allowed ontologies in current context. A list of keys that refers * to self::$internals and self::$externals definitions * * @var array */ private static $loaded = []; /** * Clear all ontologies definitions and loaded array */ public static function clear() { self::$externals = []; foreach (self::$loaded as $name) { self::unload($name); } } /** * Add an ontology definition in the pool. * Useful to define custom ontology classes on the fly * * @param string $name Ontology name. * @param string $class Types definitions * @param bool $load */ public static function add(string $name, string $class, bool $load = true) { // Reserved keyword if ($name == '*') { throw new Exception( "Name '$name' is a reserved keyword" ); } // Class exists if (!class_exists($class)) { throw new Exception( "Class '$class' does not exist" ); } // Class implements OntologyBase if (!method_exists($class, 'getDefinition')) { throw new Exception( "Class '$class' MUST implement " . OntologyInterface::class . " interface." ); } // Put in the external stack if needed self::$externals[$name] = $class; // Load if needed if ($load) { self::load($name); } } /** * Load an ontology as an active one. * * @param string $name Ontology name. * @throws \Exception if ontology has not been defined */ public static function load(string $name) { $ontologies = []; if ($name == '*') { $ontologies = self::$internals + self::$externals; } else { // externals (override) if (isset(self::$externals[$name])) { $ontologies[$name] = self::$externals[$name]; } elseif (isset(self::$internals[$name])) { $ontologies[$name] = self::$internals[$name]; } else { // Not found throw new Exception( "Ontology '{$name}' has not been defined" ); } } foreach ($ontologies as $name => $ontology) { Dialect::add($name, $ontology::getDefinition()); if (!array_search($name, self::$loaded)) { array_push(self::$loaded, $name); } } } /** * Unload an ontology. * * @param string $name Ontology name. */ public static function unload(string $name) { self::$loaded = array_filter( self::$loaded, function ($value) use ($name) { return $value != $name && $dialect != '*'; } ); Dialect::unload($name); } } __halt_compiler();----SIGNATURE:----ynerLGAaniA+7NzG17fe/2tJXiXHnQawBz/Xfag4iuOJxjSFD9yOhjVkk5TNciikeTd5VWRYqxanta7zjF1BDZ3rDKwVG+g8E6QvlaiX++72LmyRT0DkBDY76hIEWApl5ecd7UKqhnuqs0lMIFqhS4j5SXCXe3FJladG4YdXQRrkzl37zhmA8KZWIGjTteqPRocMw4GSNRhkRDjgPPgK1OJcrTT7Cy1yb2D4OqQUL5AFEHG89LWvi1VBV02rLdcy06rslWqfIi98onm+ePkMGQ6h7WBO6qzcNNqfUTq3kK3rVc5Pt291cmoYK/zFk5JdF+q5NVXWQYOWSDT0e+mCEpjmQE+eDtJU3NCfWLsVLMoyEg/EDUhOhLXt1yiBKFM5FAn8jD0tz8kIFUyBgSEIpbYpks2G7acdyVgMncVYZYAi4dXfgQ0ggAO/3qidcSc5r7EhHRqVBXhZgF+AN0mEwpyXRweCImU1plZLCR3W0tk/X7f2X/0Lohh4MOGvqJZyZgMOPIPvOezCX2phlMWajsFOUs3ob4jDns67/Y85pB/hBB0pmbW9FCklqJL7D9TFTA3l7DjfeeJzy00soYK4/TjmGGNbSCtw+fP8cFVP6ssW/+hcbj0u419T6UJKwQxTpBEukQm4KUFZVpNPnPpkbvBHE9sly+R/8JGpZh3no2g=----ATTACHMENT:----OTU4MjMwMTY1NTgzNzkzOCAzMTIzODkyMzQzNzgxOTkyIDU0NTcyODQ1MjI1Mzg=