Application PHP Class Code Examples

This page contains top rated real world PHP examples of class Application extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: AdvertController.php Project: michaud1992/TPWEB-Perillat-Michaud
0
 public function addAction(Request $request)
 {
     $advert = new Advert();
     $advert->setTitle('Recherche développeur Symfony2.');
     $advert->setAuthor('Alexandre');
     $advert->setContent("Nous recherchons un développeur Symfony2 débutant sur Lyon. Blabla…");
     $image = new Image();
     $image->setUrl('http://sdz-upload.s3.amazonaws.com/prod/upload/job-de-reve.jpg');
     $image->setAlt('Job de rêve');
     $advert->setImage($image);
     $application1 = new Application();
     $application1->setAuthor('Marine');
     $application1->setContent("J'ai toutes les qualités requises.");
     $application2 = new Application();
     $application2->setAuthor('Pierre');
     $application2->setContent("Je suis très motivé.");
     $application1->setAdvert($advert);
     $application2->setAdvert($advert);
     $em = $this->getDoctrine()->getManager();
     $em->persist($advert);
     $em->persist($application1);
     $em->persist($application2);
     $em->flush();
     if ($request->isMethod('POST')) {
         $request->getSession()->getFlashBag()->add('notice', 'Annonce bien enregistrée.');
         return $this->redirect($this->generateUrl('apb_platform_view', array('id' => $advert->getId())));
     }
     return $this->render('APBPlatformBundle:Advert:add.html.twig');
 }
Example #2
Show file File: ActivitiesController.class.php Project: Tipkin-Commons/tipkin
0
 public function __construct(Application $app, $module, $action)
 {
     parent::__construct($app, $module, $action);
     $this->authenticationRedirection();
     $this->init();
     $this->displayInfoMessage();
 }
Example #3
Show file File: SecurityController.php Project: hilltool/opencfp
0
 public function processAction(Request $req, Application $app)
 {
     $template_data = [];
     $code = Response::HTTP_OK;
     try {
         $page = new Login($app['sentry']);
         if ($page->authenticate($req->get('email'), $req->get('password'))) {
             // This is for redirecting to OAuth endpoint if we arrived
             // as part of the Authorization Code Grant flow.
             if ($this->app['session']->has('redirectTo')) {
                 return new RedirectResponse($this->app['session']->get('redirectTo'));
             }
             return $this->redirectTo('dashboard');
         }
         $errorMessage = $page->getAuthenticationMessage();
         $template_data = ['email' => $req->get('email')];
         $code = Response::HTTP_BAD_REQUEST;
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
         $template_data = ['email' => $req->get('email')];
         $code = Response::HTTP_BAD_REQUEST;
     }
     // Set Success Flash Message
     $this->app['session']->set('flash', ['type' => 'error', 'short' => 'Error', 'ext' => $errorMessage]);
     $template_data['flash'] = $this->getFlash($app);
     return $this->render('login.twig', $template_data, $code);
 }
Example #4
Show file File: applicationTable.php Project: PaulConroy1160/Appli-Website
0
 public function findById($id)
 {
     // construct the SQL SELECT statement with a named placeholder for the application id
     $sql = "SELECT * FROM " . applicationTable::TABLE_NAME . " WHERE " . applicationTable::COLUMN_ID . " = :id";
     // the value for the id named placeholder in the SQL DELETE statement
     $params = array('id' => $id);
     // prepare the statement for execution and execute it
     $stmt = $this->mConnection->prepare($sql);
     $status = $stmt->execute($params);
     // if an error occurred while executing the query then throw an exception
     if ($status != true) {
         $errorInfo = $stmt->errorInfo();
         throw new Exception("Could not retrieve book: " . $errorInfo[2]);
     }
     // if exactly one row was returned by the query then retrieve the seekers details
     // and store them in a Seeker object
     $application = null;
     if ($stmt->rowCount() == 1) {
         $row = $stmt->fetch();
         $id = $row[applicationTable::COLUMN_ID];
         $seekerId = $row[applicationTable::COLUMN_SEEKERID];
         $empId = $row[applicationTable::COLUMN_EMPID];
         $jobId = $row[applicationTable::COLUMN_JOBID];
         $status = $row[applicationTable::COLUMN_STATUS];
         $application = new Application($id, $seekerId, $empId, $jobId, $status);
     }
     // return the Application object if a Application with the specified id was found otherwise return null
     return $application;
 }
