/** * Create the new controller * * @return void */ protected function makeController() { $code = $this->compileController(); $path = $this->getControllerPath(); $this->files->put($path, $code); $this->info('Controller created successfully.'); $this->composer->dumpAutoloads(); }
/** * @param string $path * @return string */ function findRobot($pathOrClass) { if (is_file($pathOrClass)) { list($class, $root) = $this->splitPath($pathOrClass); $this->composer->add('', $root); $this->composer->register(true); } else { $class = $pathOrClass; } return $this->newRobot($class); }
/** * Generate the desired migration. */ protected function makeMigration() { $name = $this->argument('name'); if ($this->files->exists($path = $this->getPath($name))) { return $this->error($this->type . ' already exists!'); } $this->makeDirectory($path); $this->files->put($path, $this->compileMigrationStub()); $this->info('Migration created successfully.'); $this->composer->dumpAutoloads(); }
/** * Tests valid date. */ public function testValidDates() { $composer = new Composer(); $tests = array('2002-04-30 00:00:00', '2003-02-28 00:00:00', '2004-02-29 05:03:16', '2005-07-31 01:01:01', '2006-10-31 23:59:59', '2007-11-30 15:16:17'); foreach ($tests as $test) { preg_match('~^(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})$~', $test, $matches); $composer->setDay($matches[3])->setMonth($matches[2])->setYear($matches[1])->setHour($matches[4])->setMinute($matches[5])->setSecond($matches[6]); $time = $composer->getTime(); $this->assertEquals(new Time($test), $time, sprintf('Failed test for %s.', $test)); } }
/** * Test the information returned by getClass(). */ public function testGetClass() { $composer = new Composer($this->test_path); $info = array('type' => 'test', 'label' => 'Test', 'description' => 'Test'); $base = array($info + array('subtype' => 'base', 'meta' => 'Discovery\\BogusMeta')); $parent = array($info + array('subtype' => 'parent')); $dependency = array($info + array('subtype' => 'dependency')); $this->assertEquals($base, $composer->getClass('Test\\Base\\Test'), 'Base composer getClass'); $this->assertEquals($parent, $composer->getClass('Test\\Parent\\Test'), 'Parent composer getClass'); $this->assertEquals($dependency, $composer->getClass('Test\\Dependency\\Test'), 'Dependency composer getClass'); $this->assertFalse($composer->getClass('Test\\Base\\Ignored'), 'Ignored composer getClass'); }
public static function read($id) { global $db; if ($db) { $q = $db->prepare('SELECT * FROM `composer` WHERE id = ?'); $q->execute(array($id)); if ($item = $q->fetch()) { $composer = new Composer($item['last_name'], $item['name'], $item['date_birth'], $item['date_dead'], $item['birth_country']); $composer->setID($item['id']); return $item; } } return false; }
public function getRandomCompositionConsideringRelevance() { $composerModel = new Composer(); $videoModel = new Video(); $lessonCompositionModel = new LessonComposition(); $lessonComposerModel = new LessonComposer(); $composition['composition'] = $this->getRandomComposition(); $composerId = $composition['composition']['composer_id']; $compositionId = $composition['composition']['id']; $composition['videos'] = $videoModel->getVideosComposition($compositionId); $composition['composer'] = $composerModel->getComposer($composerId); $composition['lessons']['composer'] = $lessonComposerModel->getLessonsComposer($composerId); $composition['lessons']['composition'] = $lessonCompositionModel->getLessonsComposition($compositionId); return $composition; }
/** * Smarter way to get config env * * @return int|string */ public static function detect() { $file = Composer::getRootPath('/app/config/env.php'); if (is_file($file)) { $config = (include $file); } else { $config = (include dirname(__DIR__) . '/../config/env.php'); } if (defined('ZE_ENV')) { return ZE_ENV; } elseif (isset($_SERVER['ZE_ENV'])) { define('ZE_ENV', $_SERVER['ZE_ENV']); return ZE_ENV; } elseif (is_array($config)) { $env = 'production'; foreach ($config as $key => $value) { if (is_callable($value) && $value instanceof \Closure && $value()) { $env = $key; } elseif (is_string($value)) { if (preg_match('/\\//i', $value)) { // Not the safest way ! if (preg_match($value, getenv('HTTP_HOST'))) { $env = $key; } } else { if (preg_match('/' . $value . '/i', getenv('HTTP_HOST'))) { $env = $key; } } } } define('ZE_ENV', $env); return ZE_ENV; } }
/** * {@inheritdoc} */ public function inspect($dir) { if (parent::inspect($dir)) { $composerData = $this->getComposerData($dir); return isset($composerData['require']['symfony/symfony']); } return null; }
/** * Execute the console command. * * @return void */ public function fire() { $header = "scaffolding: {$this->getObjName("Name")}"; $footer = str_pad('', strlen($header), '-'); $dump = str_pad('>DUMP AUTOLOAD<', strlen($header), ' ', STR_PAD_BOTH); $this->line("\n----------- {$header} -----------\n"); $this->makeMeta(); $this->makeMigration(); $this->makeSeed(); $this->makeModel(); $this->makeController(); // $this->makeLocalization(); //ToDo - implement in future version $this->makeViews(); $this->makeViewLayout(); $this->line("\n----------- {$footer} -----------"); $this->comment("----------- {$dump} -----------"); $this->composer->dumpAutoloads(); $this->error("Don't forget to adjust: 'migrate' and 'routes'"); }
/** * Execute the command. * * @return void */ public function handle() { if (!in_array($this->argument('type'), [CommandData::$COMMAND_TYPE_API, CommandData::$COMMAND_TYPE_SCAFFOLD, CommandData::$COMMAND_TYPE_API_SCAFFOLD])) { $this->error('invalid rollback type'); } $this->commandData = new CommandData($this, $this->argument('type')); $this->commandData->config->mName = $this->commandData->modelName = $this->argument('model'); $this->commandData->config->prepareOptions($this->commandData, ['tableName', 'prefix']); $this->commandData->config->prepareAddOns(); $this->commandData->config->prepareModelNames(); $this->commandData->config->prepareTableName(); $this->commandData->config->loadPaths(); $this->commandData->config->loadNamespaces($this->commandData); $this->commandData = $this->commandData->config->loadDynamicVariables($this->commandData); $migrationGenerator = new MigrationGenerator($this->commandData); $migrationGenerator->rollback(); $modelGenerator = new ModelGenerator($this->commandData); $modelGenerator->rollback(); $repositoryGenerator = new RepositoryGenerator($this->commandData); $repositoryGenerator->rollback(); $requestGenerator = new APIRequestGenerator($this->commandData); $requestGenerator->rollback(); $controllerGenerator = new APIControllerGenerator($this->commandData); $controllerGenerator->rollback(); $routesGenerator = new APIRoutesGenerator($this->commandData); $routesGenerator->rollback(); $requestGenerator = new RequestGenerator($this->commandData); $requestGenerator->rollback(); $controllerGenerator = new ControllerGenerator($this->commandData); $controllerGenerator->rollback(); $viewGenerator = new ViewGenerator($this->commandData); $viewGenerator->rollback(); $routeGenerator = new RoutesGenerator($this->commandData); $routeGenerator->rollback(); if ($this->commandData->getAddOn('tests')) { $repositoryTestGenerator = new RepositoryTestGenerator($this->commandData); $repositoryTestGenerator->rollback(); $testTraitGenerator = new TestTraitGenerator($this->commandData); $testTraitGenerator->rollback(); $apiTestGenerator = new APITestGenerator($this->commandData); $apiTestGenerator->rollback(); } if ($this->commandData->config->getAddOn('menu.enabled')) { $menuGenerator = new MenuGenerator($this->commandData); $menuGenerator->rollback(); } $this->info('Generating autoload files'); $this->composer->dumpOptimized(); }
public function performPostActions($runMigration = false) { if ($this->commandData->getOption('save')) { $this->saveSchemaFile(); } if ($runMigration) { if ($this->commandData->config->forceMigrate) { $this->call('migrate'); } elseif (!$this->commandData->getOption('fromTable') and !$this->isSkip('migration')) { if ($this->confirm("\nDo you want to migrate database? [y|N]", false)) { $this->call('migrate'); } } } if (!$this->isSkip('dump-autoload')) { $this->info('Generating autoload files'); $this->composer->dumpOptimized(); } }
/** * @return void */ public static function prepare($output = false) { if ($output) { $output->writeln('<info>Preparing storage...</info>'); } Storage::prepare(); if ($output) { $output->writeln('<info>Preparing environment...</info>'); } Environment::prepare(); if ($output) { $output->writeln('<info>Preparing composer...</info>'); } Composer::download(); Composer::update(); if ($output) { $output->writeln('<info>Updating database schema...</info>'); } self::updateDatabaseSchema(); }
public function install() { parent::install(); $this->copyGitIgnore('symfony/gitignore-standard'); }
public function __construct() { $this->css = Composer::getDefaultCSS(); $this->js = Composer::getDefaultJS(); }
<?php // This is global bootstrap for autoloading $_SERVER['doc_root'] = __DIR__ . '/../../../../'; $_SERVER['app_path'] = __DIR__ . '/../../../app/'; $_SERVER['core_path'] = __DIR__ . '/../../../core/'; $_SERVER['package_path'] = __DIR__ . '/../../'; $_SERVER['vendor_path'] = __DIR__ . '/../../../vendor/'; require_once __DIR__ . '/../../../core/bootstrap_phpunit.php'; require_once __DIR__ . '/../vendor/autoload.php'; \Package::load('sms'); \Composer::package('sms');
<input type="submit" name="submit" value="submit"></input> </form> <?php if (isset($album)) { ?> <p>The last album entered is "<?php echo $album->last_name; ?> ". With this ID <?php echo $album->id; ?> in this database.</p> <?php } else { $album = Composer::read(1); ?> <p>The first album entered is "<?php echo $album->last_name; ?> ". With this ID <?php echo $album->id; ?> in this database.</p> <?php } ?> </body> </html>
/** * Return true if the Extension Repository can be used * * @return boolean True if the Extension Repository can be used */ public function canUseComposer() { $composer = new Composer(); if (!$composer->hasPhp()) { return false; } if (!$composer->hasCurl()) { return false; } if ($composer->hasApc()) { return false; } if ($composer->hasSuhosin()) { return false; } if (!$composer->hasAllowUrlFopen()) { return false; } if ($this->filePermissions) { return false; } return true; }
// env include "../env.php"; // models include "../app/models/composer.php"; include "../app/models/composition.php"; include "../app/models/lesson_composer.php"; include "../app/models/lesson_composition.php"; include "../app/models/video.php"; // NO ACTION PROVIDED if (!isset($_GET['action'])) { send_error(); } // ACTIONS, OUR CONTROLLER switch ($_GET['action']) { case 'loadcomposers': $composer = new Composer(); $data = $composer->loadComposers(); send_json($data); break; case 'getnextcomposition': $composition = new Composition(); $data = $composition->getNextComposition(); send_json($data); break; default: send_error(); } // AUXILIAR function send_error() { send_json(array('success' => false));