* @link https://book.cakephp.org/4/en/core-libraries/app.html#finding-paths-to-namespaces */ public static function path(string $type, ?string $plugin = null): array { if ($plugin === null && $type[0] === strtolower($type[0])) { return (array)Configure::read('App.paths.' . $type); } if ($type === 'templates') { /** @psalm-suppress PossiblyNullArgument */ return [Plugin::templatePath($plugin)]; } if ($type === 'locales') { /** @psalm-suppress PossiblyNullArgument */ return [Plugin::path($plugin) . 'resources' . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR]; } deprecationWarning( 'App::path() is deprecated for class path.' . ' Use \Cake\Core\App::classPath() or \Cake\Core\Plugin::classPath() instead.' ); return static::classPath($type, $plugin); } /** * Gets the path to a class type in the application or a plugin. * * Example: * * ``` * App::classPath('Model/Table'); * ``` * * Will return the path for tables - e.g. `src/Model/Table/`. * * ``` * App::classPath('Model/Table', 'My/Plugin'); * ``` * * Will return the plugin based path for those. * * @param string $type Package type. * @param string|null $plugin Plugin name. * @return array */ public static function classPath(string $type, ?string $plugin = null): array { if ($plugin !== null) { return [ Plugin::classPath($plugin) . $type . DIRECTORY_SEPARATOR, ]; } return [APP . $type . DIRECTORY_SEPARATOR]; } /** * Returns the full path to a package inside the CakePHP core * * Usage: * * ``` * App::core('Cache/Engine'); * ``` * * Will return the full path to the cache engines package. * * @param string $type Package type. * @return array Full path to package */ public static function core(string $type): array { if ($type === 'templates') { return [CORE_PATH . 'templates' . DIRECTORY_SEPARATOR]; } return [CAKE . str_replace('/', DIRECTORY_SEPARATOR, $type) . DIRECTORY_SEPARATOR]; } }