本文整理汇总了PHP中PHPParser::LoadPHPFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser::LoadPHPFile方法的具体用法?PHP PHPParser::LoadPHPFile怎么用?PHP PHPParser::LoadPHPFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPParser
的用法示例。
在下文中一共展示了PHPParser::LoadPHPFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Load
public static final function Load($path, $name)
{
if (class_exists($name)) {
return true;
}
PHPParser::LoadPHPFile($path);
if (!class_exists($name)) {
throw new ApplicationException(sprintf(_("%s must contain %s class."), $path, $name), E_ERROR);
}
return true;
}
示例2: DBPaymentObserver
}
//
// Attach Global Payment observers
//
PaymentModuleFactory::AddModuleObserver(new DBPaymentObserver());
//
// Attach user observers
//
$observers = $db->Execute("SELECT * FROM eventhandlers WHERE enabled='1'");
while ($observer = $observers->FetchRow())
{
// eval user class file
PHPParser::LoadPHPFile(CONFIG::$PATH."/events/class.{$observer['name']}.php");
// Check for config
$config_items = $db->GetAll("SELECT COUNT(*) FROM eventhandlers_config WHERE handler_name=?", array($observer['name']));
if (count($config_items) != 0)
{
//Config found
eval("\$Config = {$observer['name']}::GetConfigurationForm();");
if ($Config instanceof DataForm)
{
// Get fields values
$fields = $Config->ListFields();
foreach ($fields as &$field)
{
$val = $db->GetOne("
SELECT `value` FROM eventhandlers_config
示例3: array
<?php
require_once 'src/prepend.inc.php';
$display["help"] = "This page lists all custom event handlers. <a href=\"http://epp-drs.com/docs/wiki/event.handlers\">Click here</a> to learn how to add your own event handlers or configure existing ones.";
$supported_interfaces = array("IInvoiceObserver" => "invoice", "IRegistryObserver" => "registry", "IPaymentObserver" => "payment", "IGlobalObserver" => "app");
$rows = array();
// Create directory iterator for events directory
$DirIterator = new DirectoryIterator(CONFIG::$PATH . "/events");
foreach ($DirIterator as $item) {
if ($item->isFile() && $item->isReadable() && preg_match("/^class.(.*).php\$/si", $item->getFilename(), $matches)) {
// get class name
$class_name = $matches[1];
// eval user file if class not exists
if (!class_exists($class_name)) {
// eval file
PHPParser::LoadPHPFile($item->getPathname());
// Check for class existence
if (!class_exists($class_name)) {
throw new Exception(sprintf(_("%s must contain %s class."), $item->getPathname(), $class_name), E_ERROR);
}
}
// Check class validity
$ReflectionClass = new ReflectionClass($class_name);
$interfaces = $ReflectionClass->getInterfaceNames();
// Check for required interfaces
$ints = array_intersect(array_keys($supported_interfaces), $interfaces);
sort($ints);
if (count($ints) != 1) {
throw new Exception(sprintf(_("Class %s must implements one of the following interfases: %s"), $class_name, implode(", ", $supported_interfaces)), E_ERROR);
}
$enabled = $db->GetOne("SELECT enabled FROM eventhandlers WHERE name=?", array($class_name));