/**
  * {@InheritDoc}
  */
 public function init()
 {
     //  Admins only!
     if (!Session::isSystemAdmin()) {
         throw new \CHttpException(HttpResponse::Forbidden, 'Access Denied.');
     }
     parent::init();
     //	We want merged update/create...
     $this->setSingleViewMode(true);
     $this->layout = 'mobile';
     $this->defaultAction = 'index';
     //	Everything is auth-required
     $this->addUserActions(static::Authenticated, array('cache', 'index', 'update', 'error', 'create'));
     //  Set the command map
     static::$_cacheCommandMap = array('flush' => function () {
         return Platform::storeDeleteAll();
     });
 }
Exemple #2
0
 public function testServiceRequestEvents()
 {
     //	A post test
     Platform::on('user.list', 'http://dsp.local/web/eventReceiver', static::API_KEY);
     //	An inline test
     Platform::on('user.list', function ($event, $eventName, $dispatcher) {
         $this->assertEquals('user.list', $eventName);
         $this->_actionEventFired = 1;
         echo 'event "user.list" has been fired.';
     }, static::API_KEY);
     $this->_preProcessFired = $this->_postProcessFired = 0;
     $_config = (require dirname(dirname(__DIR__)) . '/config/web.php');
     /** @var \RestController $_controller */
     list($_controller, $_actionId) = Pii::app()->createController('rest/user');
     try {
         $_controller->setService('user');
         $_service = ServiceHandler::getService($_controller->getService());
         $_service->on(PlatformServiceEvents::PRE_PROCESS, function ($event, $eventName, $dispatcher) {
             $this->assertEquals('user.get.pre_process', $eventName);
             $this->_preProcessFired = 1;
         });
         $_service->on(PlatformServiceEvents::POST_PROCESS, function ($event, $eventName, $dispatcher) {
             $this->assertEquals('user.get.post_process', $eventName);
             $this->_postProcessFired = 1;
         });
         //	Test GET
         $_request = Pii::app()->getRequestObject();
         $_request->query->set('app_name', Inflector::neutralize(__CLASS__));
         $_request->overrideGlobals();
         $_response = $_service->processRequest(null, HttpMethod::GET, false);
         $this->assertTrue(is_array($_response) && isset($_response['resource']));
         $this->assertTrue(1 == $this->_preProcessFired && 1 == $this->_postProcessFired && 1 == $this->_actionEventFired);
     } catch (\Exception $ex) {
         RestResponse::sendErrors($ex);
     }
 }
Exemple #3
0
 /**
  * @param string $cache Which cache to flush
  *
  * @return bool
  * @throws DreamFactory\Platform\Exceptions\BadRequestException
  */
 public function actionFlush($cache)
 {
     $this->layout = false;
     switch (strtolower($cache)) {
         case 'platform':
             Platform::storeDeleteAll();
             Pii::flushConfig();
             break;
         case 'swagger':
             SwaggerManager::clearCache();
             break;
         default:
             throw new BadRequestException();
     }
     echo json_encode(array('success' => true, 'cache' => $cache));
     return Pii::end();
 }
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
use DreamFactory\Platform\Enums\InstallationTypes;
use DreamFactory\Platform\Utility\Platform;
/**
 * database.config.php-dist
 *
 * If you do not want to use the default MySQL instance, you can override the settings with this template.
 * Copy this file to "config/database.config.php" and change the settings to your liking.
 *
 * Below are the actual default MySQL instance settings
 */
//  Need to make sure we have the autoloader set up in case this is called by the installer
if (!class_exists('\\Yii', false)) {
    require_once dirname(__DIR__) . '/vendor/autoload.php';
    require_once dirname(__DIR__) . '/vendor/dreamfactory/yii/framework/yiilite.php';
}
//  Set a key about where we live...
Platform::storeSet(INSTALL_TYPE_KEY, InstallationTypes::STANDALONE_PACKAGE);
return array('connectionString' => 'mysql:host=' . getenv('DB_HOST') . ';port=' . getenv('DB_PORT') . ';dbname=' . getenv('DB_NAME'), 'username' => getenv('DB_USER'), 'password' => getenv('DB_PASS'), 'emulatePrepare' => true, 'charset' => 'utf8', 'enableProfiling' => defined('YII_DEBUG'), 'enableParamLogging' => defined('YII_DEBUG'), 'schemaCachingDuration' => 3600);
 /**
  * Constructor
  */
 public function __construct()
 {
     //  Register with the event dispatcher
     Platform::getDispatcher()->addSubscriber($this);
 }
 /**
  * @covers DreamFactory\Platform\Utility\Platform::getStoragePath()
  */
 public function testGetLibraryPath()
 {
     $_control = Pii::getParam(LocalStorageTypes::LIBRARY_PATH);
     $this->assertEquals($_control, Platform::getLibraryPath());
 }