/** * Test successfully initialize deployer */ public function testSuccessfullyInitialize() { list($tmpDir, $tmpFileName, $tmpFilePath) = $this->createTemporaryFile(); $this->template->expects($this->once())->method('initialize')->with($tmpFilePath); $configFilePath = $this->initializer->initialize('test', $tmpDir, $tmpFileName); $this->assertEquals($tmpFilePath, $configFilePath); }
public function init() { parent::init(); $this->setName('confirmRegisterForm'); $this->setAttrib('id', 'confirm-register-form'); $this->addElementPrefixPath('App_Validate', 'App/Validate/', 'validate'); $this->setDecorators(array('FormElements', 'DijitForm')); $config = Initializer::getConfig(); //-------------------------------------- // Elements //-------------------------------------- $this->addElement('ValidationTextBox', 'emailAddress', array('label' => 'Your E-Mail Address', 'description' => 'The E-mail address you wish you confirm', 'required' => true, 'trim' => true, 'filters' => array('StringToLower'), 'validators' => array(array('EmailAddress', false, array('validateMx' => true))))); $this->addElement('TextBox', 'code', array('label' => 'Confirmation Code', 'description' => 'This is the code you received from us.', 'required' => true, 'trim' => true, 'filters' => array('StringToUpper'), 'validators' => array('Alnum'))); $this->addElement('SubmitButton', 'submit', array('ignore' => true, 'label' => 'Confirm My E-Mail Address')); }
public function init() { parent::init(); $config = Initializer::getConfig(); $userId = Zend_Auth::getInstance()->getIdentity()->id; $this->setAttrib('id', 'new-track-form'); $this->setDecorators(array('FormElements', 'DijitForm')); $this->addElement('FilteringSelect', 'releaseId', array('label' => 'Release', 'storeId' => 'artistReleasesDataStore', 'storeType' => 'dojo.data.ItemFileReadStore', 'description' => 'The release to attach this track to. The track will still be downloadable as a single track, but will be grouped under the release', 'autocomplete' => true, 'storeParams' => array('url' => '/data/artists/releases/' . $userId . '?published=0', 'requestMethod' => 'get'), 'dijitParams' => array('searchAttr' => 'title'))); $this->addElement('ValidationTextBox', 'title', array('label' => 'Track Title', 'required' => true, 'trim' => true, 'description' => 'The display title, appears in store', 'validators' => array(array('Alnum', false, array('allowWhiteSpace' => true))))); $this->addElement('DateTextBox', 'publishDate', array('label' => 'Publish Date', 'description' => 'The date which this track will be available for purchase', 'default' => date('m/d/Y'))); $audioFile = new Zend_Form_Element_File('audioFile'); $audioFile->setLabel('Master Audio File')->addDecorators(array('Description'))->setRequired(true)->setDescription('The original (master) track. Must be a .WAV file')->setDestination($config->injestion->workDir)->addValidator('Extension', false, explode(',', $config->injestion->allowedExtensions))->addValidator('MimeType', false, explode(',', $config->injestion->allowedMimeTypes))->addFilter('Rename', array('target' => $config->injestion->workDir . '/track_' . str_pad($userId, 8, '0') . '_' . date('Ymdhs') . '.wav', 'overwrite' => true)); $this->addElement($audioFile); $this->setEnctype('multipart/form-data'); $this->addElement('SubmitButton', 'submit', array('ignore' => true, 'label' => 'Upload Track')); }
public function init() { parent::init(); $this->setName('registerForm'); $this->setAttrib('id', 'register-form'); $this->setMethod('post'); $this->addElementPrefixPath('App_Validate', 'App/Validate/', 'validate'); $this->setDecorators(array('FormElements', 'DijitForm')); $config = Initializer::getConfig(); //-------------------------------------- // Elements //-------------------------------------- $this->addElement('ValidationTextBox', 'emailAddress', array('label' => 'Your E-Mail Address', 'description' => 'Give us your valid E-mail address. We check this, so make sure its valid and you can access it.', 'required' => true, 'trim' => true, 'filters' => array('StringToLower'), 'validators' => array(array('EmailAddress', false, array('validateMx' => true)), array('UniqueAccountDetail', false, array('field' => 'emailAddress'))))); $this->addElement('PasswordTextBox', 'password', array('label' => 'Choose a Password', 'description' => 'Make it a good one. It must be at least 6 characters', 'required' => true, 'trim' => false, 'validators' => array(array('StringLength', false, array(6)), array('PasswordConfirmation', true, array('field' => 'confirm_password'))))); $this->addElement('PasswordTextBox', 'confirm_password', array('label' => 'Retype Your Password', 'description' => 'Just to make sure you didn\'t mess up', 'required' => true, 'trim' => false)); $this->addElement('CheckBox', 'sellerAccount', array('label' => 'I want to sell music, too.', 'description' => 'Check this box if you want to sell music on BitNotion. You will still be able to purchase music using this account.')); $this->addElement('Captcha', 'captcha', array('label' => 'Are you human?', 'descripton' => 'Type the letters shown, and prove you\'re smarter than the average robot.', 'captcha' => array('captcha' => 'ReCaptcha', 'privkey' => $config->recaptcha->privateKey, 'pubkey' => $config->recaptcha->publicKey))); $this->addElement('SubmitButton', 'submit', array('ignore' => true, 'label' => 'Create My Account')); }
/** * Constructor * * Initialize environment, root path, and configuration. * * @param string $env * @param string|null $root * @return void */ public function __construct($env, $root = null) { $this->_setEnv($env); if (null === $root) { $root = realpath(dirname(__FILE__) . '/../'); } $this->_root = $root; $this->initPhpConfig(); $this->_front = Zend_Controller_Front::getInstance(); date_default_timezone_set('UTC'); // set the test environment parameters if (true || $env == 'test') { // Enable all errors so we'll know when something goes wrong. error_reporting(E_ALL | E_STRICT); ini_set('display_startup_errors', 1); ini_set('display_errors', 1); $this->_front->throwExceptions(true); } $configFile = dirname(__FILE__) . '/config.xml'; require_once 'Zend/Config/Xml.php'; self::$_config = new Zend_Config_Xml($configFile, $this->_env); require_once 'Zend/Registry.php'; Zend_Registry::set('Config', self::$_config); }
#!/usr/bin/php <?php require_once '../application/Initializer.php'; // must specify the environment as the first variable if (!count($argv) > 1) { echo 'You must specify an environment as the first argument'; exit(-1); } $init = new Initializer($argv[1]); $config = $init->getConfig(); Zend_Loader::registerAutoload(); $s3 = new S3($config->aws->accessKey, $config->aws->secretKey); $buckets = array($config->aws->publicBucket => S3::ACL_PUBLIC_READ, $config->aws->contentBucket => S3::ACL_PRIVATE); $existingBuckets = $s3->listBuckets(); foreach ($buckets as $name => $acl) { if (!in_array($name, $existingBuckets)) { $s3->putBucket($name, $acl); echo "Bucket Added: {$name}\n"; } }
/* @var $cnf Zend_Config_Ini */ $cnf = Zend_Registry::get('config'); Zend_Layout::startMvc()->setLayoutPath(APP_BASE . "/{$cnf->layout->dir}")->setLayout($cnf->layout->script); } protected function initRoutes(Zend_Controller_Request_Abstract $req) { } protected function initController() { $fc = Zend_Controller_Front::getInstance(); $fc->addModuleDirectory(APP_BASE . '/modules'); } public function routeStartup($req) { $this->initMVC(); $this->initDB(); $this->initRoutes($req); } public function __construct() { $this->initConfig(); $this->initController(); } } try { Initializer::setupIncPath(); Zend_Controller_Front::getInstance()->registerPlugin(new Initializer())->dispatch(); } catch (Exception $ex) { echo "An unhandled Exception was caught: <b>" . $ex->getMessage() . "</b>"; echo "<pre>" . $ex->getTraceAsString() . "</pre>"; }
#!/usr/bin/env php <?php require_once '../application/bootstrap.php'; set_include_path('../models/generated' . PATH_SEPARATOR . get_include_path()); $init = new Initializer('build'); $init->initDb(); $basePath = dirname(dirname(__FILE__)); $cli = new Doctrine_Cli(array('data_fixtures_path' => $basePath . '/build/data/fixtures', 'models_path' => $basePath . '/models', 'migrations_path' => $basePath . '/build/data/migrations', 'sql_path' => $basePath . '/build/data/sql', 'yaml_schema_path' => $basePath . '/build/data/schema.yml')); $cli->run($_SERVER['argv']);
<?php /** * AiryMVC Framework * * @category AiryMVC * @license New BSD license - at this URL: http://opensource.org/licenses/BSD-3-Clause * @author: Hung-Fu Aaron Chang */ include dirname(__FILE__) . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Ini.php"; Initializer::initialize(); $Router = Loader::load("Router"); Dispatcher::dispatch($Router);
<?php include 'lib/initializer.php'; Initializer::init();
<?php require_once "Command.php"; require_once "FirstCommand.php"; require_once "SecondCommand.php"; require_once "Initializer.php"; $init = new Initializer(); $command1 = new FirstCommand("Google"); $command2 = new FirstCommand("Yandex"); $command3 = new SecondCommand(250); $command4 = new SecondCommand(35); $init->addCommand($command1); $init->addCommand($command2); $init->addCommand($command3); $init->addCommand($command4); $init->executeAll();
#!/usr/bin/php <?php require_once '../application/bootstrap.php'; //TODO MP3 ID3 Tagging //TODO $init = new Initializer(isset($argv[1]) ? $argv[1] : 'production'); $init->initDb(); $init->initApp(); $config = $init->getConfig(); $log = new Zend_Log(); $logwriter = new Zend_Log_Writer_Stream('ingestion.log'); $logwriter->setFormatter(new Zend_Log_Formatter_Simple('%timestamp% %priorityName% (%priority%): %process% [%track%] %message%' . PHP_EOL)); $log->addWriter($logwriter); $log->setEventItem('process', str_pad(rand(0, 999), 3, '0')); define('WORKDIR', $config->injestion->workDir); $s3 = new S3($config->aws->accessKey, $config->aws->secretKey); //------------------------------------ $log->log('-- begin processing tracks --', Zend_Log::INFO); $table = new Doctrine_Table('Track', Doctrine_Manager::connection(), true); while ($track = $table->findOneByEncodingstatus('UPLOADED')) { $log->setEventItem('track', $track->id); $track->encodingStatus = 'PROCESSING'; $track->save(); $log->log('- processing track', Zend_Log::INFO); // Make sure track has an original file id if (intval($track->originalFileId) == 0) { $track->encodingStatus = 'ERROR'; $track->save(); $log->log('error: no source file to process', Zend_Log::ERR); continue; }
/** * The input folder will be recursively loop throught and save the folder into an array. * * @param string $directory the root directory. * @param boolean $recursive sets if the function recursively fetches the directories. * * @return array all the directories. */ public static function getDirectory($directory, $recursive) { $array_items = array(); $ignore = array('.', '..', '.svn', '.DS_Store'); if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if (!in_array($file, $ignore)) { if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) { if ($recursive) { $array_items = array_merge($array_items, Initializer::getDirectory($directory . DIRECTORY_SEPARATOR . $file, $recursive)); } $file = $directory . DIRECTORY_SEPARATOR . $file; if (DIRECTORY_SEPARATOR == "\\") { $array_items[] = preg_replace("/\\\\/si", DIRECTORY_SEPARATOR, $file); } else { $array_items[] = preg_replace("/\\/\\//si", DIRECTORY_SEPARATOR, $file); } } } } closedir($handle); } return $array_items; }