get_instance() public static method

public static get_instance ( ) : pakeApp
return pakeApp
 public static function package_pear_package($package_xml_path, $target_dir)
 {
     if (!file_exists($package_xml_path)) {
         throw new pakeException('"' . $package_xml_path . '" file does not exist');
     }
     pake_mkdirs($target_dir);
     $current = getcwd();
     chdir($target_dir);
     if (!class_exists('PEAR_Packager')) {
         @(include 'PEAR/Packager.php');
         if (!class_exists('PEAR_Packager')) {
             // falling back to cli-call
             $results = pake_sh(escapeshellarg(pake_which('pear')) . ' package ' . escapeshellarg($package_xml_path));
             if (pakeApp::get_instance()->get_verbose()) {
                 echo $results;
             }
             chdir($current);
             return;
         }
     }
     $packager = new PEAR_Packager();
     $packager->debug = 0;
     // silence output
     $archive = $packager->package($package_xml_path, true);
     pake_echo_action('file+', $target_dir . '/' . $archive);
     chdir($current);
 }
Ejemplo n.º 2
0
function echo_cms_sep()
{
    if (pakeApp::get_instance()->get_verbose()) {
        $width = 9 + strlen(pakeColor::colorize('', 'SEP'));
        echo sprintf(' %-' . $width . 's %s', pakeColor::colorize("", 'SEP'), pakeApp::excerpt("", null)) . "\n";
    }
}
 function render($e)
 {
     $title = '  [' . get_class($e) . ']  ';
     $len = self::strlen($title);
     $lines = array();
     foreach (explode("\n", $e->getMessage()) as $line) {
         $lines[] = '  ' . $line . '  ';
         $len = max(self::strlen($line) + 4, $len);
     }
     $messages = array(str_repeat(' ', $len), $title . str_repeat(' ', $len - self::strlen($title)));
     foreach ($lines as $line) {
         $messages[] = $line . str_repeat(' ', $len - self::strlen($line));
     }
     $messages[] = str_repeat(' ', $len);
     fwrite(STDERR, "\n");
     foreach ($messages as $message) {
         fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR) . "\n");
     }
     fwrite(STDERR, "\n");
     $pake = pakeApp::get_instance();
     if ($pake->get_trace()) {
         fwrite(STDERR, "exception trace:\n");
         $trace = $this->trace($e);
         for ($i = 0, $count = count($trace); $i < $count; $i++) {
             $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
             $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
             $function = $trace[$i]['function'];
             $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
             $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
             fwrite(STDERR, sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR)));
         }
     }
     fwrite(STDERR, "\n");
 }
 public function setUp()
 {
     pakeApp::get_instance()->do_option('quiet', null);
     $dir = dirname(__FILE__);
     $this->test_dir = $dir . DIRECTORY_SEPARATOR . 'temporary-files';
     if (!is_dir($this->test_dir)) {
         mkdir($this->test_dir);
     }
     $this->_cleanup();
 }
 public static function render($e)
 {
     $isatty = pakeApp::isTTY();
     $title = '  [' . get_class($e) . ']  ';
     $len = self::strlen($title);
     $lines = array();
     foreach (explode("\n", $e->getMessage()) as $line) {
         if ($isatty) {
             $pieces = explode("\n", wordwrap($line, pakeApp::screenWidth() - 4, "\n", true));
         } else {
             $pieces = array($line);
         }
         foreach ($pieces as $piece) {
             $lines[] = '  ' . $piece . '  ';
             $len = max(self::strlen($piece) + 4, $len);
         }
     }
     if ($isatty) {
         $messages = array(str_repeat(' ', $len), $title . str_repeat(' ', $len - self::strlen($title)));
     } else {
         $messages = array('', $title);
     }
     foreach ($lines as $line) {
         if ($isatty) {
             $messages[] = $line . str_repeat(' ', $len - self::strlen($line));
         } else {
             $messages[] = $line;
         }
     }
     if ($isatty) {
         $messages[] = str_repeat(' ', $len);
     } else {
         $messages[] = '';
     }
     fwrite(STDERR, "\n");
     foreach ($messages as $message) {
         fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR) . "\n");
     }
     fwrite(STDERR, "\n");
     $pake = pakeApp::get_instance();
     if ($pake->get_trace()) {
         fwrite(STDERR, "exception trace:\n");
         $trace = self::trace($e);
         for ($i = 0, $count = count($trace); $i < $count; $i++) {
             $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
             $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
             $function = $trace[$i]['function'];
             $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
             $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
             fwrite(STDERR, pake_sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR)));
         }
     }
     fwrite(STDERR, "\n");
 }
