PHP Class Application, huge Code Examples

This page contains top rated real world PHP examples of class Application from package huge extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: request_test.php Project: BigKBear/drive_safe
0
 function testGetFormRequestPost()
 {
     $app = new Application();
     $_POST['post'] = "Today I learnt that you can only treat your friends so badly before they quit working for you and go and work for Halutte(sp)";
     $array = $app->getArrayFromRequest();
     $this->assertEquals("Today I learnt that you can only treat your friends so badly before they quit working for you and go and work for Halutte(sp)", $array['post']);
 }
Example #2
Show file File: exception.php Project: roket007/bicycle
0
 public function __construct($message, $code)
 {
     Log::add($message . 'URI: ' . $_SERVER['REQUEST_URI'], $code);
     if (!DEV) {
         switch ($code) {
             case 500:
                 Fw_Request::setGet('hard_controller', 'err');
                 Fw_Request::setGet('hard_action', 'error' . $code);
                 $error_app = new Application();
                 $error_app->run();
                 die;
                 break;
             case 404:
             default:
                 Fw_Request::setGet('hard_controller', 'err');
                 Fw_Request::setGet('hard_action', 'error' . $code);
                 $error_app = new Application();
                 $error_app->run();
                 die;
                 break;
         }
     }
     $code = 0;
     parent::__construct($message);
 }
Example #3
Show file File: Application.php Project: rodrigoivan/processmaker
0
 /**
  * Implementation for 'POST' method for Rest API
  *
  * @param  mixed $appUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function post($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
 {
     try {
         $result = array();
         $obj = new Application();
         $obj->setAppUid($appUid);
         $obj->setAppNumber($appNumber);
         $obj->setAppParent($appParent);
         $obj->setAppStatus($appStatus);
         $obj->setProUid($proUid);
         $obj->setAppProcStatus($appProcStatus);
         $obj->setAppProcCode($appProcCode);
         $obj->setAppParallel($appParallel);
         $obj->setAppInitUser($appInitUser);
         $obj->setAppCurUser($appCurUser);
         $obj->setAppCreateDate($appCreateDate);
         $obj->setAppInitDate($appInitDate);
         $obj->setAppFinishDate($appFinishDate);
         $obj->setAppUpdateDate($appUpdateDate);
         $obj->setAppData($appData);
         $obj->setAppPin($appPin);
         $obj->save();
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
 }
Example #4
Show file File: admin.controller.php Project: postman0/1chan
0
 /**
  * Конструктор (проверка авторизации):
  */
 public function __construct(Application $application, Template $template)
 {
     $session = Session::getInstance();
     if (!$session->isAdminSession()) {
         die($application->go('errors_error403'));
     }
 }
Example #5
Show file File: PluginHandler.php Project: ehamrin/cmsPlugin
0
 public function AdminList(\Application $application)
 {
     $ret = '<h1>Manage plugins</h1>
         <div class="table-wrapper"><form action="" method="POST"><table><tr><th>Plugin Name</th><th>Active</th><th>Description</th><th>Version</th></tr>';
     $installed = $this->model->InstalledPlugins();
     foreach ($this->model->GetAvailablePlugins() as $available => $facade) {
         $data = $application->GetPluginMeta($available);
         if (!in_array($available, $application->GetConstantPlugins())) {
             $ret .= '<tr><td>' . (!empty($data->Name) ? $data->Name : $available) . '</td>
             <td>
             <div class="onoffswitch">
                 <input type="hidden" name="plugin[' . $available . '][action]" value="' . (!in_array($available, $installed) ? 'uninstalled' : '') . '"/>
                 <input type="checkbox" name="plugin[' . $available . '][value]" id="myonoffswitch_' . $available . '" class="onoffswitch-checkbox checkbox-submit" ' . (in_array($available, $installed) ? 'checked="checked"' : '') . '/>
                 <label class="onoffswitch-label" for="myonoffswitch_' . $available . '">
                     <span class="onoffswitch-inner"></span>
                     <span class="onoffswitch-switch"></span>
                 </label>
             </div>
             </td>
             <td>' . (!empty($data->Description) ? $data->Description : '<em>Unavailable</em>') . '</td>
             <td>' . (!empty($data->Version) ? $data->Version : '<em>Unavailable</em>') . '</td></tr>';
         }
     }
     return $ret . '</table></div><input type="hidden" name="placeholder" value="1"/><button type="submit" name="submit">Submit</button></form>';
 }
