本文整理汇总了PHP中Cake\Core\Configure::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::read方法的具体用法?PHP Configure::read怎么用?PHP Configure::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Core\Configure
的用法示例。
在下文中一共展示了Configure::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: captureMessage
/**
* Capture a message via sentry
*
* @param string $message The message (primary description) for the event.
* @param array $params params to use when formatting the message.
* @param array $data Additional attributes to pass with this event (see Sentry docs).
* @param bool $stack Print stack trace
* @param null $vars Variables
* @return bool
*/
public function captureMessage($message, $params = [], $data = [], $stack = false, $vars = null)
{
if (!Configure::read('CakeMonitor.Sentry.enabled') || error_reporting() === 0) {
return false;
}
return $this->_ravenClient->captureMessage($message, $params, $data, $stack, $vars);
}
示例2: initialize
/**
* Initialization hook method.
*
* For e.g. use this method to load a helper for all views:
* `$this->loadHelper('Html');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
if (Configure::read('Facebook.app_id')) {
$this->loadHelper('JorgeFacebook.Facebook');
}
}
示例3: view
public function view($reportId)
{
if (!$reportId) {
throw new NotFoundException(__('Invalid Report'));
}
$report = $this->Reports->findById($reportId)->toArray();
if (!$report) {
throw new NotFoundException(__('Invalid Report'));
}
$this->set('report', $report);
$this->set('project_name', Configure::read('GithubRepoPath'));
$this->Reports->id = $reportId;
$this->set('incidents', $this->Reports->getIncidents()->toArray());
$this->set('incidents_with_description', $this->Reports->getIncidentsWithDescription());
$this->set('incidents_with_stacktrace', $this->Reports->getIncidentsWithDifferentStacktrace());
$this->set('related_reports', $this->Reports->getRelatedReports());
$this->set('status', $this->Reports->status);
$this->_setSimilarFields($reportId);
// if there is an unread notification for this report, then mark it as read
$current_developer = TableRegistry::get('Developers')->findById($this->request->session()->read('Developer.id'))->all()->first();
//$current_developer = Sanitize::clean($current_developer);
if ($current_developer) {
TableRegistry::get('Notifications')->deleteAll(array('developer_id' => $current_developer['Developer']['id'], 'report_id' => $reportId), false);
}
}
示例4: testRequestAction
/**
* testRequestAction method
*
* @return void
*/
public function testRequestAction()
{
$this->assertNull(Router::getRequest(), 'request stack should be empty.');
$result = $this->object->requestAction('');
$this->assertFalse($result);
$result = $this->object->requestAction('/request_action/test_request_action');
$expected = 'This is a test';
$this->assertEquals($expected, $result);
$result = $this->object->requestAction(Configure::read('App.fullBaseUrl') . '/request_action/test_request_action');
$expected = 'This is a test';
$this->assertEquals($expected, $result);
$result = $this->object->requestAction('/request_action/another_ra_test/2/5');
$expected = 7;
$this->assertEquals($expected, $result);
$result = $this->object->requestAction('/tests_apps/index', ['return']);
$expected = 'This is the TestsAppsController index view ';
$this->assertEquals($expected, $result);
$result = $this->object->requestAction('/tests_apps/some_method');
$expected = 5;
$this->assertEquals($expected, $result);
$result = $this->object->requestAction('/request_action/paginate_request_action');
$this->assertNull($result);
$result = $this->object->requestAction('/request_action/normal_request_action');
$expected = 'Hello World';
$this->assertEquals($expected, $result);
$this->assertNull(Router::getRequest(), 'requests were not popped off the stack, this will break url generation');
}
示例5: activeTheme
/**
* Get active theme name.
*
* @param bool $isSite
* @return mixed
*/
function activeTheme($isSite = true)
{
if ($isSite) {
return Configure::read('Theme.' . Theme::CLIENT_FRONT_END);
}
return Configure::read('Theme.' . Theme::CLIENT_BACK_END);
}
示例6: display
/**
* Displays a view
*
* @param mixed What page to display
* @return void
* @throws Cake\Error\NotFoundException When the view file could not be found
* or Cake\View\Error\MissingViewException in debug mode.
*/
public function display()
{
$path = func_get_args();
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $titleForLayout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$titleForLayout = Inflector::humanize($path[$count - 1]);
}
$this->set(array('page' => $page, 'subpage' => $subpage, 'title_for_layout' => $titleForLayout));
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new Error\NotFoundException();
}
}
示例7: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->View = new View();
$this->_appNamespace = Configure::read('App.namespace');
Configure::write('App.namespace', 'TestApp');
}
示例8: getModelClass
public function getModelClass()
{
$parts = explode('\\', get_class($this));
$factory = array_pop($parts);
$entity = preg_replace('/Factory$/', '', $factory);
return Configure::read('App.namespace') . '\\Model\\Entity\\' . $entity;
}
示例9:
function __construct()
{
Configure::load('amazon', 'default');
$this->awsAccessKey = Configure::read('AwsAccessKey');
$this->awsSecretKey = Configure::read('AwsSecretKey');
$this->associateTag = Configure::read('AssociateTag');
}
示例10: beforeDelete
public function beforeDelete(Event $event, Entity $entity)
{
$upload_root_offset = Configure::read('UPLOAD_ROOT_OFFSET');
$upload_root = Configure::read('UPLOAD_ROOT');
$id = $entity->id;
$job_id = $entity->job_id;
// delete creative folder and all its contents
AppController::delete_folder($upload_root_offset . DS . $upload_root . DS . $job_id . DS . $id);
/*
$Files = TableRegistry::get('Files');
$files = $Files->find('all',['conditions'=>['creative_id'=>$id]])->toArray();
if( !empty($files) ) {
foreach($files as $row){
$file_path = $upload_root_offset . $row['file'];
if( file_exists($file_path) ) {
if ( is_dir($file_path) ){
if( AppController::delete_folder($file_path) ) {
}
} else if( unlink($file_path) ) {
}
}
}
}
*/
}
示例11: _thumbnailsHtml
/**
* Method that generates and returns thumbnails html markup.
*
* @param ResultSet $entities File Entities
* @param FileUploadsUtils $fileUploadsUtils fileUploadsUtils class object
* @param array $options for default thumbs versions and other setttings
*
* @return string
*/
protected function _thumbnailsHtml($entities, FileUploadsUtils $fileUploadsUtils, $options = [])
{
$result = null;
$colWidth = static::GRID_COUNT / static::THUMBNAIL_LIMIT;
$thumbnailUrl = 'CsvMigrations.thumbnails/' . static::NO_THUMBNAIL_FILE;
$hashes = Configure::read('FileStorage.imageHashes.file_storage');
$extensions = $fileUploadsUtils->getImgExtensions();
foreach ($entities as $k => $entity) {
if ($k >= static::THUMBNAIL_LIMIT) {
break;
}
if (in_array($entity->extension, $extensions)) {
$thumbnailUrl = $entity->path;
if (isset($hashes[$options['imageSize']])) {
$version = $hashes[$options['imageSize']];
$exists = $this->_checkThumbnail($entity, $version, $fileUploadsUtils);
if ($exists) {
$path = dirname($entity->path) . '/' . basename($entity->path, $entity->extension);
$path .= $version . '.' . $entity->extension;
$thumbnailUrl = $path;
}
}
}
$thumbnail = sprintf(static::THUMBNAIL_HTML, $this->cakeView->Html->image($thumbnailUrl, ['title' => $entity->filename]));
$thumbnail = $this->cakeView->Html->link($thumbnail, $entity->path, ['escape' => false, 'target' => '_blank']);
$result .= sprintf(static::GRID_COL_HTML, $colWidth, $colWidth, $colWidth, $colWidth, $thumbnail);
}
$result = sprintf(static::GRID_ROW_HTML, $result);
return $result;
}
示例12: _getContentEmpty
/**
* Get the comment content purified with HTMLPurifier.
*
* @return string
*/
protected function _getContentEmpty()
{
$config = HTMLPurifier_Config::createDefault();
$config->loadArray(Configure::read('HtmlPurifier.Blog.comment_empty'));
$HTMLPurifier = new HTMLPurifier($config);
return $HTMLPurifier->purify($this->content);
}
示例13: _getAssetFile
/**
* Builds asset file path based on the provided $url.
*
* @param string $url Asset URL
* @return string|void Absolute path for asset file
*/
protected function _getAssetFile($url)
{
$parts = explode('/', $url);
$pluginPart = [];
$plugin = false;
for ($i = 0; $i < 2; $i++) {
if (!isset($parts[$i])) {
break;
}
$pluginPart[] = Inflector::camelize($parts[$i]);
$possiblePlugin = implode('/', $pluginPart);
if ($possiblePlugin && Plugin::loaded($possiblePlugin)) {
$plugin = $possiblePlugin;
$parts = array_slice($parts, $i + 1);
break;
}
}
$isAssetRequest = isset($parts[0]) && $parts[0] === 'ASSETS';
if ($isAssetRequest && Configure::read('debug')) {
$parts = array_slice($parts, 1);
} else {
$isAssetRequest = false;
}
if ($plugin && Plugin::loaded($plugin)) {
return $this->_getPluginAsset($plugin, $parts, $isAssetRequest);
} else {
return $this->_getAppAsset($parts, $isAssetRequest);
}
}
示例14: search
/**
* Search the elastic search index.
*
* @return void
*/
public function search()
{
$domains = Configure::read('AccessControlAllowOrigin');
$this->response->cors($this->request)->allowOrigin($domains)->allowMethods(['GET'])->allowHeaders(['X-CSRF-Token'])->maxAge(300)->build();
$version = '2-2';
if (!empty($this->request->query['version'])) {
$version = $this->request->query['version'];
}
if (empty($this->request->query['lang'])) {
throw new BadRequestException();
}
$lang = $this->request->query['lang'];
$page = 1;
if (!empty($this->request->query['page'])) {
$page = $this->request->query['page'];
}
$page = max($page, 1);
if (count(array_filter(explode(' ', $this->request->query['q']))) === 1) {
$this->request->query['q'] .= '~';
}
$options = ['query' => $this->request->query('q'), 'page' => $page];
$this->loadModel('Search', 'Elastic');
$results = $this->Search->search($lang, $version, $options);
$this->viewBuilder()->className('Json');
$this->set('results', $results);
$this->set('_serialize', 'results');
}
示例15: register
/**
* Register method
*
* @return void (Redirection)
*/
public function register()
{
$user = $this->Users->newEntity();
if ($this->request->is('post')) {
//Adding defaults
$this->request->data['see_nsfw'] = Configure::read('cms.defaultSeeNSFW');
$this->request->data['role'] = Configure::read('cms.defaultRole');
$this->request->data['status'] = Configure::read('cms.defaultUserStatus');
$this->request->data['locked'] = Configure::read('cms.defaultLockedUser');
$this->request->data['file_count'] = 0;
$this->request->data['note_count'] = 0;
$this->request->data['post_count'] = 0;
$this->request->data['project_count'] = 0;
$this->request->data['preferences'] = json_encode(Configure::read('cms.defaultPreferences'));
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
$this->Flash->success(__d('elabs', 'Your account has been created. An email will be sent to you when active'));
$this->redirect(['action' => 'index']);
} else {
$errors = $user->errors();
$errorMessages = [];
array_walk_recursive($errors, function ($a) use(&$errorMessages) {
$errorMessages[] = $a;
});
$this->Flash->error(__d('elabs', 'Some errors occured. Please, try again.'), ['params' => ['errors' => $errorMessages]]);
}
}
$this->set(compact('user'));
$this->set('_serialize', ['user']);
}