Ejemplo n.º 6
0
function run_help($task = null, $args = array(), $cliopts = array())
{
    /*if ( count( $args ) == 0 )
      {
          // ...
      }*/
    // work around a pake bug
    if (count($args) > 0) {
        $args[0] = pakeTask::get_full_task_name($args[0]);
    }
    $pake = pakeApp::get_instance();
    $pake->run_help($task, $args);
}
 public function get_property($name, $section = null)
 {
     $properties = pakeApp::get_instance()->get_properties();
     if ($section) {
         if (!array_key_exists($section, $properties) || !array_key_exists($name, $properties[$section])) {
             throw new pakeException(sprintf('Property "%s/%s" does not exist.', $section, $name));
         } else {
             return $properties[$section][$name];
         }
     } else {
         if (!array_key_exists($name, $properties)) {
             throw new pakeException(sprintf('Property "%s" does not exist.', $name));
         } else {
             return $properties[$name];
         }
     }
 }
Ejemplo n.º 8
0
 private static function _get_php_executable()
 {
     static $php_exec = null;
     if (null === $php_exec) {
         $root = dirname(pakeApp::get_instance()->getPakefilePath());
         if (!file_exists($root . '/Makefile')) {
             throw new LogicException("Makefile is missing. You have to build extension before testing it!");
         }
         $makefile_rows = file($root . '/Makefile');
         foreach ($makefile_rows as $row) {
             if (strpos($row, 'PHP_EXECUTABLE = ') !== 0) {
                 continue;
             }
             $row = rtrim($row);
             $parts = explode(' = ', $row);
             if (!isset($parts[1]) or strlen($parts[1]) == 0) {
                 continue;
             }
             $php_exec = $parts[1];
             break;
         }
         unset($makefile_rows);
     }
     if (!$php_exec) {
         // Fallback
         $php_exec = 'php';
     }
     return $php_exec;
 }
Ejemplo n.º 9
0
function pake_echo_comment($text)
{
    if (pakeApp::get_instance()->get_verbose()) {
        echo sprintf(pakeColor::colorize('   # %s', 'COMMENT'), $text) . "\n";
    }
}
Ejemplo n.º 10
0
        $initialized = true;
    }
    return simpleAutoloader::__autoload($class);
}
// trap -V before pake
if (in_array('-V', $argv) || in_array('--version', $argv)) {
    printf("symfony version %s\n", pakeColor::colorize(trim(file_get_contents($sf_symfony_lib_dir . '/VERSION')), 'INFO'));
    exit(0);
}
if (count($argv) <= 1) {
    $argv[] = '-T';
}
require_once $sf_symfony_lib_dir . '/config/sfConfig.class.php';
sfConfig::add(array('sf_root_dir' => getcwd(), 'sf_symfony_lib_dir' => $sf_symfony_lib_dir, 'sf_symfony_data_dir' => $sf_symfony_data_dir));
// directory layout
include $sf_symfony_data_dir . '/config/constants.php';
// include path
set_include_path(sfConfig::get('sf_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_app_lib_dir') . PATH_SEPARATOR . sfConfig::get('sf_model_dir') . PATH_SEPARATOR . sfConfig::get('sf_symfony_lib_dir') . DIRECTORY_SEPARATOR . 'vendor' . PATH_SEPARATOR . get_include_path());
// register tasks
$dirs = array(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'tasks' => 'myPake*.php', sfConfig::get('sf_symfony_data_dir') . DIRECTORY_SEPARATOR . 'tasks' => 'sfPake*.php', sfConfig::get('sf_root_dir') . '/plugins/*/data/tasks' => '*.php');
foreach ($dirs as $globDir => $name) {
    if ($dirs = glob($globDir)) {
        $tasks = pakeFinder::type('file')->ignore_version_control()->name($name)->in($dirs);
        foreach ($tasks as $task) {
            include_once $task;
        }
    }
}
// run task
pakeApp::get_instance()->run(null, null, false);
exit(0);
Ejemplo n.º 11
0
 public static function run_pear_package($task, $args)
 {
     $path = dirname(pakeApp::get_instance()->getPakefilePath());
     self::package_pear_package($path . '/package.xml', $path);
 }
Ejemplo n.º 12
0
<?php

Phar::interceptFileFuncs();
$phar_name = dirname(__FILE__);
define('PAKE_DIR', $phar_name . '/lib/pake');
require PAKE_DIR . '/init.php';
$pake = pakeApp::get_instance();
$pake->run();
Ejemplo n.º 13
0
<?php

Phar::interceptFileFuncs();
$phar_name = dirname(__FILE__);
define('PAKE_DIR', $phar_name . '/lib/pake');
require PAKE_DIR . '/autoload.php';
require PAKE_DIR . '/cli_init.php';
$retval = pakeApp::get_instance()->run();
if (false === $retval) {
    exit(1);
}
 public static function run_help_pake()
 {
     pakeApp::get_instance()->display_tasks_and_comments();
 }