当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim::stop方法代码示例

本文整理汇总了PHP中Slim::stop方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::stop方法的具体用法?PHP Slim::stop怎么用?PHP Slim::stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim的用法示例。


在下文中一共展示了Slim::stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fileFsPost

 public function fileFsPost()
 {
     LFileTest::createTests();
     $this->app->response->setBody(LFileTest::$Tester->gibSituationsdaten('fileFsPost'));
     $this->app->response->setStatus(201);
     $this->app->stop();
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:7,代码来源:LFileTest.php

示例2: getExistsCourse

 /**
  * Returns whether the component is installed for the given course
  *
  * Called when this component receives an HTTP GET request to
  * /link/exists/course/$courseid(/).
  *
  * @param int $courseid A course id.
  */
 public function getExistsCourse($courseid)
 {
     $result = Request::routeRequest('GET', '/process/course/' . $courseid . '/component/' . $this->_conf->getId(), $this->app->request->headers->all(), '', $this->_getProcess, 'process');
     if (isset($result['status']) && $result['status'] >= 200 && $result['status'] <= 299 && isset($result['content']) && $this->_conf !== null && $this->_conf->getId() !== null) {
         $this->app->response->setStatus(200);
         $this->app->stop();
     }
     $this->app->response->setStatus(409);
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:17,代码来源:LFormProcessor.php

示例3: getExtension

 /**
  * Returns informations about a given extension
  *
  * Called when this component receives an HTTP GET request to
  * /link/extension/$name(/).
  *
  * @param int $name The name of the component
  */
 public function getExtension($name)
 {
     foreach ($this->_extension as $link) {
         if ($link->getTargetName() === $name || $link->getTarget() === $name) {
             $this->app->response->setStatus(200);
             $this->app->response->setBody(Link::encodeLink($link));
             $this->app->stop();
         }
     }
     $this->app->response->setStatus(404);
     $this->app->response->setBody(null);
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:20,代码来源:LExtension.php

示例4: getExistsCourse

 /**
  * Returns whether the component is installed for the given course
  *
  * Called when this component receives an HTTP GET request to
  * /link/exists/course/$courseid(/).
  *
  * @param int $courseid A course id.
  */
 public function getExistsCourse($courseid)
 {
     // hier soll geprüft werden, ob ein entsprechender Eintrag für diese Komponente in der referenzierten Prozesstabelle besteht,
     // ob sie also als Verarbeitung registriert ist (dazu wird die ID dieser Komponente verwendet ($this->_conf->getId()))
     $result = Request::routeRequest('GET', '/process/course/' . $courseid . '/component/' . $this->_conf->getId(), array(), '', $this->_getProcess, 'process');
     // wenn etwas für die ID dieser Komponente von der DB geantwortet wird, ist die Installation korrekt bzw. vorhanden.
     if (isset($result['status']) && $result['status'] >= 200 && $result['status'] <= 299 && isset($result['content']) && $this->_conf !== null && $this->_conf->getId() !== null) {
         $this->app->response->setStatus(200);
         $this->app->stop();
     }
     // die Datenbank hat keinen Eintrag für diese Komponente geliefert oder ein sonstiger Fehler ist aufgetreten, daher
     // gilt die Installation als nicht vorhanden/korrekt
     $this->app->response->setStatus(409);
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:22,代码来源:LOOP.php

示例5: addPlatform

 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform()
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     // decode the received course data, as an object
     $insert = Platform::decodePlatform($this->_app->request->getBody());
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         $file = dirname(__FILE__) . '/config.ini';
         $text = "[DB]\n" . "db_path = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseUrl()) . "\"\n" . "db_user = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorUser()) . "\"\n" . "db_passwd = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseOperatorPassword()) . "\"\n" . "db_name = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getDatabaseName()) . "\"\n" . "[PL]\n" . "urlExtern = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getExternalUrl()) . "\"\n" . "url = \"" . str_replace(array("\\", "\""), array("\\\\", "\\\""), $in->getBaseUrl()) . "\"";
         if (!@file_put_contents($file, $text)) {
             Logger::Log('POST AddPlatform failed, config.ini no access', LogLevel::ERROR);
             $this->_app->response->setStatus(409);
             $this->_app->stop();
         }
         // starts a query
         ob_start();
         eval("?>" . file_get_contents(dirname(__FILE__) . '/Sql/AddPlatform.sql'));
         $sql = ob_get_contents();
         ob_end_clean();
         $result = DBRequest::request2($sql, false, parse_ini_file(dirname(__FILE__) . '/config.ini', TRUE));
         // checks the correctness of the query
         if (!isset($result['errno']) || !$result['errno']) {
             $platform = new Platform();
             $platform->setStatus(201);
             $res[] = $platform;
             $this->_app->response->setStatus(201);
         } else {
             Logger::Log('POST AddPlatform failed', LogLevel::ERROR);
             $this->_app->response->setStatus(409);
             $this->_app->response->setBody(Platform::encodePlatform($res));
             $this->_app->stop();
         }
     }
     if (!$arr && count($res) == 1) {
         $this->_app->response->setBody(Platform::encodePlatform($res[0]));
     } else {
         $this->_app->response->setBody(Platform::encodePlatform($res));
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:52,代码来源:CControl.php

示例6: deleteCourse

 /**
  * Deletes a course.
  *
  * Called when this component receives an HTTP DELETE request to
  * /course/course/$courseid(/).
  *
  * @param int $courseid The id of the course that is being deleted.
  *
  * @author Till Uhlig
  * @date 2014
  */
 public function deleteCourse($courseid)
 {
     Logger::Log('starts DELETE DeleteCourse', LogLevel::DEBUG);
     $this->app->response->setStatus(201);
     $header = $this->app->request->headers->all();
     $courseid = DBJson::mysql_real_escape_string($courseid);
     foreach ($this->_deleteCourse as $_link) {
         $result = Request::routeRequest('DELETE', '/course/' . $courseid, $header, '', $_link, 'course');
         // checks the correctness of the query
         if ($result['status'] == 201) {
             // ok
         } else {
             Logger::Log('DELETE DeleteCourse failed', LogLevel::ERROR);
             $this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->app->stop();
         }
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:29,代码来源:LCourse.php

示例7: addCourse

 /**
  * Adds the component to a course
  *
  * Called when this component receives an HTTP POST request to
  * (/:preChoice(/:preForm(/:preExercise)))/course(/).
  *
  * @param int $preChoice A optional prefix for the Choice table.
  * @param int $preForm A optional prefix for the Form table.
  * @param int $preExercise A optional prefix for the Exercise table.
  */
 public function addCourse($preChoice = '', $preForm = '', $preExercise = '')
 {
     $this->loadConfig($preChoice, $preForm, $preExercise);
     $preChoice = ($preChoice === '' ? '' : '_') . $preChoice;
     $preForm = ($preForm === '' ? '' : '_') . $preForm;
     $preExercise = ($preExercise === '' ? '' : '_') . $preExercise;
     Logger::Log('starts POST AddCourse', LogLevel::DEBUG);
     // decode the received course data, as an object
     $insert = Course::decodeCourse($this->_app->request->getBody());
     $preChoice = DBJson::mysql_real_escape_string($preChoice);
     $preForm = DBJson::mysql_real_escape_string($preForm);
     $preExercise = DBJson::mysql_real_escape_string($preExercise);
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         // starts a query, by using a given file
         $result = DBRequest::getRoutedSqlFile($this->query, dirname(__FILE__) . '/Sql/AddCourse.sql', array('object' => $in, 'preChoice' => $preChoice, 'preForm' => $preForm, 'preExercise' => $preExercise));
         // checks the correctness of the query
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $queryResult = Query::decodeQuery($result['content']);
             $res[] = $in;
             $this->_app->response->setStatus(201);
             if (isset($result['headers']['Content-Type'])) {
                 $this->_app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
         } else {
             Logger::Log('POST AddCourse failed', LogLevel::ERROR);
             $this->_app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->_app->response->setBody(Course::encodeCourse($res));
             $this->_app->stop();
         }
     }
     if (!$arr && count($res) == 1) {
         $this->_app->response->setBody(Course::encodeCourse($res[0]));
     } else {
         $this->_app->response->setBody(Course::encodeCourse($res));
     }
 }
开发者ID:ostepu,项目名称:ostepu-forms,代码行数:54,代码来源:DBChoice.php

示例8: deleteCourse

 /**
  * Removes the component from a given course
  *
  * Called when this component receives an HTTP DELETE request to
  * /course/$courseid(/).
  */
 public function deleteCourse($courseid)
 {
     Logger::Log('starts DELETE DeleteCourse', LogLevel::DEBUG);
     $courseid = DBJson::mysql_real_escape_string($courseid);
     foreach ($this->_createCourse as $_link) {
         $result = Request::routeRequest('DELETE', '/course/' . $courseid, array(), '', $_link, 'course');
         // checks the correctness of the query
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $this->app->response->setStatus(201);
             if (isset($result['headers']['Content-Type'])) {
                 $this->app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
         } else {
             Logger::Log('POST DeleteCourse failed', LogLevel::ERROR);
             $this->app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->app->stop();
         }
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:25,代码来源:LProcessor.php

示例9: addPlatform

 /**
  * Adds the component to the platform
  *
  * Called when this component receives an HTTP POST request to
  * /platform.
  */
 public function addPlatform()
 {
     Logger::Log('starts POST AddPlatform', LogLevel::DEBUG);
     // decode the received course data, as an object
     $insert = Platform::decodePlatform($this->_app->request->getBody());
     // always been an array
     $arr = true;
     if (!is_array($insert)) {
         $insert = array($insert);
         $arr = false;
     }
     // this array contains the indices of the inserted objects
     $res = array();
     foreach ($insert as $in) {
         // starts a query, by using a given file
         $result = DBRequest::getRoutedSqlFile($this->query2, dirname(__FILE__) . '/Sql/AddPlatform.sql', array('object' => $in), false);
         // checks the correctness of the query
         if ($result['status'] >= 200 && $result['status'] <= 299) {
             $queryResult = Query::decodeQuery($result['content']);
             $res[] = $in;
             $this->_app->response->setStatus(201);
             if (isset($result['headers']['Content-Type'])) {
                 $this->_app->response->headers->set('Content-Type', $result['headers']['Content-Type']);
             }
         } else {
             Logger::Log('POST AddPlatform failed', LogLevel::ERROR);
             $this->_app->response->setStatus(isset($result['status']) ? $result['status'] : 409);
             $this->_app->response->setBody(Platform::encodePlatform($res));
             $this->_app->stop();
         }
     }
     if (!$arr && count($res) == 1) {
         $this->_app->response->setBody(Platform::encodePlatform($res[0]));
     } else {
         $this->_app->response->setBody(Platform::encodePlatform($res));
     }
 }
开发者ID:sawh,项目名称:ostepu-system,代码行数:43,代码来源:DBAttachment.php

示例10: testSlimStop

 /**
  * Test Slim Stop
  *
  * Pre-conditions:
  * You have initialized a Slim application and stop
  * the application inside of a route callback.
  *
  * Post-conditions:
  * A SlimStopException is thrown;
  * The response is unaffected by code after Slim::stop is called
  */
 public function testSlimStop() {
     Slim::init();
     Slim::get('/', function () {
         try {
             echo "foo";
             Slim::stop();
             echo "bar";
         } catch ( Slim_Exception_Stop $e ) {}
     });
     Slim::run();
     $this->assertEquals(Slim::response()->body(), 'foo');
 }
开发者ID:ntdt,项目名称:Slim,代码行数:23,代码来源:SlimTest.php

示例11: function

$app->configureMode('development', function () use($app) {
    $app->config(array('debug' => true));
});
$app->configureMode('production', function () use($app) {
    error_reporting(0);
    $app->notFound(function () use($app) {
        $page = new ErrorController(404);
        $page->render();
    });
    $app->error(function (Exception $e) use($app) {
        $app->response()->status(500);
        if (!$app->request()->isAjax()) {
            $page = new ErrorController(500);
            $page->render();
        }
        $app->stop();
        if (file_exists(BASE_DIR . '/.gbemail')) {
            foreach (explode('\\n', file_get_contents(BASE_DIR . '/.gbemail')) as $email) {
                mail(trim($email), "GetchaBooks Error", get_error_message($e));
            }
        }
    });
});
$app->hook('slim.before', function () use($app) {
    global $referrers;
    $request = $app->request();
    define('BASE_URL', $request->getUrl() . $request->getRootUri() . '/');
    define('CURRENT_URL', $request->getUrl() . $request->getPath());
    define('MOBILE_DEVICE', strpos(strtolower($request->getUserAgent()), 'mobile') !== false);
    // remove extra slashes
    $path = $request->getPath();
开发者ID:therealchiko,项目名称:getchabooks,代码行数:31,代码来源:index.php

示例12: testStopDoesNotLeaveOutputBuffersOpen

 /**
  * Test stop does not leave output buffers open
  */
 public function testStopDoesNotLeaveOutputBuffersOpen()
 {
     $level_start = ob_get_level();
     $s = new Slim();
     $s->get('/bar', function () use($s) {
         $s->stop();
     });
     $s->run();
     $this->assertEquals($level_start, ob_get_level());
 }
开发者ID:rs3d,项目名称:Slimplr,代码行数:13,代码来源:SlimTest.php

示例13: testStopWithSubsequentOutput

 /**
  * Test stop with subsequent output
  */
 public function testStopWithSubsequentOutput()
 {
     $this->expectOutputString('Foo');
     $s = new Slim();
     $s->get('/bar', function () use($s) {
         echo "Foo";
         //<-- Should be in response body!
         $s->stop();
         echo "Bar";
         //<-- Should not be in response body!
     });
     $s->call();
     $this->assertEquals('Foo', $s->response()->body());
 }
开发者ID:renvieir,项目名称:emprestae,代码行数:17,代码来源:SlimTest.php

示例14: testSlimStop

 /**
  * Test Slim Stop
  *
  * Pre-conditions:
  * Slim app instantiated;
  * Slim app stopped while route invocation in process;
  *
  * Post-conditions:
  * Slim ignores output after `stop()` is invoked;
  */
 public function testSlimStop()
 {
     $app = new Slim();
     $app->get('/', function () use($app) {
         try {
             echo "foo";
             $app->stop();
             echo "bar";
         } catch (Slim_Exception_Stop $e) {
         }
     });
     $app->run();
     $this->assertEquals('foo', $app->response()->body());
 }
开发者ID:inscriptionweb,项目名称:lebonmail,代码行数:24,代码来源:SlimTest.php

示例15: testStopWithSubsequentOutput

 /**
  * Test stop with subsequent output
  */
 public function testStopWithSubsequentOutput()
 {
     $this->expectOutputString('Foo');
     $s = new Slim();
     $s->get('/bar', function () use($s) {
         echo "Foo";
         //<-- Should be in response body!
         $s->stop();
         echo "Bar";
         //<-- Should not be in response body!
     });
     $env = $s->environment();
     list($status, $header, $body) = $s->call($env);
     $this->assertEquals('Foo', $body);
 }
开发者ID:nerdfiles,项目名称:slim_bp,代码行数:18,代码来源:SlimTest.php


注:本文中的Slim::stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。