Example #6
Show file File: BaseController.php Project: donatienthorez/sf_mobilIT_backEnd
0
 private static function createDatabase()
 {
     $application = new Application(static::$kernel);
     // drop the database
     $command = new DropDatabaseDoctrineCommand();
     $application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:drop', '--force' => true));
     $command->run($input, new NullOutput());
     // we have to close the connection after dropping the database
     //  so we don't get "No database selected" error
     $connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection();
     if ($connection->isConnected()) {
         $connection->close();
     }
     // create the database
     $command = new CreateDatabaseDoctrineCommand();
     $application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:database:create'));
     $command->run($input, new NullOutput());
     // create the database
     $command = new CreateSchemaDoctrineCommand();
     $application->add($command);
     $input = new ArrayInput(array('command' => 'doctrine:schema:create', '--em' => 'default'));
     $command->run($input, new NullOutput());
     // get the Entity Manager
     $em = static::$kernel->getContainer()->get('doctrine')->getManager();
     // load fixtures
     $client = static::createClient();
     $loader = new ContainerAwareLoader($client->getContainer());
     $loader->loadFromDirectory(static::$kernel->locateResource('@MainBundle/DataFixtures/ORM'));
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->execute($loader->getFixtures());
 }
Example #7
Show file File: base.php Project: alexmixaylov/real
0
 /**
  * @param array $app
  * @param array $config
  * @throws AppException
  */
 public function __construct($app, $config = array())
 {
     parent::__construct($app, $config);
     $this->_jbrequest = $this->app->jbrequest;
     $task = $this->_jbrequest->getWord('task');
     $ctrl = $this->_jbrequest->getCtrl();
     if (!method_exists($this, $task)) {
         throw new AppException('Action method not found!  ' . $ctrl . ' :: ' . $task . '()');
     }
     // internal vars
     $this->application = $this->app->zoo->getApplication();
     $this->_params = $this->application->getParams('frontpage');
     $this->joomla = $this->app->system->application;
     $isSite = $this->app->jbenv->isSite();
     if (!$isSite) {
         $this->app->document->addStylesheet("root:administrator/templates/system/css/system.css");
         $this->app->jbassets->uikit(true, true);
         $this->_setToolbarTitle();
     } else {
         $this->params = $this->joomla->getParams();
         $this->pathway = $this->joomla->getPathway();
         $this->app->jbassets->setAppCSS();
         $this->app->jbassets->setAppJS();
     }
     $this->_config = JBModelConfig::model();
 }
Example #8
Show file File: Action.class.php Project: sanplit/huishou
0
 /**
  * 退出登录处理
  *
  */
 public function doLogout()
 {
     $_SESSION['admin'] = false;
     session_destroy();
     $this->app->redirect($this->app->cfg['url']['root'] . 'system/');
     exit;
 }
Example #9
Show file File: Rfc6455Protocol.php Project: icicleio/websocket
0
 /**
  * {@inheritdoc}
  */
 public function createResponse(Application $application, Request $request, Socket $socket) : Response
 {
     if (!$request->hasHeader('Sec-WebSocket-Key')) {
         $sink = new MemorySink('No WebSocket key header provided.');
         return new BasicResponse(Response::BAD_REQUEST, ['Connection' => 'close', 'Content-Length' => $sink->getLength()], $sink);
     }
     $headers = ['Connection' => 'upgrade', 'Upgrade' => 'websocket', 'Sec-WebSocket-Accept' => $this->responseKey(trim($request->getHeader('Sec-WebSocket-Key')))];
     if ($application instanceof SubProtocol) {
         $protocol = $application->selectSubProtocol(array_map('trim', explode(',', $request->getHeader('Sec-WebSocket-Protocol'))));
         if (strlen($protocol)) {
             $headers['Sec-WebSocket-Protocol'] = $protocol;
         }
     }
     /*
     $extensions = $application->selectExtensions(
         array_map('trim', explode(',', $request->getHeader('Sec-WebSocket-Extensions')))
     );
     
     if (!empty($extensions)) {
         $headers['Sec-WebSocket-Extensions'] = $extensions;
     }
     */
     $response = new BasicResponse(Response::SWITCHING_PROTOCOLS, $headers);
     $connection = $this->createConnection($response, $socket, false);
     return new WebSocketResponse($application, $connection, $response);
 }
