本文整理汇总了PHP中System\Classes\PluginManager::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginManager::instance方法的具体用法?PHP PluginManager::instance怎么用?PHP PluginManager::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System\Classes\PluginManager
的用法示例。
在下文中一共展示了PluginManager::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
public function boot()
{
Event::listen('backend.form.extendFields', function ($form) {
if ($form->model instanceof Backend\Models\BackendPreferences) {
$form->addFields(['focus_searchfield' => ['label' => 'indikator.backend::lang.settings.search_label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.search_comment'], 'sidebar_description' => ['label' => 'indikator.backend::lang.settings.sidebar_label', 'type' => 'switch', 'span' => 'right', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.sidebar_comment'], 'rounded_avatar' => ['label' => 'indikator.backend::lang.settings.avatar_label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.avatar_comment'], 'virtual_keyboard' => ['label' => 'indikator.backend::lang.settings.keyboard_label', 'type' => 'switch', 'span' => 'right', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.keyboard_comment'], 'media_menu' => ['label' => 'indikator.backend::lang.settings.media_label', 'type' => 'switch', 'span' => 'left', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.media_comment'], 'more_themes' => ['label' => 'indikator.backend::lang.settings.themes_label', 'type' => 'switch', 'span' => 'right', 'default' => 'false', 'comment' => 'indikator.backend::lang.settings.themes_comment']]);
}
});
BackendController::extend(function ($controller) {
if (BackendAuth::check()) {
$preferences = UserPreferences::forUser()->get('backend::backend.preferences');
if (isset($preferences['focus_searchfield']) && $preferences['focus_searchfield']) {
$controller->addJs('/plugins/indikator/backend/assets/js/setting-search.js');
}
if (isset($preferences['rounded_avatar']) && $preferences['rounded_avatar']) {
$controller->addCss('/plugins/indikator/backend/assets/css/rounded-avatar.css');
}
if (isset($preferences['virtual_keyboard']) && $preferences['virtual_keyboard']) {
$controller->addCss('/plugins/indikator/backend/assets/css/ml-keyboard.css');
$controller->addJs('/plugins/indikator/backend/assets/js/ml-keyboard.js');
}
if (isset($preferences['media_menu']) && $preferences['media_menu']) {
if (PluginManager::instance()->exists('RainLab.Pages')) {
$controller->addCss('/plugins/indikator/backend/assets/css/media-menu-pages.css');
} else {
$controller->addCss('/plugins/indikator/backend/assets/css/media-menu.css');
}
}
if (isset($preferences['more_themes']) && $preferences['more_themes']) {
$controller->addJs('/plugins/indikator/backend/assets/js/setting-theme.js');
}
}
});
BackendMenu::registerContextSidenavPartial('October.System', 'system', '~/plugins/indikator/backend/partials/_system_sidebar.htm');
}
示例2: register
/**
* Register our data source and renderer
*/
public function register()
{
/**
* Set up the data source for the feed
*/
$this->app->bind('KoderHut\\RssFeedster\\DataSource', function ($app) {
$config['page'] = Settings::get('post_page');
$config['comments_anchor'] = Settings::get('comments_anchor');
$config['controller'] = new Controller();
return new PostsSource($config);
});
/**
* Set up the adapter interface between the XML renderer and
* the blog posts data
*/
$this->app->bind(IAdapter::DI_NAMESPACE, function () {
return new BlogPostXmlAdapter();
});
/**
* Set up the feed renderer
*/
$this->app->bind('KoderHut\\RssFeedster\\Renderer', function ($app) {
$config = ['description' => Settings::get('feed_description'), 'title' => Settings::get('feed_title'), 'category' => Settings::get('feed_category'), 'copyright' => Settings::get('feed_copyright'), 'language' => Settings::get('feed_language'), 'link' => Url::action('KoderHut\\RssFeedster\\Controllers\\Rss@buildRssFeed')];
$pluginPath = PluginManager::instance()->getPluginPath(Plugin::KODERHUT_RSSFEEDSTER_NS);
$xmlTemplate = $pluginPath . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'feed-template.xml';
return new XmlRenderer($config, file_get_contents($xmlTemplate), $this->app->make(IAdapter::DI_NAMESPACE));
});
return;
}
示例3: fire
/**
* Execute the console command.
* @return void
*/
public function fire()
{
$pluginManager = PluginManager::instance();
$pluginName = $this->argument('name');
$pluginName = $pluginManager->normalizeIdentifier($pluginName);
if (!$pluginManager->hasPlugin($pluginName)) {
return $this->error(sprintf('Unable to find a registered plugin called "%s"', $pluginName));
}
if (!$this->confirmToProceed(sprintf('This will DELETE "%s" from the filesystem and database.', $pluginName))) {
return;
}
/*
* Rollback plugin
*/
$manager = UpdateManager::instance()->resetNotes();
$manager->rollbackPlugin($pluginName);
foreach ($manager->getNotes() as $note) {
$this->output->writeln($note);
}
/*
* Delete from file system
*/
if ($pluginPath = $pluginManager->getPluginPath($pluginName)) {
File::deleteDirectory($pluginPath);
$this->output->writeln(sprintf('<info>Deleted: %s</info>', $pluginName));
}
}
示例4: down
public function down()
{
if (PluginManager::instance()->hasPlugin('RainLab.Blog')) {
Schema::dropIfExists('bedard_blogtags_post_tag');
Schema::dropIfExists('bedard_blogtags_tags');
}
}
示例5: afterFetch
/**
* After the model is populated
*/
public function afterFetch()
{
/*
* Override the database columns with the plugin details
* found in the plugin registration file.
*/
$manager = PluginManager::instance();
$pluginObj = $manager->findByIdentifier($this->code);
if ($pluginObj) {
$pluginInfo = $pluginObj->pluginDetails();
foreach ($pluginInfo as $attribute => $info) {
$this->{$attribute} = Lang::get($info);
}
if ($this->is_disabled) {
$manager->disablePlugin($this->code, true);
} else {
$manager->enablePlugin($this->code, true);
}
$this->disabledBySystem = $pluginObj->disabled;
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
$this->disabledByConfig = in_array($this->code, $configDisabled);
}
} else {
$this->name = $this->code;
$this->description = Lang::get('system::lang.plugins.unknown_plugin');
$this->orphaned = true;
}
}
示例6: afterFetch
/**
* After the model is populated
*/
public function afterFetch()
{
/*
* Override the database columns with the plugin details
* found in the plugin registration file.
*/
$manager = PluginManager::instance();
$pluginObj = $manager->findByIdentifier($this->code);
if ($pluginObj) {
$pluginInfo = $pluginObj->pluginDetails();
foreach ($pluginInfo as $attribute => $info) {
$this->{$attribute} = $info;
}
if ($this->is_disabled) {
$manager->disablePlugin($this->code, true);
} else {
$manager->enablePlugin($this->code, true);
}
$this->disabledBySystem = $pluginObj->disabled;
$this->disabledByConfig = in_array($this->code, Config::get('cms.disablePlugins'));
} else {
$this->name = $this->code;
$this->description = 'Plugin has been removed from the file system.';
$this->orphaned = true;
}
}
示例7: boot
public function boot()
{
$this->manager = PluginManager::instance();
// Get paths we need
$theme = Theme::getActiveTheme();
$themePath = $theme->getPath();
$pluginPath = dirname(__FILE__);
$providerPath = $themePath . '/Plugin.php';
// Load your theme's Theme.php file as a service provider
if (File::exists($providerPath)) {
// Use reflection to find out info about Plugin.php
$info = new Classes\ClassInfo($providerPath);
if (ltrim($info->extends, '\\') == "NSRosenqvist\\ThemesPlus\\Classes\\ThemesPlusBase") {
// Activate the theme plugin
$plugin = $this->manager->loadPlugin($info->namespace, $themePath);
$identifier = $this->manager->getIdentifier($plugin);
$definitionsFile = $pluginPath . '/composer/definitions.php';
$this->manager->registerPlugin($plugin);
$this->manager->bootPlugin($plugin);
// See if we need to generate a new composer psr-4 definitions file
if (Settings::get('definitions_generated_for') != $identifier || !File::exists($definitionsFile)) {
File::put($definitionsFile, $this->makeDefinitionFile($info->namespace, $themePath));
Settings::set('definitions_generated_for', $identifier);
}
// Add theme to autoload through our definitions file
ComposerManager::instance()->autoload($pluginPath);
}
}
// dd(\Composer\Autoload\ClassLoader::findFile('MyCompany\\MyTheme\\Classes\\Radical'));
// dd(ComposerManager::instance());
}
示例8: loadActivities
/**
* Load the available activities that are defined by plugins
*/
protected function loadActivities()
{
/*
* Load module activities
*/
foreach ($this->callbacks as $callback) {
$callback($this);
}
/*
* Load plugin activities
*/
$pluginManager = PluginManager::instance();
$plugins = $pluginManager->getPlugins();
foreach ($plugins as $plugin) {
if (method_exists($plugin, 'registerFriendsActivities')) {
$activities = $plugin->registerFriendsActivities();
if (!is_array($activities)) {
continue;
}
foreach ($activities as $className => $code) {
$this->registerActivity($className, $code, $plugin);
}
}
}
}
示例9: down
public function down()
{
if (PluginManager::instance()->hasPlugin('RainLab.Blog')) {
Schema::table('rainlab_blog_posts', function ($table) {
$table->dropColumn('view');
});
}
}
示例10: register_flynsarmy_menu_item_types
public function register_flynsarmy_menu_item_types()
{
$types = ['Flynsarmy\\Menu\\MenuItemTypes\\Page' => ['label' => 'Page', 'alias' => 'page', 'description' => 'A link to a CMS Page'], 'Flynsarmy\\Menu\\MenuItemTypes\\Partial' => ['label' => 'Partial', 'alias' => 'partial', 'description' => 'Render a CMS Partial'], 'Flynsarmy\\Menu\\MenuItemTypes\\Link' => ['label' => 'Link', 'alias' => 'link', 'description' => 'A given URL']];
if (PluginManager::instance()->hasPlugin('RainLab.Blog')) {
$types['Flynsarmy\\Menu\\MenuItemTypes\\BlogPost'] = ['label' => 'Blog Post', 'alias' => 'blog_post', 'description' => 'A link to a Blog Post'];
$types['Flynsarmy\\Menu\\MenuItemTypes\\BlogCategory'] = ['label' => 'Blog Category', 'alias' => 'blog_category', 'description' => 'A link to a Blog Category'];
}
return $types;
}
示例11: user
/**
* Returns the logged in user, if available
*/
public function user()
{
if (!PluginManager::instance()->exists('RainLab.User')) {
return null;
}
if (!Auth::check()) {
return null;
}
return Auth::getUser();
}
示例12: createFromPluginCode
public static function createFromPluginCode($pluginCode)
{
$pluginCodeObj = new PluginCode($pluginCode);
$plugins = PluginManager::instance()->getPlugins();
foreach ($plugins as $code => $plugin) {
if ($code == $pluginCode) {
return new PluginVector($plugin, $pluginCodeObj);
}
}
return null;
}
示例13: getFeedLanguageOptions
/**
* Load and return the feed_language dropdown options
*
* @return array
*/
public function getFeedLanguageOptions()
{
$pluginPath = PluginManager::instance()->getPluginPath(Plugin::KODERHUT_RSSFEEDSTER_NS);
$path = $pluginPath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'language_codes.yaml';
if (!File::exists($path)) {
return [];
}
$languages = YamlParser::parseFile($path);
$languages = is_array($languages) ? array_flip($languages) : [];
return $languages;
}
示例14: getDropdownOptions
public function getDropdownOptions($fieldName = null, $keyValue = null)
{
$options = [];
$manager = PluginManager::instance();
if ($manager->exists('shahiemseymor.roles')) {
$permissions = \ShahiemSeymor\Roles\Models\UserPermission::get();
foreach ($permissions as $permission) {
$options[$permission->id] = $permission->name;
}
}
return $options;
}
示例15: getUserIdOptions
public function getUserIdOptions($keyValue = null)
{
$manager = PluginManager::instance();
if ($manager->exists('rainlab.user')) {
$Users = array();
foreach (UserModel::orderBy('surname')->orderBy('name')->get() as $user) {
$Users[$user->id] = $user->surname . ', ' . $user->name;
}
return $Users;
}
return [0 => 'Rainlab User Model Not Installed'];
}