Loading resources

at 2007-05-12 in Examples by friebe (0 comments)

Yesterday we talked about what is the most elegant way to load a resource existing "alongside" a class. With "alongside", we mean:

$ ls -a de/thekid/demo/
. .. BusinessLogic.class.php bl-config.ini

To load this resource, Alex was using the folllowing:
  $r= ClassLoader::getDefault()->getResource(
strtr
($this->getClass()->getPackage()->getName(), '.', '/').'/bl-config.ini'
);

As of today, the lang.reflect.Package class was extended to provide this out of the box. The following is now possible:
  $r= $this->getClass()->getPackage()->getResource('bl-config.ini');



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES

Related

Find related articles by a search for «Loading».