Example #10
Show file File: Bootstrap.php Project: hscale/curator
0
/**
 * Preps the application for running, then runs it. If this function is called more than once, an E_USER_ERROR is triggered.
 * 
 * @param string $root_dir The path to the root of the installation.
 * @return void
 */
function StartCurator()
{
    static $did_start = false;
    // set up the exit status.
    $exit_status = 0;
    // make sure this is only run once.
    if ($did_start === false) {
        $autoload = Autoload::singleton();
        // configure the autoloader.
        try {
            $autoload->setBaseDir(CURATOR_APP_DIR);
            $autoload->register();
        } catch (\Exception $e) {
            Console::stderr('** Could not register the autoloader:');
            Console::stderr('   ' . $e->getMessage());
            die;
        }
        // once the autoloader is in place, we are started up.
        $did_start = true;
        try {
            $app = new Application();
            $exit_status = $app->run();
        } catch (\Exception $e) {
            Console::stderr('** Could not run the application:');
            Console::stderr('   ' . $e->getMessage());
            die;
        }
    } else {
        // if we are called again, bail.
        trigger_error('StartCurator called after already being called.', E_USER_ERROR);
    }
    // send the status back.
    return $exit_status;
}
Example #11
Show file File: Controller.php Project: clagiordano/weblibs-mvc
0
 /**
  *
  * @param clagiordano\weblibs\mvc\Application $application
  * @return clagiordano\weblibs\mvc\Controller
  */
 public function __construct(Application $application)
 {
     $this->application = $application;
     $this->request = new Request();
     $this->application->getRegistry()->requestType = $this->request->getType();
     $this->application->getRegistry()->requestData = $this->request->getData();
 }
Example #12
Show file File: framework.php Project: rudenyl/kcms
0
 /**
 	Get core application class
 		@public
 	**/
 static function &getApplication()
 {
     static $app;
     // create if don't exists
     if (!is_object($app)) {
         // single app instance only
         if (isset($GLOBALS['_globalapp'])) {
             $app = $GLOBALS['_globalapp'];
         } else {
             $app = new Application();
             // config
             $config =& Factory::getConfig();
             $app->set('config', $config);
             // authentication
             $auth =& Factory::getAuth();
             $app->set('auth', $auth);
             // set our timezone
             if (isset($config->timezone)) {
                 @(list($tz_script, $tz_db) = explode('|', $config->timezone));
                 date_default_timezone_set($tz_script);
             }
             $GLOBALS['_globalapp'] = $app;
         }
     }
     return $app;
 }
Example #13
Show file File: view.php Project: moomot/Simple-MVC-CMS
0
 public function generatePage($view, $data = array())
 {
     $app = new Application();
     $template = $app->getTemplate();
     include $template;
     //include PATH_SITE.'/templates/default_theme/index.php';
 }
Example #14
Show file File: Application.php Project: kylewm/KnownOAuth2
0
 /**
  * Helper function to create a new application with a new keypair.
  * @param type $title
  * @return \IdnoPlugins\OAuth2\Application
  */
 public static function newApplication($title)
 {
     $app = new Application();
     $app->setTitle($title);
     $app->generateKeypair();
     return $app;
 }
Example #15
Show file File: ValidationCommandBus.php Project: flyingfoxx/commandcenter
0
 /**
  * Execute a command.
  *
  * @param $command
  * @return mixed
  */
 public function execute($command)
 {
     $validator = $this->translator->toValidator($command);
     if (class_exists($validator)) {
         $this->app->make($validator)->validate($command);
     }
     return $this->bus->execute($command);
 }
Example #16
Show file File: Menu.php Project: bedezign/yii2-desktop
0
 /**
  * Add a new main menu. Sticky means that it will be shown for all applications.
  *
  * @param MenuShortcut $menu
  * @param Application $application     The application this menu is linked to, if null it is always shown
  */
 public function addMenu(MenuShortcut $menu, Application $application = null)
 {
     $context = $application ? $application->getApplicationId() : 'global';
     if (!isset($this->menus[$context])) {
         $this->menus[$context] = [];
     }
     $this->menus[$context][] = $menu;
 }