Example #5
Show file File: 370alpha4a.php Project: luisbrito/Phraseanet
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = 'SELECT id, src FROM metadatas_structure';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $update = [];
     $tagDirname = new \Alchemy\Phrasea\Metadata\Tag\TfDirname();
     $tagBasename = new \Alchemy\Phrasea\Metadata\Tag\TfBasename();
     foreach ($rs as $row) {
         if (strpos(strtolower($row['src']), 'tf-parentdir') !== false) {
             $update[] = ['id' => $row['id'], 'src' => $tagDirname->getTagname()];
         }
         if (strpos(strtolower($row['src']), 'tf-filename') !== false) {
             $update[] = ['id' => $row['id'], 'src' => $tagBasename->getTagname()];
         }
     }
     $sql = 'UPDATE metadatas_structure SET src = :src
             WHERE id = :id';
     $stmt = $databox->get_connection()->prepare($sql);
     foreach ($update as $row) {
         $stmt->execute([':src' => $row['src'], ':id' => $row['id']]);
     }
     $stmt->closeCursor();
     return true;
 }
Example #6
Show file File: Event.php Project: EnmanuelCode/backend-laravel
0
 /**
  * Determine if the given event should run based on the Cron expression.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @return bool
  */
 public function isDue(Application $app)
 {
     if (!$this->runsInMaintenanceMode() && $app->isDownForMaintenance()) {
         return false;
     }
     return $this->expressionPasses() && $this->filtersPass($app) && $this->runsInEnvironment($app->environment());
 }
Example #7
Show file File: ApplicationMvcTest.php Project: aisuhua/phalcon-php
0
 public function testApplicationModulesDefinitionClosure()
 {
     // Creates the autoloader
     $loader = new \Phalcon\Loader();
     $loader->registerNamespaces(array('Frontend\\Controllers' => __DIR__ . '/modules/frontend/controllers/', 'Backend\\Controllers' => __DIR__ . '/modules/backend/controllers/'));
     $loader->register();
     $_GET['_url'] = '/login';
     Phalcon\DI::reset();
     $di = new Phalcon\DI\FactoryDefault();
     $di->set('router', function () {
         $router = new Phalcon\Mvc\Router(false);
         $router->add('/index', array('controller' => 'index', 'module' => 'frontend', 'namespace' => 'Frontend\\Controllers\\'));
         $router->add('/login', array('controller' => 'login', 'module' => 'backend', 'namespace' => 'Backend\\Controllers\\'));
         return $router;
     });
     $application = new Phalcon\Mvc\Application();
     $view = new \Phalcon\Mvc\View();
     $application->registerModules(array('frontend' => function ($di) use($view) {
         $di->set('view', function () use($view) {
             $view = new \Phalcon\Mvc\View();
             $view->setViewsDir(__DIR__ . '/modules/frontend/views/');
             return $view;
         });
     }, 'backend' => function ($di) use($view) {
         $di->set('view', function () use($view) {
             $view->setViewsDir(__DIR__ . '/modules/backend/views/');
             return $view;
         });
     }));
     $application->setDi($di);
     $this->assertEquals($application->handle()->getContent(), '<html>here</html>' . PHP_EOL);
     $loader->unregister();
 }
Example #8
Show file File: trashbin.php Project: loulancn/core
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $appManager = \OC::$server->getAppManager();
     self::$trashBinStatus = $appManager->isEnabledForUser('files_trashbin');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     $application = new \OCA\Files_Sharing\AppInfo\Application();
     $application->registerMountProviders();
     //disable encryption
     \OC_App::disable('encryption');
     $config = \OC::$server->getConfig();
     //configure trashbin
     self::$rememberRetentionObligation = $config->getSystemValue('trashbin_retention_obligation', Files_Trashbin\Expiration::DEFAULT_RETENTION_OBLIGATION);
     $config->setSystemValue('trashbin_retention_obligation', 'auto, 2');
     // register hooks
     Files_Trashbin\Trashbin::registerHooks();
     // create test user
     self::loginHelper(self::TEST_TRASHBIN_USER2, true);
     self::loginHelper(self::TEST_TRASHBIN_USER1, true);
 }
