本文整理汇总了PHP中Component::getActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::getActive方法的具体用法?PHP Component::getActive怎么用?PHP Component::getActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::getActive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_generate
public function action_generate()
{
$sitemaps = array();
$components = Component::getActive();
foreach ($components as $component) {
if ($filename = $this->generateSitemap($component['name'])) {
$sitemaps[] = array('location' => SITE_LINK . basename($filename));
}
}
if (count($sitemaps)) {
$fp = fopen(WEB_FOLDER . '/sitemap_index.xml', 'w');
if (!$fp) {
Backend::addError('Could not generate sitemap index: Could not open file');
return false;
}
fwrite($fp, Render::file('backend_sitemap/index.tpl.php', array('sitemaps' => $sitemaps)));
return WEB_FOLDER . '/sitemap_index.xml';
}
return false;
}
示例2: action_execute
public function action_execute()
{
$return_boolean = empty($_REQUEST['return_boolean']) ? false : true;
$components = Component::getActive();
if (!$components) {
return false;
}
$end_result = true;
$results = array();
foreach (Component::getActive() as $component) {
$results[$component['name']] = array();
if (method_exists($component['name'], 'test')) {
$results[$component['name']]['component'] = call_user_func(array($component['name'], 'test'));
}
$methods = get_class_methods($component['name']);
if (!$methods) {
continue;
}
$component_obj = new $component['name']();
foreach ($methods as $method) {
if (substr($method, 0, 7) == 'action_') {
$test_method = preg_replace('/^action_/', 'test_', $method);
if (in_array($test_method, $methods)) {
set_time_limit(30);
if ($result = $component_obj->{$test_method}()) {
} else {
Backend::addError($component['name'] . '::' . $method . ' Failed');
$end_result = false;
}
$results[$component['name']][$method] = $result;
}
}
}
}
$results = array_filter($results, 'count');
ksort($results);
return $return_boolean ? $end_result : $results;
}
示例3: reportCoverage
public static function reportCoverage(array $options = array())
{
$app_only = array_key_exists('app_only', $options) ? $options['app_only'] : true;
$components = array();
$documented = 0;
$undocumented = 0;
foreach (Component::getActive() as $component) {
$methods = get_class_methods($component['name']);
if (!$methods) {
continue;
}
$action_methods = array_filter($methods, create_function('$var', '$temp = explode(\'_\', $var, 2); return count($temp) == 2 && in_array(strtolower($temp[0]), array(\'action\', \'get\', \'post\', \'put\', \'delete\'));'));
$action_methods = array_map(create_function('$var', 'return preg_replace(\'/^(action|get|post|put|delete)_/\', \'\', $var);'), $action_methods);
if (!count($action_methods)) {
continue;
}
$docu_methods = array_filter($methods, create_function('$var', 'return substr($var, 0, 7) == \'define_\';'));
$docu_methods = array_map(create_function('$var', 'return preg_replace(\'/^(define)_/\', \'\', $var);'), $docu_methods);
$components[$component['name']] = array('documented' => $docu_methods, 'undocumented' => array_diff($action_methods, $docu_methods));
$documented += count($components[$component['name']]['documented']);
$undocumented += count($components[$component['name']]['undocumented']);
}
ksort($components);
return array('documented' => $documented, 'undocumented' => $undocumented, 'components' => $components);
}
示例4: html_index
function html_index($result)
{
Backend::add('Sub Title', 'Manage Application');
Backend::add('result', $result);
$admin_links = array();
$components = Component::getActive();
foreach ($components as $component) {
if (method_exists($component['name'], 'adminLinks')) {
$links = call_user_func(array($component['name'], 'adminLinks'));
if (is_array($links) && count($links)) {
$admin_links[$component['name']] = $links;
}
}
}
Backend::add('admin_links', $admin_links);
Backend::addContent(Render::file('admin.index.tpl.php'));
}
示例5: getConnection
public static function getConnection($table)
{
if ($table instanceof DBObject) {
return $table->getConnection();
} else {
if (is_array($table)) {
$table = current($table);
return self::getConnection($table);
} else {
if ($components = Component::getActive()) {
if (substr($table, -3) == 'Obj') {
$table = substr($table, 0, strlen($table) - 3);
}
$components = array_flatten($components, null, 'name');
if (in_array($table, $components) && class_exists($table . 'Obj', true)) {
$name = $table . 'Obj';
$table = new $name();
return $table->getConnection();
}
}
}
}
return false;
}