本文整理汇总了PHP中KService::set方法的典型用法代码示例。如果您正苦于以下问题:PHP KService::set方法的具体用法?PHP KService::set怎么用?PHP KService::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KService
的用法示例。
在下文中一共展示了KService::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Return the singleton instnace of PlgContentfilterChain. This method also imports all the
* content filter plugins.
*
* @return PlgContentfilterChain
*/
public static function getInstance()
{
static $_instance;
if (!$_instance) {
$_instance = new self(new KConfig(array('service_container' => KService::getInstance())));
KService::set('plg:contentfilter.chain', $_instance);
JPluginHelper::importPlugin('contentfilter');
}
return $_instance;
}
示例2: __construct
/**
* Constructor.
*
* @param mixed $dispatcher A dispatcher
* @param array $config An optional KConfig object with configuration options.
*
* @return void
*/
public function __construct($dispatcher = null, $config = array())
{
if (isset($config['params'])) {
$config = (array) JRegistryFormat::getInstance('ini')->stringToObject($config['params']);
}
$config = new KConfig($config);
parent::__construct($config);
$this->_params = $config;
KService::set('plg:storage.default', $this);
}
示例3: __construct
public function __construct($subject, $config = array())
{
//Intercept the events for profiling
if (KDEBUG) {
//Create the event profiler
$profiler = KService::get('com://admin/debug.profiler.events');
//Replace the event dispatcher
KService::set('koowa:event.dispatcher', $profiler);
}
parent::__construct($subject, $config);
}
示例4: getAPI
/**
* Get a service api
*
* @param string $service The service name.
*
* @return ComConnectOauthApiAbstract
*/
public static function getAPI($service)
{
$service = strtolower($service);
$identifier = 'com://site/connect.oauth.service.' . $service;
if (!KService::has($identifier)) {
$config = array();
$config['consumer'] = self::getConsumer($service);
$config['enabled'] = self::enabled($service);
KService::set($identifier, KService::get($identifier, $config));
}
return KService::get($identifier);
}
示例5: __construct
/**
* Constructor.
*
* @param KConfig $config An optional KConfig object with configuration options.
*/
public function __construct(KConfig $config)
{
KService::set($config->service_identifier, $this);
parent::__construct($config);
$this->_entityset = $config->entityset;
$this->_prototype = $config->prototype;
$this->_store = $config->store;
$this->_space = $config->space;
$this->_resources = $config->resources;
$this->_description = new AnDomainDescriptionDefault($config);
//$this->_description = $this->getService($config->description, KConfig::unbox($config));
//now set the attributes and relationships
$this->_description->setAttribute(KConfig::unbox($config->attributes));
$this->_description->setRelationship(KConfig::unbox($config->relationships));
$this->_query = $this->getService($config->query, $config->toArray());
// Mixin the behavior interface
$config->mixer = $this;
$this->mixin(new KMixinCommand($config));
$this->mixin(new KMixinBehavior($config));
//insert the reposiry with highest priority
$this->getCommandChain()->enqueue($this, -PHP_INT_MAX);
}
示例6: __construct
/**
* Constructor.
*
* Prevent creating instances of this class by making the contructor private
*
* @param array An optional array with configuration options.
*/
private final function __construct($config = array())
{
//store the path
$this->_path = dirname(__FILE__);
//instantiate koowa
Koowa::getInstance(array('cache_prefix' => $config['cache_prefix'], 'cache_enabled' => $config['cache_enabled']));
//if caching is not enabled then reset the apc cache to
//to prevent corrupt identifier
if (!$config['cache_enabled']) {
clean_apc_with_prefix($config['cache_prefix']);
}
require_once dirname(__FILE__) . '/loader/adapter/anahita.php';
KLoader::addAdapter(new AnLoaderAdapterAnahita(array('basepath' => dirname(__FILE__))));
KLoader::addAdapter(new AnLoaderAdapterDefault(array('basepath' => JPATH_LIBRARIES . '/default')));
AnServiceClass::getInstance();
KServiceIdentifier::addLocator(new AnServiceLocatorAnahita());
KServiceIdentifier::addLocator(new AnServiceLocatorRepository());
//register an empty path for the application
//a workaround to remove the applicaiton path from an identifier
KServiceIdentifier::setApplication('', '');
//create a central event dispatcher
KService::set('anahita:event.dispatcher', KService::get('koowa:event.dispatcher'));
}
示例7: onBeforeControllerGet
/**
* Push the toolbar into the view
* .
*
* @param KEvent A event object
*/
public function onBeforeControllerGet(KEvent $event)
{
KService::set('com:controller.toolbar', $this);
$event->getPublisher()->getView()->toolbar = $this;
}
示例8: _renderMails
/**
* Renders emails for a list of people
*
* @param array $config Config parameter
*
* @return array
*/
protected function _renderMails($config)
{
$mails = array();
$config = new KConfig($config);
$settings = $config->settings;
$people = $config->people;
$notification = $config->notification;
foreach ($people as $person) {
$setting = $settings->{$person->id};
if (!($ret = $notification->shouldNotify($person, $setting))) {
$notification->removeSubscribers($person);
continue;
}
$person->addNotification($notification);
if ($ret !== ComNotificationsDomainDelegateSettingInterface::NOTIFY_WITH_EMAIL) {
continue;
}
//since each owner revieces the mail, they are in fact the viewer
//so we need to set the as viewer while processing the notification
KService::set('com:people.viewer', $person);
$notification->owner = $person;
$data = new KConfig($this->_parser->parse($notification));
$data->append(array('email_subject' => $data->title, 'email_title' => pick($data->email_subject, $data->title), 'email_body' => $data->body, 'notification' => $notification));
if ($notification->target && !$notification->target->eql($person)) {
$data->commands->insert('notification_setting', array('actor' => $notification->target));
}
$body = $this->renderMail(array('layout' => false, 'template' => 'notification', 'data' => array('person' => $person, 'commands' => $data->commands, 'subject' => $notification->subject, 'title' => $data->email_title, 'body' => $data->email_body)));
$mails[] = array('subject' => $data->email_subject, 'body' => $body, 'to' => $person->email);
}
return $mails;
}
示例9: renderComponent
static function renderComponent($name, $params = array())
{
global $mainframe, $option;
// Define component path
define('JPATH_COMPONENT', JPATH_BASE . DS . 'components' . DS . $name);
define('JPATH_COMPONENT_SITE', JPATH_SITE . DS . 'components' . DS . $name);
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . DS . 'components' . DS . $name);
if (!file_exists(JPATH_COMPONENT)) {
JError::raiseError(404, JText::_('Component Not Found'));
}
$file = substr($name, 4);
// get component path
if ($mainframe->isAdmin() && file_exists(JPATH_COMPONENT . DS . 'admin.' . $file . '.php')) {
$path = JPATH_COMPONENT . DS . 'admin.' . $file . '.php';
} else {
$path = JPATH_COMPONENT . DS . $file . '.php';
}
$identifier = KService::getIdentifier("com:{$file}.aliases");
$identifier->application = $mainframe->isAdmin() ? 'admin' : 'site';
$lang =& JFactory::getLanguage();
$lang->load($name);
KLoader::getInstance()->loadIdentifier($identifier);
//new way of doing it
if (!file_exists($path)) {
$identifier->name = 'dispatcher';
register_default(array('identifier' => $identifier, 'default' => 'ComBaseDispatcherDefault'));
$dispatcher = ComBaseDispatcher::getInstance();
KService::setAlias('component.dispatcher', $dispatcher->getIdentifier());
KService::set('component.dispatcher', $dispatcher);
return $dispatcher->dispatch();
} else {
$contents = self::_renderComponent($path);
// Build the component toolbar
jimport('joomla.application.helper');
if (($path = JApplicationHelper::getPath('toolbar')) && $mainframe->isAdmin()) {
// Get the task again, in case it has changed
$task = JRequest::getString('task');
// Make the toolbar
include_once $path;
}
return $contents;
}
}
示例10: getRepository
/**
* Helper mehtod to return a repository for an entity.
*
* @param string $identifier Entity Identifier
* @param array $config Configuration
*
* @return AnDomainRepositoryAbstract
*/
public static function getRepository($identifier, $config = array())
{
if (strpos($identifier, 'repos:') === 0) {
$repository = KService::get($identifier);
} else {
$strIdentifier = (string) $identifier;
if (!KService::has($identifier)) {
$identifier = self::getEntityIdentifier($identifier);
}
if (!KService::has($identifier)) {
KService::set($strIdentifier, KService::get($identifier, $config));
}
$repository = KService::get($identifier)->getRepository();
}
return $repository;
}
示例11: createAdminUser
/**
* Creates the admin user
*/
public static function createAdminUser(&$vars)
{
$DBtype = JArrayHelper::getValue($vars, 'DBtype', 'mysqli');
$DBhostname = JArrayHelper::getValue($vars, 'DBhostname', '');
$DBuserName = JArrayHelper::getValue($vars, 'DBuserName', '');
$DBpassword = JArrayHelper::getValue($vars, 'DBpassword', '');
$DBname = JArrayHelper::getValue($vars, 'DBname', '');
$DBPrefix = JArrayHelper::getValue($vars, 'DBPrefix', '');
$adminPassword = JArrayHelper::getValue($vars, 'adminPassword', '');
$adminEmail = JArrayHelper::getValue($vars, 'adminEmail', '');
jimport('joomla.user.helper');
// Create random salt/password for the admin user
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($adminPassword, $salt);
$cryptpass = $crypt . ':' . $salt;
$db =& JInstallationHelper::getDBO($DBtype, $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix);
$vars = array_merge(array('adminLogin' => 'admin', 'adminName' => 'Administrator'), $vars);
$adminLogin = $vars['adminLogin'];
$adminName = $vars['adminName'];
// create the admin user
$installdate = date('Y-m-d H:i:s');
$nullDate = $db->getNullDate();
$query = "INSERT INTO #__users VALUES (62, '{$adminName}', '{$adminLogin}', " . $db->Quote($adminEmail) . ", " . $db->Quote($cryptpass) . ", 'Super Administrator', 0, 1, 25, '{$installdate}', '{$nullDate}', '', '')";
$db->setQuery($query);
if (!$db->query()) {
// is there already and existing admin in migrated data
if ($db->getErrorNum() == 1062) {
$vars['adminLogin'] = JText::_('Admin login in migrated content was kept');
$vars['adminPassword'] = JText::_('Admin password in migrated content was kept');
return;
} else {
echo $db->getErrorMsg();
return;
}
}
// add the ARO (Access Request Object)
$query = "INSERT INTO #__core_acl_aro VALUES (10,'users','62',0,'Administrator',0)";
$db->setQuery($query);
if (!$db->query()) {
echo $db->getErrorMsg();
return;
}
// add the map between the ARO and the Group
$query = "INSERT INTO #__core_acl_groups_aro_map VALUES (25,'',10)";
$db->setQuery($query);
if (!$db->query()) {
echo $db->getErrorMsg();
return;
}
//Anahita Installation
require_once JPATH_LIBRARIES . '/anahita/anahita.php';
//instantiate anahita and nooku
Anahita::getInstance(array('cache_prefix' => uniqid(), 'cache_enabled' => false));
KServiceIdentifier::setApplication('site', JPATH_SITE);
KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
KLoader::addAdapter(new AnLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
KServiceIdentifier::addLocator(KService::get('anahita:service.locator.component'));
KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
KService::setAlias('anahita:domain.space', 'com:base.domain.space');
KService::set('koowa:database.adapter.mysqli', KService::get('koowa:database.adapter.mysqli', array('connection' => $db->_resource, 'table_prefix' => $DBPrefix)));
KService::set('anahita:domain.store.database', KService::get('anahita:domain.store.database', array('adapter' => KService::get('koowa:database.adapter.mysqli'))));
KService::set('plg:storage.default', new KObject());
$person = KService::get('repos://site/people')->getEntity()->setData(array('name' => $adminName, 'userId' => 62, 'username' => $adminLogin, 'userType' => 'Super Administrator', 'email' => $adminEmail));
$note = KService::get('repos://site/notes')->getEntity()->setData(array('author' => $person, 'owner' => $person, 'body' => 'Welcome to Anahita!'));
$comment = $note->addComment(array('author' => $person, 'body' => 'The best Social Platform there is', 'component' => 'com_notes'));
$story = KService::get('repos://site/stories')->getEntity()->setData(array('component' => 'com_notes', 'name' => 'note_comment', 'object' => $note, 'comment' => $comment, 'target' => $person, 'owner' => $person, 'subject' => $person));
$entities = array();
$comment->save($entities);
return true;
}