本文整理汇总了PHP中ClassInfo::classes_for_file方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassInfo::classes_for_file方法的具体用法?PHP ClassInfo::classes_for_file怎么用?PHP ClassInfo::classes_for_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassInfo
的用法示例。
在下文中一共展示了ClassInfo::classes_for_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collectFromEntityProviders
public function collectFromEntityProviders($filePath, $module = null)
{
$entities = [];
// HACK Ugly workaround to avoid "Cannot redeclare class PHPUnit_Framework_TestResult" error
// when running text collector with PHPUnit 3.4. There really shouldn't be any dependencies
// here, but the class reflection enforces autloading of seemingly unrelated classes.
// The main problem here is the CMSMenu class, which iterates through test classes,
// which in turn trigger autoloading of PHPUnit.
$phpunitwrapper = PhpUnitWrapper::inst();
$phpunitwrapper->init();
$classes = ClassInfo::classes_for_file($filePath);
if ($classes) {
foreach ($classes as $class) {
// Not all classes can be instanciated without mandatory arguments,
// so entity collection doesn't work for all SilverStripe classes currently
// Requires PHP 5.1+
if (class_exists($class) && in_array('i18nEntityProvider', class_implements($class))) {
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isAbstract()) {
continue;
}
$obj = singleton($class);
$entities = array_merge($entities, (array) $obj->provideI18nEntities());
if ($obj->is_a('DataObject')) {
foreach (['db', 'has_one', 'has_many', 'many_many', 'belongs_many_many'] as $type) {
foreach ((array) Config::inst()->get($obj->class, $type, Config::UNINHERITED) as $name => $spec) {
$entities["{$obj->class}.{$type}_{$name}"] = [FormField::name_to_label($name)];
}
}
}
}
}
}
ksort($entities);
return $entities;
}
开发者ID:helpfulrobot,项目名称:zauberfisch-silverstripe-better-i18n,代码行数:36,代码来源:BetterI18nTextCollector.php
示例2: collectFromEntityProviders
/**
* @uses i18nEntityProvider
*/
function collectFromEntityProviders($filePath)
{
$entitiesArr = array();
$classes = ClassInfo::classes_for_file($filePath);
if ($classes) {
foreach ($classes as $class) {
// Not all classes can be instanciated without mandatory arguments,
// so entity collection doesn't work for all SilverStripe classes currently
// Requires PHP 5.1+
if (class_exists($class) && in_array('i18nEntityProvider', class_implements($class))) {
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isAbstract()) {
continue;
}
$obj = singleton($class);
$entitiesArr = array_merge($entitiesArr, (array) $obj->provideI18nEntities());
}
}
}
ksort($entitiesArr);
return $entitiesArr;
}
示例3: getTestsInFile
/**
* Find all test classes in a file and return an array of them.
* @param string $file To search in
* @param array $ignore Ignore these test classes if they are found.
* @return array
*/
protected function getTestsInFile($file, $ignore = array())
{
$classes = ClassInfo::classes_for_file($file);
return $this->filterTestClasses($classes, $ignore);
}
示例4: collectFromEntityProviders
/**
* Allows classes which implement i18nEntityProvider to provide
* additional translation strings.
*
* Not all classes can be instanciated without mandatory arguments,
* so entity collection doesn't work for all SilverStripe classes currently
*
* @uses i18nEntityProvider
* @param string $filePath
* @param string $module
* @return array
*/
public function collectFromEntityProviders($filePath, $module = null)
{
$entities = array();
$classes = ClassInfo::classes_for_file($filePath);
foreach ($classes as $class) {
// Skip non-implementing classes
if (!class_exists($class) || !in_array('i18nEntityProvider', class_implements($class))) {
continue;
}
// Skip abstract classes
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isAbstract()) {
continue;
}
$obj = singleton($class);
$entities = array_merge($entities, (array) $obj->provideI18nEntities());
}
ksort($entities);
return $entities;
}
示例5: collectFromEntityProviders
/**
* @uses i18nEntityProvider
*/
function collectFromEntityProviders($filePath, $module = null)
{
$entities = array();
// HACK Ugly workaround to avoid "Cannot redeclare class PHPUnit_Framework_TestResult" error
// when running text collector with PHPUnit 3.4. There really shouldn't be any dependencies
// here, but the class reflection enforces autloading of seemingly unrelated classes.
// The main problem here is the CMSMenu class, which iterates through test classes,
// which in turn trigger autoloading of PHPUnit.
$phpunitwrapper = PhpUnitWrapper::inst();
$phpunitwrapper->init();
$classes = ClassInfo::classes_for_file($filePath);
if ($classes) {
foreach ($classes as $class) {
// Not all classes can be instanciated without mandatory arguments,
// so entity collection doesn't work for all SilverStripe classes currently
// Requires PHP 5.1+
if (class_exists($class) && in_array('i18nEntityProvider', class_implements($class))) {
$reflectionClass = new ReflectionClass($class);
if ($reflectionClass->isAbstract()) {
continue;
}
$obj = singleton($class);
$entities = array_merge($entities, (array) $obj->provideI18nEntities());
}
}
}
ksort($entities);
return $entities;
}