/** * List of core directories with normalized paths, longest directories first. * * @return array */ private function getDirectories() { $directories = $this->core->getDirectories(); foreach ($directories as &$directory) { $directory = $this->files->normalizePath($directory); unset($directory); } //Sorting to get longest first uasort($directories, function ($valueA, $valueB) { return strlen($valueA) < strlen($valueB); }); return $directories; }
/** * Export configuration data to final directory (application configs directory by default). If * configuration file already exists it's content will be merged with new configuration data * using merge method. * * @param string $directory Destination config directory, application directory by default. * @param int $mode File mode, use FilesInterface::RUNTIME for publicly accessible * files. * @return bool */ public function writeConfig($directory = null, $mode = FilesInterface::READONLY) { $directory = !empty($directory) ? $directory : $this->core->directory('config'); //Target configuration file $filename = $this->configFilename($directory, $this->name); $original = []; if ($this->files->exists($filename)) { $original = (require $filename); //We are going to use original config header $this->readHeader($filename); } return $this->files->write($filename, $this->renderConfig($original), $mode, true); }
/** * Shortcut to shared container get method. * * @param string $alias Class name or alias. * @return object|null * @throws \Interop\Container\Exception\ContainerException */ function spiral($alias) { return Core::sharedContainer()->get($alias); }
/** * Pluralize string using language pluralization options and specified numeric value. Number * has to be ingested at place of {n} placeholder. * * Examples: * p("{n} user", $users); * * @param string $phrase Should include {n} as placeholder. * @param int $number * @param bool $format Format number. * @return string * @throws TranslatorException */ function p($phrase, $number, $format = true) { return Core::container()->get(TranslatorInterface::class)->pluralize($phrase, $number, $format); }