public static function generate($object, $append = null, $prefix = null, $moreEntropy = false) { if ($prefix === null) { $class = Objects::classShortname($object); $short = self::getUppers($class); $prefix = strlen($short) > 1 ? $short : substr(strtoupper($class), 0, 3); } if ($append !== null) { $append = self::getUppers($append); } return uniqid(Path::buildCustom(':', [$prefix, 'PHID', $append]) . ':', $moreEntropy); }
/** * Concatenate a path with a custom separator * * @param string $directorySeparator * @param string[] $pathComponents * * @return string * * @deprecated */ function build_path_custom($directorySeparator, array $pathComponents) { return \Packaged\Helpers\Path::buildCustom($directorySeparator, $pathComponents); }
public function testBuildCustomPath() { $this->assertEquals("a|b", Path::buildCustom("|", ["a", "b"])); $this->assertEquals("a|b", Path::buildCustom("|", [0 => "a", 1 => "b"])); }
/** * Calculate the base template directory */ protected function _calculateTemplateDefaults() { if ($this->_callingClass === null) { $this->_callingClass = get_called_class(); } else { if (!is_scalar($this->_callingClass)) { $this->_callingClass = get_class($this->_callingClass); } } $parts = explode('\\', $this->_callingClass); $nesting = []; if (!empty($parts) && in_array('Views', $parts)) { $parts = array_reverse($parts); foreach ($parts as $part) { //Looks for the views directory if ($part === 'Views') { break; } $nesting[] = $part; $this->_viewDepth++; } } else { $nesting[] = class_basename($this->_callingClass); $this->_viewDepth = 1; } $this->_templateDir = dirname((new \ReflectionClass($this->_callingClass))->getFileName()); for ($i = 0; $i < $this->_viewDepth; $i++) { $this->_templateDir = dirname($this->_templateDir); } $this->_templateDir = Path::build($this->_templateDir, $this->_templateDirName); if ($this->_templateFile === null) { $this->_templateFile = Path::buildCustom(DIRECTORY_SEPARATOR, array_reverse($nesting)); } }