Example #9
Show file File: CommentsServiceProvider.php Project: PhonemeCms/cms
0
 public function __construct(Application $app, Router $router, View $view)
 {
     parent::__construct($app);
     $this->app = $app;
     $this->router = $router;
     $this->view = $view;
 }
Example #10
Show file File: sent.php Project: luisbrito/Phraseanet
0
 protected function buildResult(Application $app, $rs)
 {
     $i = 0;
     foreach ($rs as $row) {
         if ($i >= $this->nb_record) {
             break;
         }
         foreach ($this->champ as $key => $value) {
             if ($row[$value]) {
                 if ($value == 'date') {
                     $this->result[$i][$value] = $this->pretty_string ? $this->app['date-formatter']->getPrettyString(new DateTime($row[$value])) : $row[$value];
                 } elseif ($value == 'size') {
                     $this->result[$i][$value] = p4string::format_octets($row[$value]);
                 } else {
                     $this->result[$i][$value] = $row[$value];
                 }
             } else {
                 if ($value == 'comment') {
                     $this->result[$i][$value] = '&nbsp;';
                 } else {
                     $this->result[$i][$value] = '<i>' . $this->app->trans('report:: non-renseigne') . '</i>';
                 }
             }
         }
         $i++;
     }
 }
Example #11
Show file File: ApplicationTest.php Project: luisbrito/Phraseanet
0
 /**
  * @covers Alchemy\Phrasea\Application
  */
 public function testDebug()
 {
     $app = new Application('prod');
     $this->assertFalse($app['debug']);
     $app = new Application(Application::ENV_TEST);
     $this->assertTrue($app['debug']);
     $app = new Application('dev');
     $this->assertTrue($app['debug']);
 }
Example #12
Show file File: ServiceProvider.php Project: crazycodr/phpDocumentor2
0
 /**
  * Initializes and adds the configuration merger object as the 'config.merger' service to the container.
  *
  * @param Application $container
  *
  * @return void
  */
 private function addMerger(Application $container)
 {
     $this->addMergerAnnotations($container);
     $container['config.merger'] = $container->share(function () {
         return new Merger(new AnnotationReader());
     });
 }
Example #13
Show file File: NewsLetterServiceProvider.php Project: PhonemeCms/cms
0
 public function __construct(Application $app, View $view, Router $router)
 {
     parent::__construct($app);
     $this->app = $app;
     $this->view = $view;
     $this->router = $router;
 }
Example #14
Show file File: 20151228143323_uuid_complex_short_pg.php Project: DeltaPHP/UUID
0
 public function up()
 {
     define('ROOT_DIR', realpath(__DIR__ . '/..'));
     // надо исключить realpath из кода и вынести в конфиг
     define('PUBLIC_DIR', ROOT_DIR . '/public');
     define('VENDOR_DIR', ROOT_DIR . '/vendor');
     define('DATA_DIR', ROOT_DIR . '/data');
     $loader = (include ROOT_DIR . "/vendor/autoload.php");
     $app = new Application();
     $app->setLoader($loader);
     $app->init();
     $epoch = $app->getConfig()->get(["UUID", "complexShort", "epoch"], 1451317149374);
     $shard = $app->getConfig(["UUID", "complexShort", "shard"], 1);
     $sql = "create sequence uuid_complex_short_part;";
     $this->execute($sql);
     $sql = <<<sql
ATE OR REPLACE FUNCTION uuid_short_complex(OUT result bigint) AS \$\$
LARE
 our_epoch bigint := {$epoch};
 seq_id bigint;
 now_millis bigint;
 shard_id int := {$shard};
IN
 SELECT nextval('uuid_complex_short_part') % 1024 INTO seq_id;

ECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp()) * 1000) INTO now_millis;
 result := (now_millis - our_epoch) << 23;
 result := result | (shard_id << 10);
 result := result | (seq_id);
;
$ LANGUAGE PLPGSQL;
;
     $this->execute($sql);
 }
