/** * Add one or more maps * A map is simply a class namepsace * * @param string|array $name * @param path $path * @return void */ public static function map($name, $path = null) { if (is_array($name)) { static::$namespaces = array_merge(static::$namespaces, $name); return; } static::$namespaces[$name] = $path; }
/** * Adds an array of namespace paths. See {add_namespace}. * * @param array the namespaces * @param bool whether to prepend the namespace to the search path * @return void */ public static function add_namespaces(array $namespaces, $prepend = false) { if (!$prepend) { static::$namespaces = array_merge(static::$namespaces, $namespaces); } else { static::$namespaces = $namespaces + static::$namespaces; } }
/** * init * * @param boolean $reset * * @return void */ public static function init($reset = false) { if (!static::$namespaces || $reset) { $namespaces = new \SplPriorityQueue(); $namespaces->insert(static::$defaultNamespace, $reset); static::$namespaces = $namespaces; } }
/** * Map namespaces to directories. * * @param array $mappings * @param string $append * @return void */ public static function namespaces($mappings, $append = '\\') { foreach ($mappings as $namespace => $directory) { // When adding new namespaces to the mappings, we will unset the previously // mapped value if it existed. This allows previously registered spaces to // be mapped to new directories on the fly. $namespace = trim($namespace, $append) . $append; unset(static::$namespaces[$namespace]); $namespaces[$namespace] = head(static::format($directory)); } // We'll array_merge the new mappings onto the front of the array so // derivative namespaces are not always shadowed by their parents. // For instance, when mappings Laravel\Docs, we don't want the // main Laravel namespace to always override it. static::$namespaces = array_merge($namespaces, static::$namespaces); }
/** * Method collects the namespace definitions into the static namespace storage (the Customer interface only!). * Widgets can register the namespaces they are using via 'getNamespaces()' * * @return void * * @see \XLite\View\AView::getNamespaces() */ protected function registerNamespaces() { $data = $this->getNamespaces(); if ($data) { static::$namespaces = array_unique(array_merge(static::$namespaces, $data)); } }
public function decode($data) { try { if ($data == '') { return array(); } libxml_use_internal_errors(true); $xml = simplexml_load_string($data, "SimpleXMLElement", LIBXML_NOBLANKS | LIBXML_NOCDATA | LIBXML_COMPACT); if (false === $xml) { $error = libxml_get_last_error(); throw new RestException(400, 'Malformed XML. ' . trim($error->message, "\r\n") . ' at line ' . $error->line); } libxml_clear_errors(); if (static::$importSettingsFromXml) { static::$attributeNames = array(); static::$namespacedProperties = array(); static::$namespaces = array(); static::$rootName = $xml->getName(); $namespaces = $xml->getNamespaces(); if (count($namespaces)) { $p = strpos($data, $xml->getName()); if ($p && $data[$p - 1] == ':') { $s = strpos($data, '<') + 1; $prefix = substr($data, $s, $p - $s - 1); static::$namespacedProperties[static::$rootName] = $prefix; } } } $data = $this->read($xml); if (count($data) == 1 && isset($data[static::$textNodeName])) { $data = $data[static::$textNodeName]; } return $data; } catch (\RuntimeException $e) { throw new RestException(400, "Error decoding request. " . $e->getMessage()); } }
/** * Map namespaces to directories. * * @param array $mappings * @return void */ public static function namespaces($mappings) { $mappings = static::format_mappings($mappings, '\\'); static::$namespaces = array_merge($mappings, static::$namespaces); }
public static function addNamespaces($namespaces) { static::$namespaces = $namespaces; }