Exemple #1
0
 public static function mail_template_list()
 {
     $path = \ebi\Conf::get(\ebi\Mail::class . '@resource_path', \ebi\Conf::resource_path('mail'));
     $template_list = [];
     try {
         foreach (\ebi\Util::ls($path, true, '/\\.xml$/') as $f) {
             $info = new \ebi\Dt\DocInfo();
             $info->name(str_replace(\ebi\Util::path_slash($path, null, true), '', $f->getPathname()));
             try {
                 $xml = \ebi\Xml::extract(file_get_contents($f->getPathname()), 'mail');
                 $info->document($xml->find_get('subject')->value());
                 $info->set_opt('x_t_code', \ebi\Mail::xtc($info->name()));
                 $template_list[] = $info;
             } catch (\ebi\exception\NotFoundException $e) {
             }
         }
     } catch (\ebi\exception\InvalidArgumentException $e) {
     }
     return $template_list;
 }
Exemple #2
0
    $class_name = \ebi\Util::get_class_name($class_info['class']);
    try {
        call_user_func([$class_name, 'find_get']);
        \cmdman\Std::println_success(' ' . $class_name . ' OK');
    } catch (\ebi\exception\NotFoundException $e) {
    } catch (\ebi\exception\ConnectionException $e) {
        $failure['db']++;
        \cmdman\Std::println_danger(' ' . $class_name . ' Failure, ' . $e->getMessage());
    } catch (\Exception $e) {
        $failure['db']++;
        \cmdman\Std::println_warning(' ' . $class_name . ' Failure, ' . $e->getMessage());
    }
}
\cmdman\Std::println();
\cmdman\Std::println_info('Entry:');
foreach (\ebi\Util::ls(getcwd()) as $f) {
    $src = file_get_contents($f->getPathname());
    if (strpos($src, '\\ebi\\Flow::app(') !== false) {
        $map = \ebi\Flow::get_map($f->getPathname());
        $entry = str_replace(getcwd(), '', $f->getPathname());
        foreach ($map['patterns'] as $p) {
            if (array_key_exists('action', $p) && is_string($p['action'])) {
                try {
                    list($c, $m) = explode('::', $p['action']);
                    $mr = new \ReflectionMethod(\ebi\Util::get_class_name($c), $m);
                    \cmdman\Std::println_success($entry . ' ' . $p['name'] . ' OK');
                } catch (\ReflectionException $e) {
                    $failure['entry']++;
                    \cmdman\Std::println_danger($entry . ' ' . $p['name'] . ' Failure');
                }
            }
Exemple #3
0
 /**
  * ライブラリ一覧
  * @return array
  */
 public static function classes($parent_class = null, $ignore = true)
 {
     $result = [];
     $include_path = [];
     $ignore_class = [];
     if (is_dir(getcwd() . DIRECTORY_SEPARATOR . 'lib')) {
         $include_path[] = realpath(getcwd() . DIRECTORY_SEPARATOR . 'lib');
     }
     if (class_exists('Composer\\Autoload\\ClassLoader')) {
         $r = new \ReflectionClass('Composer\\Autoload\\ClassLoader');
         $vendor_dir = dirname(dirname($r->getFileName()));
         if (is_file($loader_php = $vendor_dir . DIRECTORY_SEPARATOR . 'autoload.php')) {
             $loader = (include $loader_php);
             // vendor以外の定義されているパスを探す
             foreach ($loader->getPrefixes() as $ns) {
                 foreach ($ns as $path) {
                     $path = realpath($path);
                     if (strpos($path, $vendor_dir) === false) {
                         $include_path[] = $path;
                     }
                 }
             }
         }
     }
     $valid_find_class_file = function ($f) {
         if (strpos($f->getPathname(), DIRECTORY_SEPARATOR . '.') === false && strpos($f->getPathname(), DIRECTORY_SEPARATOR . '_') === false && strpos($f->getPathname(), DIRECTORY_SEPARATOR . 'cmd' . DIRECTORY_SEPARATOR) === false && ctype_upper(substr($f->getFilename(), 0, 1)) && substr($f->getFilename(), -4) == '.php') {
             try {
                 include_once $f->getPathname();
             } catch (\Exeption $e) {
             }
         }
     };
     foreach ($include_path as $libdir) {
         if ($libdir !== '.' && is_dir($libdir)) {
             foreach (\ebi\Util::ls($libdir, true) as $f) {
                 $valid_find_class_file($f);
             }
         }
     }
     /**
      * @param string[] $vendor 利用するvendorのクラス
      */
     $use_vendor = \ebi\Conf::gets('use_vendor');
     /**
      * @param callback $callback 利用するvendorのクラス配列を返すメソッド
      */
     $use_vendor_callback = \ebi\Conf::get('use_vendor_callback');
     if (!empty($use_vendor_callback)) {
         $callback_result = call_user_func($use_vendor_callback);
         if (is_array($callback_result)) {
             $use_vendor = array_merge($use_vendor, $callback_result);
         }
     }
     if (is_array($use_vendor)) {
         foreach ($use_vendor as $class) {
             $find_package = false;
             if (substr($class, -1) == '*') {
                 $class = substr($class, 0, -1);
                 $find_package = true;
             }
             $class = str_replace('.', '\\', $class);
             if (class_exists($class)) {
                 if ($find_package) {
                     $r = new \ReflectionClass($class);
                     foreach (\ebi\Util::ls(dirname($r->getFileName()), true) as $f) {
                         $valid_find_class_file($f);
                     }
                 }
             }
         }
     }
     $valid_find_class = function ($r, $parent_class) {
         if (!$r->isInterface() && (empty($parent_class) || is_subclass_of($r->getName(), $parent_class)) && $r->getFileName() !== false && strpos($r->getName(), '_') === false && strpos($r->getName(), 'Composer') === false && strpos($r->getName(), 'cmdman') === false && strpos($r->getName(), 'testman') === false) {
             return true;
         }
         return false;
     };
     foreach (get_declared_classes() as $class) {
         if ($valid_find_class($r = new \ReflectionClass($class), $parent_class)) {
             (yield ['filename' => $r->getFileName(), 'class' => '\\' . $r->getName()]);
         }
     }
 }
Exemple #4
0
\ebi\Conf::set([
]);
__SRC__
);
    \cmdman\Std::println_success('Written: ' . realpath($f));
}
if ($mode != $appmode) {
    \cmdman\Std::println_info('Application mode changed.');
    return;
} else {
    \cmdman\Std::println_info('Application mode is `' . $mode . '`');
}
if (!is_file($f = $path . '/bootstrap.php')) {
    $autoload_file = '';
    if (class_exists('Composer\\Autoload\\ClassLoader')) {
        $r = new \ReflectionClass('Composer\\Autoload\\ClassLoader');
        $composer_dir = dirname($r->getFileName());
        if (is_file($bf = realpath(dirname($composer_dir) . '/autoload.php'))) {
            $autoload_file = str_replace(str_replace("\\", '/', getcwd()) . '/', '', str_replace("\\", '/', $bf));
        }
    } else {
        foreach (\ebi\Util::ls($path, true, '/ebi\\.phar$/') as $p) {
            $autoload_file = str_replace(str_replace("\\", '/', getcwd()) . '/', '', str_replace("\\", '/', $p));
            break;
        }
    }
    if (!empty($autoload_file)) {
        file_put_contents($f, '<?php' . PHP_EOL . 'include_once(\'' . $autoload_file . '\');');
        \cmdman\Std::println_success('Written file ' . $f);
    }
}