« Yaf_Loader::getLocalNamespace
Yaf_Loader::getNamespaces »

Yaf_Loader::getNamespacePath

(Yaf >=3.2.0)

Yaf_Loader::getNamespacePath — Retrieve the library path of a class

説明

public function Yaf_Loader::getNamespacePath(string $class_name): string

Retrieve the library directory a class would be looked up in.

パラメータ

class_name

The class name whose library directory is requested.

戻り値

The local library directory if the class belongs to a registered local namespace, otherwise the global library directory (falling back to the local one when the global one is not set).

例

例1 Yaf_Loader::getNamespacePath() example

<?php
$app    = new Yaf_Application(__DIR__ . "/conf/application.ini");
$loader = Yaf_Loader::getInstance();

$loader->registerLocalNamespace("Models");
$loader->setLibraryPath("/usr/local/share/yaf/library", true);

/* "Models" is a registered local namespace */
echo $loader->getNamespacePath("Models_Product"), PHP_EOL;

/* other classes fall back to the global library directory */
echo $loader->getNamespacePath("Vendor_Payment"), PHP_EOL;
?>

上の例の出力は、 たとえば以下のようになります。

/var/www/shop/application/library
/usr/local/share/yaf/library

参考

関連キーワード:
library   Loader   getNamespacePath   local   directory   loader   Retrieve   path   the global   Models   registered   namespace   back   application   share   isLocalName   getLocalNamespace   getNamespaces   looked   requested   belongs   otherwise   falling   example   Application
関連する関数・ページ:
yaf-loader.registerlocalnamespace   yaf-loader.getnamespaces   yaf-loader.construct   function.rnp-version-string-full   class.yaf-loader   yaf-loader.registernamespace