Пример #1
0
/**
 * Returns snippet for Class of the current file
 *
 * @param string $filename returns file name
 * @param string $filepath returns file path
 * @return string snippet
 * @author Konstantin Kudryashov <*****@*****.**>
 */
function getSnippet()
{
    $baseClass = sfBundle::getBaseClassForCurrentFile();
    $packageName = getPackageName($baseClass);
    $snippet = sprintf(<<<SNIPPET
/*
 * This file is part of the \$1.
 * (c) \${2:%s} \${3:\${TM_ORGANIZATION_NAME}}
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * \${4:%s} \${5:does things}.
 *
 * @package    \${6:\$1}
 * @subpackage \${7:%s}
 * @author     \$3
 * @version    \${8:1.0.0}
 */
class \$4%s
{
  \$0
}
SNIPPET
, date('Y', time()), getClassName(TextMate::getEnv('filename'), TextMate::getEnv('filepath')), $packageName ? $packageName : 'custom', $baseClass ? sprintf(" extends \${9:%s}", $baseClass) : '');
    return $snippet;
}
Пример #2
0
<?php

require_once dirname(__FILE__) . '/../Lib/sfBundle.class.php';
$args = $_SERVER['argv'];
if (isset($args[1])) {
    switch ($args[1]) {
        case 'cmd':
            sfBundle::runCLICommand($args[2]);
            if (false !== strpos($args[2], 'generate') || false !== strpos($args[2], 'build')) {
                TextMate::rescanProject();
            }
            break;
    }
} else {
    sfBundle::runCLICommand('list --xml');
}
Пример #3
0
}
// Partial name is global or relative?
if (count($nameParts = explode('/', $partialName)) > 1) {
    $path = sprintf('%s/%s/templates', dirname(dirname(dirname(TextMate::getEnv('filepath')))), $nameParts[0]);
    $renderedPartialName = $nameParts[1];
} else {
    $path = dirname(TextMate::getEnv('filepath'));
    $renderedPartialName = $partialName;
}
// Getting partial path by it's name & checking if it exists
$partialPath = sprintf('%s/_%s.php', $path, $renderedPartialName);
if (file_exists($partialPath)) {
    TextMate::drawCocoaDialog('msgbox', array('title' => 'Partial already exists', 'text' => 'Partial already exists', 'informative-text' => $partialPath, 'button1' => "Ok"));
    TextMate::exitDiscard();
}
// Path exists ? If not - create one
if (!is_dir($path)) {
    mkdir($path, 0755, true);
}
// Getting content of partial & splitting spaces from start
$content = file_get_contents('php://stdin');
if ($splittableSpacesCount = sfBundle::getSplittableSpacesCount($content)) {
    $content = sfBundle::splitSpacesAtStart($content, $splittableSpacesCount);
}
// Echoing snippet
echo sprintf("%s<?php include_partial('%s'\${1:, array(\$0)}) ?>", str_repeat(' ', $splittableSpacesCount), $partialName);
// Writing partial
file_put_contents($partialPath, $content);
// Rescaning project folder & opening partial in TM
TextMate::rescanProject();
TextMate::open($partialPath);