本文整理汇总了PHP中App::get方法的典型用法代码示例。如果您正苦于以下问题:PHP App::get方法的具体用法?PHP App::get怎么用?PHP App::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEnable
public function testEnable()
{
$this->assertFalse($this->app->get('en'));
$this->assertFalse($this->app->enabled('en'));
$this->app->enable('en');
$this->assertTrue($this->app->enabled('en'));
$this->app->disable('en');
$this->assertFalse($this->app->enabled('en'));
}
示例2: createApplication
/**
* @param string $config
*
* @return \Songbird\App
*/
public static function createApplication($config = '')
{
$app = new App(require __DIR__ . '/../config/di.php');
$app->add('Config', new Config($config));
$app->add('Symfony\\Component\\HttpFoundation\\Response', new Response());
$app->add('Symfony\\Component\\HttpFoundation\\Request', Request::createFromGlobals());
$app->add('Filesystem', 'League\\Flysystem\\Filesystem')->withArgument(new CachedAdapter(new Adapter($app->config('app.paths.resources')), new CacheStore()));
$app->get('Logger')->pushHandler(new StreamHandler(vsprintf('%s/songbird-%s.log', [$app->config('app.paths.log'), date('Y-d-m')]), Logger::INFO));
$app->inflector('League\\Container\\ContainerAwareInterface')->invokeMethod('setContainer', [$app]);
$app->inflector('League\\Event\\EmitterAwareInterface')->invokeMethod('setEmitter', [$app->get('Emitter')]);
$app->inflector('Psr\\Log\\LoggerAwareInterface')->invokeMethod('setLogger', [$app->get('Logger')]);
$app->inflector('Songbird\\FilesystemAwareInterface')->invokeMethod('setFilesystem', ['Filesystem']);
$app->add('Repository', $app->get('RepositoryFactory')->createContentRepository());
return $app;
}
示例3: display
/**
* Display module
*
* @return void
*/
public function display()
{
// Instantiate database object
$this->database = \App::get('db');
// Get mailing list details that we are wanting users to sign up for
$sql = "SELECT * FROM `#__newsletter_mailinglists` WHERE deleted=0 AND private=0 AND id=" . $this->database->quote($this->params->get('mailinglist', 0));
$this->database->setQuery($sql);
$this->mailinglist = $this->database->loadObject();
// Get mailing list subscription if not guest
$this->subscription = null;
$this->subscriptionId = null;
if (!User::isGuest()) {
$sql = "SELECT * FROM `#__newsletter_mailinglist_emails` WHERE mid=" . $this->database->quote($this->params->get('mailinglist', 0)) . " AND email=" . $this->database->quote(User::get('email'));
$this->database->setQuery($sql);
$this->subscription = $this->database->loadObject();
}
// If we are unsubscribed...
if (is_object($this->subscription) && $this->subscription->status == 'unsubscribed') {
$this->subscriptionId = $this->subscription->id;
$this->subscription = null;
}
// Add stylesheets and scripts
$this->css()->js();
// Display module
require $this->getLayoutPath();
}
示例4: onSystemOverview
/**
* Return information about this hub
*
* @return array
*/
public function onSystemOverview($values = 'all')
{
if ($values != 'all') {
return;
}
$response = new stdClass();
$response->name = 'tickets';
$response->label = 'Support Tickets';
$response->data = array();
$database = App::get('db');
$database->setQuery("SELECT COUNT(*) FROM `#__support_tickets` AS f WHERE f.`type` = '0'");
$response->data['total'] = $this->_obj('Total', intval($database->loadResult()));
$database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0'");
$response->data['open'] = $this->_obj('Open', intval($database->loadResult()));
$database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' AND f.`status` = '0'");
$response->data['open_new'] = $this->_obj('(open) New', intval($database->loadResult()));
$database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' AND (f.`owner` = '' OR f.`owner` IS NULL)");
$response->data['open_unassigned'] = $this->_obj('(open) Unassigned', intval($database->loadResult()));
$database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' AND f.`status` = '1'");
$response->data['open_waiting'] = $this->_obj('(open) Waiting', intval($database->loadResult()));
$database->setQuery("SELECT f.`created` FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' ORDER BY f.`created` ASC LIMIT 1");
$response->data['open_oldest'] = $this->_obj('(open) Oldest', $database->loadResult());
$database->setQuery("SELECT f.`created` FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' ORDER BY f.`created` DESC LIMIT 1");
$response->data['open_newest'] = $this->_obj('(open) Newest', $database->loadResult());
$database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '0' AND f.`type` = '0'");
$response->data['closed'] = $this->_obj('Closed', intval($database->loadResult()));
return $response;
}
示例5: __construct
/**
* Constructor
*
* @param object $db
* @return void
*/
public function __construct($db = null)
{
if (!$db) {
$db = \App::get('db');
}
$this->_db = $db;
}
示例6: __construct
/**
* Constructor
*
* @param mixed $oid Integer (ID), string (alias), object or array
* @return void
*/
public function __construct($oid = null, $wish = null)
{
$this->_db = \App::get('db');
if ($this->_tbl_name) {
$cls = $this->_tbl_name;
$this->_tbl = new $cls($this->_db);
if (!$this->_tbl instanceof \JTable) {
$this->_logError(__CLASS__ . '::' . __FUNCTION__ . '(); ' . Lang::txt('Table class must be an instance of JTable.'));
throw new \LogicException(Lang::txt('Table class must be an instance of JTable.'));
}
if ($oid) {
if (is_numeric($oid) || is_string($oid)) {
// Make sure $oid isn't empty
// This saves a database call
$this->_tbl->load($oid);
} else {
if (is_object($oid) || is_array($oid)) {
$this->bind($oid);
}
}
} else {
if ($wish) {
if ($plans = $this->_tbl->getPlan($wish)) {
$this->bind($plans[0]);
}
}
}
}
}
示例7: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 1.6
*/
protected function populateState($ordering = 'ordering', $direction = 'ASC')
{
$app = JFactory::getApplication();
// List state information
$value = Request::getUInt('limit', Config::get('list_limit', 0));
$this->setState('list.limit', $value);
$value = Request::getUInt('limitstart', 0);
$this->setState('list.start', $value);
$orderCol = Request::getCmd('filter_order', 'a.ordering');
if (!in_array($orderCol, $this->filter_fields)) {
$orderCol = 'a.ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = Request::getCmd('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$params = $app->getParams();
$this->setState('params', $params);
if (!User::authorise('core.edit.state', 'com_content') && !User::authorise('core.edit', 'com_content')) {
// filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.published', 1);
}
$this->setState('filter.language', App::get('language.filter'));
// process show_noauth parameter
if (!$params->get('show_noauth')) {
$this->setState('filter.access', true);
} else {
$this->setState('filter.access', false);
}
$this->setState('layout', Request::getCmd('layout'));
}
示例8: render
/**
* Generate macro output
*
* @return string
*/
public function render()
{
//get the args passed in
$args = explode(',', $this->args);
// get feed url
$url = $this->_getFeedUrl($args);
// get feed details
$limit = $this->_getFeedLimit($args, 5);
$class = $this->_getFeedClass($args);
// get feed
$feed = \App::get('feed.parser');
$feed->set_feed_url($url);
$feed->init();
//var to hold html
$html = '<div class="feed ' . $class . '">';
// display title
$title = $feed->get_title();
$link = $feed->get_permalink();
if ($title) {
$html .= '<h3><a rel="external" href="' . $link . '">' . $title . '</a></h3>';
}
// display description
$desc = $feed->get_description();
if ($desc) {
$html .= '<p>' . $desc . '</p>';
}
// add each item
foreach ($feed->get_items(0, $limit) as $item) {
$html .= $this->_renderItem($item);
}
// close feed
$html .= '</div>';
return $html;
}
示例9: displayTask
/**
* Display the update dashboard
*
* @return void
*/
public function displayTask()
{
// Set any errors
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
$source = Component::params('com_update')->get('git_repository_source', null);
$this->view->repositoryVersion = json_decode(Cli::version());
$this->view->repositoryVersion = $this->view->repositoryVersion[0];
$this->view->repositoryMechanism = json_decode(Cli::mechanism());
$this->view->repositoryMechanism = $this->view->repositoryMechanism[0];
$this->view->databaseMechanism = Config::get('dbtype');
$this->view->databaseVersion = \App::get('db')->getVersion();
$this->view->status = json_decode(Cli::status());
$this->view->upcoming = json_decode(Cli::update(true, false, $source));
$this->view->migration = json_decode(Cli::migration());
if (!isset($this->view->repositoryMechanism)) {
$this->view->message = 'Please ensure that the component is properly configured';
$this->view->setLayout('error');
} elseif ($this->view->repositoryMechanism != 'GIT') {
$this->view->message = 'The CMS update component currently only supports repositories managed via GIT';
$this->view->setLayout('error');
}
// Output the HTML
$this->view->display();
}
示例10: onUserLoginFailure
public function onUserLoginFailure($response)
{
$errorlog = array();
switch ($response['status']) {
case \Hubzero\Auth\Status::SUCCESS:
$errorlog['status'] = $response['type'] . " CANCELED: ";
$errorlog['comment'] = $response['error_message'];
App::get('log')->logger('auth')->info(implode('', $errorlog));
break;
case \Hubzero\Auth\Status::FAILURE:
$errorlog['status'] = $response['type'] . " FAILURE: ";
if ($this->params->get('log_username', 0)) {
$errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")';
} else {
$errorlog['comment'] = $response['error_message'];
}
App::get('log')->logger('auth')->info(implode('', $errorlog));
break;
default:
$errorlog['status'] = $response['type'] . " UNKNOWN ERROR: ";
$errorlog['comment'] = $response['error_message'];
App::get('log')->logger('auth')->info(implode('', $errorlog));
break;
}
}
示例11: association
/**
* @param int $itemid The menu item id
*/
static function association($itemid)
{
// Get the associations
$associations = MenusHelper::getAssociations($itemid);
// Get the associated menu items
$db = App::get('db');
$query = $db->getQuery(true);
$query->select('m.*');
$query->select('mt.title as menu_title');
$query->from('#__menu as m');
$query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype');
$query->where('m.id IN (' . implode(',', array_values($associations)) . ')');
$query->leftJoin('#__languages as l ON m.language=l.lang_code');
$query->select('l.image');
$query->select('l.title as language_title');
$db->setQuery($query);
$items = $db->loadObjectList('id');
// Check for a database error.
if ($error = $db->getErrorMsg()) {
throw new Exception($error, 500);
return false;
}
// Construct html
$text = array();
foreach ($associations as $tag => $associated) {
if ($associated != $itemid) {
$text[] = Lang::txt('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', Html::asset('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title);
}
}
return JHtml::_('tooltip', implode('<br />', $text), Lang::txt('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png');
}
示例12: _getPybeService
/**
* @return \App_Rest_Service
*/
protected function _getPybeService()
{
if (!isset($this->_pybeService)) {
$this->_pybeService = \App::get(self::PYBE_SERVICE_NAME);
}
return $this->_pybeService;
}
示例13: getOptions
/**
* Method to get the list of siblings in a menu.
* The method requires that parent be set.
*
* @return array The field option objects or false if the parent field has not been set
* @since 1.7
*/
protected function getOptions()
{
// Initialize variables.
$options = array();
// Get the parent
$parent_id = $this->form->getValue('parent_id', 0);
if (empty($parent_id)) {
return false;
}
$db = App::get('db');
$query = $db->getQuery(true);
$query->select('a.id AS value, a.title AS text');
$query->from('#__menu AS a');
$query->where('a.published >= 0');
$query->where('a.parent_id =' . (int) $parent_id);
if ($menuType = $this->form->getValue('menutype')) {
$query->where('a.menutype = ' . $db->quote($menuType));
} else {
$query->where('a.menutype != ' . $db->quote(''));
}
$query->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
throw new Exception($db->getErrorMsg(), 500);
}
$options = array_merge(array(array('value' => '-1', 'text' => Lang::txt('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))), $options, array(array('value' => '-2', 'text' => Lang::txt('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST'))));
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例14: _prepareDocument
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = \App::get('menu');
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu) {
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
} else {
$this->params->def('page_heading', Lang::txt('COM_CONTENT_FORM_EDIT_ARTICLE'));
}
$title = $this->params->def('page_title', Lang::txt('COM_CONTENT_FORM_EDIT_ARTICLE'));
if (Config::get('sitename_pagetitles', 0) == 1) {
$title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title);
} elseif (Config::get('sitename_pagetitles', 0) == 2) {
$title = Lang::txt('JPAGETITLE', $title, Config::get('sitename'));
}
$this->document->setTitle($title);
Pathway::append($title, '');
if ($this->params->get('menu-meta_description')) {
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords')) {
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots')) {
$this->document->setMetadata('robots', $this->params->get('robots'));
}
}
示例15: onWhatsnew
/**
* Pull a list of records that were created within the time frame ($period)
*
* @param object $period Time period to pull results for
* @param mixed $limit Number of records to pull
* @param integer $limitstart Start of records to pull
* @param array $areas Active area(s)
* @param array $tagids Array of tag IDs
* @return array
*/
public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array())
{
if (is_array($areas) && $limit) {
if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) {
return array();
}
}
// Do we have a search term?
if (!is_object($period)) {
return array();
}
$database = App::get('db');
// Build the query
$f_count = "SELECT COUNT(*)";
$f_fields = "SELECT" . " f.id, " . " f.title, " . " 'kb' AS section, NULL AS subsection, " . " f.fulltxt AS text," . " CONCAT('index.php?option=com_kb&task=article&id=', f.id) AS href";
$f_from = " FROM #__kb_articles AS f";
$f_where = "f.state=1 AND f.created > '{$period->cStartDate}' AND f.created < '{$period->cEndDate}' AND f.access IN (" . implode(',', User::getAuthorisedViewLevels()) . ")";
$order_by = " ORDER BY created DESC, title";
$order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : "";
if (!$limit) {
// Get a count
$database->setQuery($f_count . $f_from . " WHERE " . $f_where);
return $database->loadResult();
} else {
// Get results
$database->setQuery($f_fields . $f_from . " WHERE " . $f_where . $order_by);
$rows = $database->loadObjectList();
foreach ($rows as $key => $row) {
$rows[$key]->href = Route::url($row->href);
}
return $rows;
}
}