本文整理汇总了PHP中Filesystem::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::find方法的具体用法?PHP Filesystem::find怎么用?PHP Filesystem::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadClass
/**
* Load a class for one of the form's entities of a particular type.
* Currently, it makes sense to use this method for the "field" and "rule" entities
* (but you can support more entities in your subclass).
*
* @param string $entity One of the form entities (field or rule).
* @param string $type Type of an entity.
* @return mixed Class name on success or false otherwise.
*/
protected static function loadClass($entity, $type)
{
$class = __NAMESPACE__ . '\\' . ucfirst($entity) . 's' . '\\' . ucfirst($type);
if (class_exists($class)) {
return $class;
}
// Get the field search path array.
$paths = self::addPath($entity);
// Try to find the class file.
$type = strtolower($type) . '.php';
foreach ($paths as $path) {
if ($file = \Filesystem::find($path, $type)) {
require_once $file;
if (class_exists($class)) {
break;
}
}
}
// Check for all if the class exists.
return class_exists($class) ? $class : false;
}
示例2: loadFile
/**
* Method to load the form description from an XML file.
*
* The reset option works on a group basis. If the XML file references
* groups that have already been created they will be replaced with the
* fields in the new XML file unless the $reset parameter has been set
* to false.
*
* @param string $file The filesystem path of an XML file.
* @param string $reset Flag to toggle whether form fields should be replaced if a field
* already exists with the same group/name.
* @param string $xpath An optional xpath to search for the fields.
* @return boolean True on success, false otherwise.
*/
public function loadFile($file, $reset = true, $xpath = false)
{
// Check to see if the path is an absolute path.
if (!is_file($file)) {
// Not an absolute path so let's attempt to find one using Filesystem.
$file = Filesystem::find(self::addFormPath(), strtolower($file) . '.xml');
// If unable to find the file return false.
if (!$file) {
return false;
}
}
// Attempt to load the XML file.
$xml = self::getXML($file, true);
return $this->load($xml, $reset, $xpath);
}
示例3: loadElement
/**
* Loads an element type.
*
* @param string The element type.
* @param boolean False (default) to reuse parameter elements; true to load the parameter element type again.
* @return object
*/
public function loadElement($type, $new = false)
{
if ($type == 'list') {
$type = 'select';
}
$signature = md5($type);
if (isset($this->_elements[$signature]) && !$this->_elements[$signature] instanceof __PHP_Incomplete_Class && $new === false) {
return $this->_elements[$signature];
}
$elementClass = __NAMESPACE__ . '\\Element\\' . $type;
if (!class_exists($elementClass)) {
if (isset($this->_elementPath)) {
$dirs = $this->_elementPath;
} else {
$dirs = array();
}
$source = str_replace('_', DS, $type) . '.php';
preg_match('/^[A-Za-z0-9_-]+[A-Za-z0-9_\\.-]*([\\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\\.-]*)*$/', (string) $source, $matches);
$file = @(string) $matches[0];
if ($elementFile = \Filesystem::find($dirs, $file)) {
include_once $elementFile;
} else {
return false;
}
}
if (!class_exists($elementClass)) {
return false;
}
$this->_elements[$signature] = new $elementClass($this);
return $this->_elements[$signature];
}