本文整理汇总了PHP中Wire::setFuel方法的典型用法代码示例。如果您正苦于以下问题:PHP Wire::setFuel方法的具体用法?PHP Wire::setFuel怎么用?PHP Wire::setFuel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wire
的用法示例。
在下文中一共展示了Wire::setFuel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCurrentUser
public function setCurrentUser(User $user)
{
if (!$user->roles->has("id=" . $this->fuel('config')->guestUserRolePageID)) {
$guestRole = $this->fuel('roles')->getGuestRole();
$user->roles->add($guestRole);
}
$this->currentUser = $user;
Wire::setFuel('user', $user);
}
示例2: setCurrentUser
/**
* Set the current system user (the $user API variable)
*
* @param User $user
*
*/
public function setCurrentUser(User $user)
{
$hasGuest = false;
$guestRoleID = $this->wire('config')->guestUserRolePageID;
if ($user->roles) {
foreach ($user->roles as $role) {
if ($role->id == $guestRoleID) {
$hasGuest = true;
break;
}
}
}
if (!$hasGuest && $user->roles) {
$guestRole = $this->wire('roles')->getGuestRole();
$user->roles->add($guestRole);
}
$this->currentUser = $user;
Wire::setFuel('user', $user);
}
示例3: Breadcrumbs
$event->arguments(0, $url);
}
}
// ensure core jQuery modules are loaded before others
$modules->get("JqueryCore");
$modules->get("JqueryUI");
// tell ProcessWire that any pages loaded from this point forward should have their outputFormatting turned off
$pages->setOutputFormatting(false);
// setup breadcrumbs to current page, and the Process may modify, add to or replace them as needed
$breadcrumbs = new Breadcrumbs();
foreach ($page->parents() as $p) {
if ($p->id > 1) {
$breadcrumbs->add(new Breadcrumb($p->url, $p->get("title|name")));
}
}
Wire::setFuel('breadcrumbs', $breadcrumbs);
$controller = null;
$content = '';
// enable modules to output their own ajax responses if they choose to
if ($config->ajax) {
ob_start();
}
if ($page->process && $page->process != 'ProcessPageView') {
try {
if ($config->demo && !in_array($page->process, array('ProcessLogin'))) {
if (count($_POST)) {
$this->error("Saving is disabled in this demo");
}
foreach ($_POST as $k => $v) {
unset($_POST[$k]);
}
示例4: setCurrentUser
/**
* Sets the current users
*
* @param User $user
* @return this
*
*/
public function setCurrentUser(User $user)
{
$this->currentUser = $user;
Wire::setFuel('user', $user);
return $this;
}
示例5: ___uninstall
/**
* Uninstall the module and related modules
*
*/
public function ___uninstall()
{
$language = wire('user')->language;
if ($language && $language->id && !$language->isDefault) {
throw new WireException("Please switch your language back to the default language before uninstalling");
}
// uninstall the components 1 by 1
$configData = wire('modules')->getModuleConfigData('LanguageSupport');
$field = $this->fields->get(LanguageSupport::languageFieldName);
if ($field) {
$field->flags = Field::flagSystemOverride;
$field->flags = 0;
$userFieldgroup = $this->templates->get('user')->fieldgroup;
if ($userFieldgroup) {
$userFieldgroup->remove($field);
$userFieldgroup->save();
$this->message("Removed language field from user profiles");
}
$this->fields->delete($field);
$this->message("Removing field: {$field}");
}
$deletePageIDs = array($configData['defaultLanguagePageID'], $configData['languageTranslatorPageID'], $configData['languagesPageID']);
// remove any language pages that are in the trash
$trashLanguages = wire('pages')->get(wire('config')->trashPageID)->find("include=all, template=" . LanguageSupport::languageTemplateName);
foreach ($trashLanguages as $p) {
$deletePageIDs[] = $p->id;
}
foreach ($deletePageIDs as $id) {
$page = $this->pages->get($id);
if (!$page->id) {
continue;
}
$page->status = Page::statusSystemOverride;
$page->status = 0;
$this->message("Removing page: {$page->path}");
$this->pages->delete($page, true);
}
$template = $this->templates->get(LanguageSupport::languageTemplateName);
if ($template) {
$template->flags = Template::flagSystemOverride;
$template->flags = 0;
$this->message("Removing template: {$template->name}");
$this->templates->delete($template);
}
$fieldgroup = $this->fieldgroups->get(LanguageSupport::languageTemplateName);
if ($fieldgroup) {
$this->message("Removing fieldgroup: {$fieldgroup}");
$this->fieldgroups->delete($fieldgroup);
}
$field = $this->fields->get("language_files");
if ($field) {
$field->flags = Field::flagSystemOverride;
$field->flags = 0;
$this->message("Removing field: {$field->name}");
$this->fields->delete($field);
}
Wire::setFuel('languages', null);
$uninstallModules = array('ProcessLanguage', 'ProcessLanguageTranslator');
foreach ($uninstallModules as $name) {
$this->modules->uninstall($name);
$this->message("Uninstalled Module: {$name}");
}
}
示例6: load
/**
* Load's ProcessWire using the supplied Config and populates all API fuel
*
* $param Config $config
*
*/
public function load(Config $config)
{
Wire::setFuel('notices', new Notices());
Wire::setFuel('sanitizer', new Sanitizer());
if ($config->dbSocket) {
$db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort, $config->dbSocket);
} else {
$db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort);
}
Wire::setFuel('db', $db);
if ($config->dbCharset) {
$db->set_charset($config->dbCharset);
} else {
if ($config->dbSetNamesUTF8) {
$db->query("SET NAMES 'utf8'");
}
}
$modules = new Modules($config->paths->modules, $config->paths->siteModules);
$fieldtypes = new Fieldtypes();
$fields = new Fields();
$fieldgroups = new Fieldgroups();
$templates = new Templates($fieldgroups, $config->paths->templates);
Wire::setFuel('modules', $modules);
Wire::setFuel('fieldtypes', $fieldtypes);
Wire::setFuel('fields', $fields);
Wire::setFuel('fieldgroups', $fieldgroups);
Wire::setFuel('templates', $templates);
Wire::setFuel('permissions', new Permissions());
Wire::setFuel('roles', new Roles());
Wire::setFuel('pages', new Pages(), true);
Wire::setFuel('pagesRoles', new PagesRoles());
Wire::setFuel('users', new Users());
Wire::setFuel('user', Wire::getFuel('users')->getCurrentUser());
Wire::setFuel('session', new Session());
Wire::setFuel('input', new WireInput());
$fieldtypes->init();
$fields->init();
$fieldgroups->init();
$templates->init();
$modules->init();
}
示例7: load
/**
* Load's ProcessWire using the supplied Config and populates all API fuel
*
* $param Config $config
*
*/
public function load(Config $config)
{
Wire::setFuel('wire', $this);
Wire::setFuel('notices', new Notices());
Wire::setFuel('sanitizer', new Sanitizer());
try {
Wire::setFuel('db', new Database($config));
} catch (WireDatabaseException $e) {
// catch and re-throw to prevent DB connect info from ever appearing in debug backtrace
throw new WireDatabaseException($e->getMessage());
}
$modules = new Modules($config->paths->modules, $config->paths->siteModules);
Wire::setFuel('modules', $modules);
if (!($updater = $modules->get('SystemUpdater'))) {
$modules->resetCache();
$modules->get('SystemUpdater');
}
$fieldtypes = new Fieldtypes();
$fields = new Fields();
$fieldgroups = new Fieldgroups();
$templates = new Templates($fieldgroups, $config->paths->templates);
Wire::setFuel('fieldtypes', $fieldtypes);
Wire::setFuel('fields', $fields);
Wire::setFuel('fieldgroups', $fieldgroups);
Wire::setFuel('templates', $templates);
Wire::setFuel('pages', new Pages(), true);
$fieldtypes->init();
$fields->init();
$fieldgroups->init();
$templates->init();
if (!($t = $templates->get('permission'))) {
throw new WireException("Missing system template: 'permission'");
}
$permissions = new Permissions($t, $config->permissionsPageID);
Wire::setFuel('permissions', $permissions);
if (!($t = $templates->get('role'))) {
throw new WireException("Missing system template: 'role'");
}
$roles = new Roles($t, $config->rolesPageID);
Wire::setFuel('roles', $roles);
if (!($t = $templates->get('user'))) {
throw new WireException("Missing system template: 'user'");
}
$users = new Users($t, $config->usersPageID);
Wire::setFuel('users', $users);
// the current user can only be determined after the session has been initiated
$session = new Session();
Wire::setFuel('session', $session);
Wire::setFuel('user', $users->getCurrentUser());
Wire::setFuel('input', new WireInput());
$modules->triggerInit();
}
示例8: load
/**
* Load's ProcessWire using the supplied Config and populates all API fuel
*
* $param Config $config
*
*/
public function load(Config $config)
{
$this->wire('wire', $this, true);
$this->wire('log', new WireLog(), true);
$this->wire('notices', new Notices(), true);
$this->wire('sanitizer', new Sanitizer());
try {
$database = WireDatabasePDO::getInstance($config);
$this->wire('database', $database);
$db = new DatabaseMysqli($config);
$this->wire('db', $db);
} catch (Exception $e) {
// catch and re-throw to prevent DB connect info from ever appearing in debug backtrace
throw new WireDatabaseException($e->getMessage());
}
$modules = new Modules($config->paths->modules, $config->paths->siteModules);
Wire::setFuel('modules', $modules, true);
$updater = $modules->get('SystemUpdater');
if (!$updater) {
$modules->resetCache();
$modules->get('SystemUpdater');
}
$fieldtypes = new Fieldtypes();
$fields = new Fields();
$fieldgroups = new Fieldgroups();
$templates = new Templates($fieldgroups, $config->paths->templates);
$this->wire('fieldtypes', $fieldtypes, true);
$this->wire('fields', $fields, true);
$this->wire('fieldgroups', $fieldgroups, true);
$this->wire('templates', $templates, true);
$pages = new Pages();
$this->wire('pages', $pages, true);
$fieldtypes->init();
$fields->init();
$fieldgroups->init();
$templates->init();
if (!($t = $templates->get('permission'))) {
throw new WireException("Missing system template: 'permission'");
}
$permissions = new Permissions($t, $config->permissionsPageID);
$this->wire('permissions', $permissions, true);
if (!($t = $templates->get('role'))) {
throw new WireException("Missing system template: 'role'");
}
$roles = new Roles($t, $config->rolesPageID);
$this->wire('roles', $roles, true);
if (!($t = $templates->get('user'))) {
throw new WireException("Missing system template: 'user'");
}
$users = new Users($t, $config->usersPageID);
$this->wire('users', $users, true);
// the current user can only be determined after the session has been initiated
$session = new Session();
$this->wire('session', $session, true);
$this->wire('user', $users->getCurrentUser());
$this->wire('input', new WireInput(), true);
// populate admin URL before modules init()
$config->urls->admin = $config->urls->root . ltrim($pages->_path($config->adminRootPageID), '/');
$this->setStatus(self::statusInit);
}
示例9: load
/**
* Load's ProcessWire using the supplied Config and populates all API fuel
*
* $param Config $config
*
*/
public function load(Config $config)
{
Wire::setFuel('wire', $this);
Wire::setFuel('notices', new Notices());
Wire::setFuel('sanitizer', new Sanitizer());
if ($config->dbSocket) {
$db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort, $config->dbSocket);
} else {
$db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort);
}
Wire::setFuel('db', $db);
if ($config->dbCharset) {
$db->set_charset($config->dbCharset);
} else {
if ($config->dbSetNamesUTF8) {
$db->query("SET NAMES 'utf8'");
}
}
$modules = new Modules($config->paths->modules, $config->paths->siteModules);
$fieldtypes = new Fieldtypes();
$fields = new Fields();
$fieldgroups = new Fieldgroups();
$templates = new Templates($fieldgroups, $config->paths->templates);
Wire::setFuel('modules', $modules);
Wire::setFuel('fieldtypes', $fieldtypes);
Wire::setFuel('fields', $fields);
Wire::setFuel('fieldgroups', $fieldgroups);
Wire::setFuel('templates', $templates);
Wire::setFuel('pages', new Pages(), true);
$fieldtypes->init();
$fields->init();
$fieldgroups->init();
$templates->init();
if (!($t = $templates->get('permission'))) {
throw new WireException("Missing system template: 'permission'");
}
$permissions = new Permissions($t, $config->permissionsPageID);
Wire::setFuel('permissions', $permissions);
if (!($t = $templates->get('role'))) {
throw new WireException("Missing system template: 'role'");
}
$roles = new Roles($t, $config->rolesPageID);
Wire::setFuel('roles', $roles);
if (!($t = $templates->get('user'))) {
throw new WireException("Missing system template: 'user'");
}
$users = new Users($t, $config->usersPageID);
Wire::setFuel('users', $users);
// the current user can only be determined after the session has been initiated
$session = new Session();
Wire::setFuel('session', $session);
Wire::setFuel('user', $users->getCurrentUser());
Wire::setFuel('input', new WireInput());
$modules->triggerInit();
}