Example #17
Show file File: User.php Project: kzfk/emlauncher
0
 public function getAppInstallDate(Application $app, $format = null)
 {
     $install_apps = $this->getInstallApps();
     if (isset($install_apps[$app->getId()])) {
         return $install_apps[$app->getId()]->getLastInstalled();
     }
     return null;
 }
Example #18
Show file File: PageRepository.php Project: Jazzee/Jazzee
0
 /**
  * Check if a page has any answers associated with it for a specific application
  * @param Page $page
  * @param Application $application
  * @return boolean
  */
 public function hasApplicationAnswers(Page $page, Application $application)
 {
     $query = $this->_em->createQuery('SELECT COUNT(answer.id) as ancnt FROM Jazzee\\Entity\\Answer answer JOIN answer.applicant applicant WHERE answer.page = :pageId AND applicant.application = :applicationId');
     $query->setParameter('pageId', $page->getId());
     $query->setParameter('applicationId', $application->getId());
     $result = $query->getResult();
     return $result[0]['ancnt'] > 0;
 }
Example #19
Show file File: CollectorManager.php Project: opis-colibri/core
0
 /**
  * Unregister a collector
  * 
  * @param   string  $name
  */
 public function unregisterCollector($name)
 {
     $name = strtolower($name);
     $collectors = $this->app->config()->read('collectors');
     $collectors += $this->getCollectors();
     unset($collectors[$name]);
     $this->app->config()->write('collectors', $collectors);
 }
Example #20
Show file File: message.php Project: cyan-framework/cms
0
 /**
  * Enqueue message and redirect
  *
  * @param Application $App
  * @param $type
  * @param $message
  * @param $redirect_identifier
  * @param $redirect_parameters
  */
 public static function enqueueRedirect($App, $type, $message, $redirect_identifier, $redirect_parameters = [])
 {
     if (!$App instanceof \Cyan\Framework\ApplicationWeb) {
         throw new \Cyan\Framework\ApplicationException('$App must be a instance of Cyan\\Framework\\ApplicationWeb.');
     }
     $type = strtolower($type);
     $App->enqueueMessage($App->Text->translate($message), ucfirst($type), self::$classes[$type]);
     $App->Router->redirect(strpos($redirect_identifier, '://') === false ? $App->Router->generate($redirect_identifier, $redirect_parameters) : $redirect_identifier);
 }
Example #21
Show file File: Facade.php Project: Doraemons/framework
0
 /**
  * Create a fresh mock instance for the given class.
  *
  * @param  string  $name
  * @return \Mockery\Expectation
  */
 protected static function createFreshMockInstance($name)
 {
     static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
     $mock->shouldAllowMockingProtectedMethods();
     if (isset(static::$app)) {
         static::$app->instance($name, $mock);
     }
     return $mock;
 }
Example #22
Show file File: ApplicationTest.php Project: AroundPBT/PHPBoost
0
 function test__get_installed_version()
 {
     $id = 'news';
     $language = 'french';
     $app = new Application($id, $language);
     $vers = $app->_get_installed_version();
     self::assertEquals($vers, '0');
     // TODO(__FILE__, __METHOD__);
 }
Example #23
Show file File: Controller.php Project: rikimarutest/gittest
0
 /**
  * コンストラクタ
  *
  * @param Application $application
  */
 public function __construct($application)
 {
     $this->controller_name = strtolower(substr(get_class($this), 0, -10));
     $this->application = $application;
     $this->request = $application->getRequest();
     $this->response = $application->getResponse();
     $this->session = $application->getSession();
     $this->db_manager = $application->getDbManager();
 }
Example #24
Show file File: HttpRequest.php Project: tymiles003/FieldWorkManager
0
 public function initLanguage(Application $currentApp, $type)
 {
     if ($type === "default") {
         return $currentApp->config()->get(Enums\AppSettingKeys::DefaultLanguage);
     }
     if ($type === "browser") {
         return substr(strtok($_SERVER['HTTP_ACCEPT_LANGUAGE'], '?'), 0, 2);
     }
 }
