Imagine we
want to locate the file somefile.txt and we know that it will be located in the root
of either the frontend or backend of the current component:
$paths = array(JPATH_COMPONENT, JPATH_COMPONENT_ADMINISTRATOR);
$filePath = JPath::find($paths, 'somefile.txt');
??? ??? ??? ??? ??? ???
Utilities and Useful Classes
[ 346 ]
The first parameter that we pass to the method is an array of paths. The second
parameter is the name of the file that we are attempting to locate.
The $paths array is ordered by priority. This is because the file we are searching for
may exist in more than one of the defined paths. So in our example, if the file were
present in both locations, the frontend path would be returned because it has priority.
If the file is successfully found, then the path to that file is returned. If the file is not
found in any of the locations, then false is returned.
The find() method is not recursive; it does not search subfolders.
The remaining methods are all designed for handling permissions.
Pages:
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480