Example #15
Show file File: MagentoHelper.php Project: brentwpeterson/n98-magerun2
0
 /**
  * @return array
  * @throws RuntimeException
  */
 public function getBaseConfig()
 {
     if (!$this->baseConfig) {
         $command = $this->getHelperSet()->getCommand();
         if ($command == null) {
             $application = new Application();
         } else {
             $application = $command->getApplication();
             /* @var $application Application */
         }
         $application->detectMagento();
         $configFiles = [$application->getMagentoRootFolder() . '/app/etc/config.php', $application->getMagentoRootFolder() . '/app/etc/env.php'];
         foreach ($configFiles as $configFile) {
             if (!is_readable($configFile)) {
                 throw new RuntimeException('app/etc/config.php is not readable');
             }
             $config = @(include $configFile);
             if (!is_array($config)) {
                 throw new RuntimeException('app/etc/config.php is corrupted. Please check it.');
             }
             $this->baseConfig = array_merge($this->baseConfig, $config);
         }
     }
     return $this->baseConfig;
 }
Example #16
Show file File: Module.php Project: estrom85/sample-codes
0
 public function __construct(Application $app)
 {
     $this->App = $app;
     $this->mRenderMode = false;
     $this->method = $this->getMethod();
     $this->data = $this->getData($this->method);
 }
Example #17
Show file File: Router.php Project: Avrel07/MyBank-Silex
0
 public static function loadRoutes(Application &$app, $file = null)
 {
     if ($file == null) {
         $file_content = file_get_contents(BASE_DIR . self::ROOT_ROUTING_FILE);
     } elseif (file_exists($file)) {
         $file_content = file_get_contents($file);
     } else {
         throw new FileNotFoundException($file);
     }
     $routes = Yaml::parse($file_content, true);
     foreach ($routes as $key => $route) {
         if (array_key_exists('resource', $route)) {
             self::loadRoutes($app, BASE_DIR . $route['resource']);
         } else {
             if (array_key_exists('path', $route) && array_key_exists('action', $route)) {
                 $app_route = $app->match($route['path'], $route['action'])->bind($key);
                 if (array_key_exists('method', $route)) {
                     $app_route->method($route['method']);
                 }
                 if (array_key_exists('values', $route)) {
                     foreach ($route['values'] as $key => $route_value) {
                         $app_route->value($key, $route_value);
                     }
                 }
                 if (array_key_exists('asserts', $route)) {
                     foreach ($route['asserts'] as $key => $route_assert) {
                         $app_route->assert($key, $route_assert);
                     }
                 }
             } else {
                 throw new MissingMandatoryParametersException('Path and action parameters are mandatory');
             }
         }
     }
 }
Example #18
Show file File: ApplicationTest.php Project: joan16v/symfony2_test
0
 public function testRun()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add($command = new \Foo1Command());
     $_SERVER['argv'] = array('cli.php', 'foo:bar1');
     ob_start();
     $application->run();
     ob_end_clean();
     $this->assertSame('Symfony\\Component\\Console\\Input\\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given');
     $this->assertSame('Symfony\\Component\\Console\\Output\\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $this->ensureStaticCommandHelp($application);
     $tester = new ApplicationTester($application);
     $tester->run(array(), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() runs the list command if no argument is passed');
     $tester->run(array('--help' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() runs the help command if --help is passed');
     $tester->run(array('-h' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() runs the help command if -h is passed');
     $tester->run(array('command' => 'list', '--help' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() displays the help if --help is passed');
     $tester->run(array('command' => 'list', '-h' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() displays the help if -h is passed');
     $tester->run(array('--ansi' => true));
     $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed');
     $tester->run(array('--no-ansi' => true));
     $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed');
     $tester->run(array('--version' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() displays the program version if --version is passed');
     $tester->run(array('-V' => true), array('decorated' => false));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->run() displays the program version if -v is passed');
     $tester->run(array('command' => 'list', '--quiet' => true));
     $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
     $tester->run(array('command' => 'list', '-q' => true));
     $this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
     $tester->run(array('command' => 'list', '--verbose' => true));
     $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');
     $tester->run(array('command' => 'list', '-v' => true));
     $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add(new \FooCommand());
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'foo:bar', '--no-interaction' => true), array('decorated' => false));
     $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed');
     $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false));
     $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
 }
Example #19
Show file File: CiconiaCommandTest.php Project: bencalie/Ciconia
0
 /**
  * @return CommandTester
  */
 protected function createCommandTester()
 {
     $application = new Application();
     $application->add(new CiconiaCommand());
     $command = $application->find('ciconia');
     return new CommandTester($command);
 }
Frequently Used Methods