Example #25
Show file File: wordpress-plugin.php Project: ThemeWP/wordpress-plugin
0
/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function run()
{
    /**
     * The core plugin class that is used to define internationalization,
     * admin-specific hooks, and public-facing site hooks.
     */
    $plugin = new Application();
    $plugin->run();
}
Example #26
Show file File: Service.php Project: fortSQ/portfolio
0
 private function __construct(Application $app)
 {
     $this->app = $app;
     if (!$this->name) {
         //throw new Exception(sprintf('The name of service %s is not defined', static::class));
         throw new Exception(sprintf('The name of service %s is not defined', get_called_class()));
     }
     $app->addService($this->name, $this);
 }
Example #27
Show file File: install.php Project: NavaINT1876/ccustoms
0
 /**
  * Uninstall Application
  *
  * @param Application $application
  * @since 2.0
  * @throws InstallHelperException
  */
 public function uninstallApplication(Application $application)
 {
     $group = $application->getGroup();
     if ($this->_applicationExists($group)) {
         throw new InstallHelperException('Delete existing applications first.');
     }
     if (!($directory = $this->app->path->path("applications:{$group}")) || !JFolder::delete($directory)) {
         throw new InstallHelperException('Unable to delete directory: (' . $directory . ')');
     }
 }
Example #28
Show file File: Router.php Project: anddorua/boardroom
0
 private function needSetPassword(Application $app, Database $db, \DBMappers\EmpItem $empMapper)
 {
     if ($app->isAuthorized()) {
         $empItem = $empMapper->getById($app->getEmpId(), $db);
         if ($empItem->isPasswordEqual(null) && $this->controllerName != EMPLOYEE_CONTROLLER && $this->controllerName != LOGIN_CONTROLLER) {
             $app->setStateRedirect(EMPLOYEE_URL . '/edit/' . $empItem->getId());
             return true;
         }
     }
     return false;
 }
Example #29
Show file File: jblayout.php Project: JBZoo/JBZoo-CCK-Free
0
 /**
  * Constructor, set internal vars
  * @param $app
  */
 public function __construct($app)
 {
     // load libs
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // set internal vars
     $this->app = $app;
     $this->_name = strtolower(basename(get_class($this), 'Helper'));
     $this->_application = $app->zoo->getApplication();
     $this->_rendererPath = $this->_application->getPath() . '/templates/' . $this->_application->params->get('template') . '/renderer';
 }
Example #30
Show file File: application.php Project: Geekathon/rat
0
 public static function initialise()
 {
     require_once 'vendor/autoload.php';
     try {
         require_once 'lib/routing.php';
         $uri = Routing::fetch_uri();
         $controller = ucfirst($uri['controller']) . 'Controller';
         @(include "controllers/{$uri['controller']}_controller.php");
         if (substr($uri['action'], 0, 1) == '?') {
             $uri['action'] = '';
         }
         if (empty($uri['action']) && method_exists($controller, 'index')) {
             $uri['action'] = 'index';
         }
         // If controller found and action exists
         if (class_exists($controller) && method_exists($controller, $uri['action'])) {
             $app = new $controller();
         } else {
             $uri = Routing::route();
             $controller = ucfirst($uri['controller']) . 'Controller';
             include "controllers/{$uri['controller']}_controller.php";
             $app = new $controller();
         }
         $app->loadConfig();
         $app->loadTwig();
         $app->loadAws();
         $app->loadModels();
         $app->loadPlugins();
         $app->uri = $uri;
         // Helper var to simplify reponding to json
         $app->json = $app->uri['format'] == 'json';
         require_once 'lib/filter.php';
         $app->runFilters();
         $app->loadDefaultLibs();
         // Set timezone from config
         date_default_timezone_set($config->timezone);
         // Call relevant function in controller
         $app->loadAction();
         unset($_SESSION['flash']);
     } catch (ValidationException $e) {
         ob_end_clean();
         Application::flash('error', $e->getMessage());
         header('Location: ' . $_SERVER['HTTP_REFERER']);
     } catch (RoutingException $e) {
         ob_end_flush();
         // RoutingExceptions only thrown from static context
         // so must set up new Application before rendering 404
         $app = new Application();
         $app->loadView('pages/404');
     } catch (ApplicationException $e) {
         ob_end_flush();
         $e->app->loadView('pages/500');
     }
 }
Frequently Used Methods