Im trying to set up my yii2 site on a linux server, and i use my windows pc for development using wampp.
Ive set up RBAC AuthManagement to use DBManager, and everything works perfectly on my development site. However, when i try and install the site onto my Live server, i get a Yii2 NonInstantiableException Error, stating that "Class yii\rbac\DBManager does not exist" (Screenshot attached)
Yii2 Class Error
While looking through the stack trace, it highlights a line in my code where i have Yii checking a users roles to see if it can display a navigation item. Ive attached the code below to show the line highlighted:
use yii\helpers\Html;
$frontend_url = "frontend site";
//organisation navigation links
$orgNav[] = ['label' => "Organisation Details"];
$orgNav[] = ['label' => "All Organisation List",'visible'=>Yii::$app->user->can('owner')];
$orgNav[] = ['label' => "Organisation User Management",'visible'=>Yii::$app->user->can('superAdmin')];
$orgNav[] = ['label' => "Organisation Customer Management"];
if(Yii::$app->user->can('admin')){
$menuItems[] = ['label'=>'Organisation','items'=>$orgNav];
}
//Ticket Management Links
$ticketNav[] = ['label'=>'Open Tickets'];
$ticketNav[] = ['label'=>'Closed Tickets'];
$ticketNav[] = ['label'=>'My Tickets'];
$ticketNav[] = ['label'=>'All Tickets (For Org)','visible' => Yii::$app->user->can('admin')];
$ticketNav[] = ['label'=>'Open a new Support Ticket'];
$menuItems[] = ['label'=>'Tickets','items'=>$ticketNav];
//user navigation links
$userNav[] = ['label'=>'Profile', 'url'=>'/user/index'];
$userNav[] = ['label' => 'Account Settings'];
$userNav[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
];
$menuItems[] = ['label'=>'User','items'=>$userNav];
//admin links (for owner and superAdmins)
$adminNav[] = ['label' => 'Organisation Management','visible' => Yii::$app->user->can('owner')];
$adminNav[] = ['label' => 'User Management','visible' => Yii::$app->user->can('owner')];
$adminNav[] = ['label' => 'License Management','visible' => Yii::$app->user->can('owner')];
$adminNav[] = ['label' => 'Site Settings','visible' => Yii::$app->user->can('owner')];
$menuItems[] = ['label' => 'Admin','items'=>$adminNav,'visible'=>Yii::$app->user->can('owner')];
$menuItems[] = ['label' => '> Home', 'url' => ['/']];
$menuItems[] = ['label' => '> Visit Website', 'url' => $frontend_url];
The line that is being highlighted is
$orgNav[] = ['label' => "All Organisation List",'visible'=>Yii::$app->user->can('owner')];
Ive googled this error but get shown other classes which dont provide much information for me.
Could i get some insight on this please?
Do the fact you are using linux on production and windows for develpment your problem could be related to the different manage of case for filename between the tow OS
So be suere that your app/config/main.php 'component' section you have the correct entry for filename
this is a working sample for authManger configuration for the same env (linux --- window) as you can see the entry is DbManger and not DBManager ( the 'b' is lowercase)
'components' => [
......
'authManager' => [
'class' => 'yii\rbac\DbManager',
......
],
Related
I am developing a theme, and I want the Theme Options Page, to be available for Editor, and Administrator user roles.
The options page show up fine when the user is an administrator.
My reduxt configuration file:
...
$args = array(
'display_name' => esc_html__( 'Ρυθμίσεις Θέματος', TEXT_DOMAIN ),
'display_version' => '1.0.0',
'menu_title' => esc_html__( 'Ρυθμίσεις Θέματος', TEXT_DOMAIN ),
'customizer' => false,
'page_permissions' => 'delete_pages',
'dev_mode' => true
);
Redux::setArgs( $opt_name, $args );
$sections = array(
'basic',
);
Redux::setSection( $opt_name, array(
'title' => esc_html__( 'Βασικές Ρυθμίσεις', TEXT_DOMAIN ),
'id' => $sections[0],
'desc' => esc_html__( 'Social Media, Στοιχεία Επικοινωνίας', TEXT_DOMAIN ),
'icon' => 'el el-home',
'permissions' => 'delete_pages',
'fields' => array(
...
I've found it. Line 75 in redux-framework\redux-core\inc\classes\class-redux-page-render.php, sets the page_permissions argument.
Which of course accepts any valid Wordpress capability.
I'm using array data provider for grid view widget since the data source is an API response. It's working fine, but when I try to sort the 'Name' column, it's sorting incorrectly with the lowercase first letters. Please check the table grid screenshot. The API response which I'm receiving is correct with the current sorting.
1. Table Grid
2. Model
$provider = new ArrayDataProvider([
'allModels' => #$response->data,
'pagination' => false,
'sort' => [
'attributes' => ['id', 'name', 'shortDescription'],
],
]);
3. View
<?= GridView::widget([
' dataProvider' => $dataProvider,
'columns' => [
'id',
'name',
'shortDescription'
],
'options' => ['class' => 'content'],
'tableOptions' => ['class' => 'table table-striped table-hover'],
'summary' => Yii::t('app', 'Showing').' {begin}-{end} of '.$total.' '.Yii::t('app', 'items')
]);
?>
Please guide me to fix this. Thanks!
How to cache database translations on yii2
I tried the following but not worked
'i18n' => [
'class' => Zelenin\yii\modules\I18n\components\I18N::className(),
'languages' => ['en', 'ar', 'fr'],
'sourceMessageTable' => 'source_message',
'messageTable' => 'message',
'cache' => 'cache'
],
The problem is in Zelenin i18n module. If you look at Module.php file, you can see:
$this->translations['*'] = [
'class' => DbMessageSource::className(),
'sourceMessageTable' => $this->sourceMessageTable,
'messageTable' => $this->messageTable,
'on missingTranslation' => $this->missingTranslationHandler
];
in init() method. This Code set DbMessageSource options and there are no any options about caching. Module have no any caching options too.
If you change this code to:
$this->translations['*'] = [
'class' => DbMessageSource::className(),
'sourceMessageTable' => $this->sourceMessageTable,
'messageTable' => $this->messageTable,
'enableCaching' => true,
'cachingDuration' => 3600,
'on missingTranslation' => $this->missingTranslationHandler
];
Cache will work. Some SELECT messages will gone from debug list.
The Yii documentation for i18n db messages says that the property cache only has meaning when the property cacheDuration is not zero. I suggest you set this value, so;
'i18n' => [
'class' => Zelenin\yii\modules\I18n\components\I18N::className(),
'languages' => ['en', 'ar', 'fr'],
'sourceMessageTable' => 'source_message',
'messageTable' => 'message',
'cache' => 'cache',
'cacheDuration' => 3600
],
I'm trying to change my page title. To visit the page - click here.
This is written as a custom module within Drupal 7. The file is called wb_spc.module for this module code in JSFiddle, please click here.
I've tried changing lines 51 and 59 but this won't change the h1 page title?
Please see a code snippet below:
/**
* Implements hook_menu().
*/
function wb_spc_menu() {
$items = array();
// Admin configuration group.
$items['admin/config/wb_spc'] = array(
'title' => 'Workbooks Self-Assessment CRM ROI Calculator',
'description' => 'Administer WB CRM Requirements',
'access arguments' => array('administer wb crm requirements'),
);
// Admin configuration - Settings.
$items['admin/config/wb_spc/manage'] = array(
'title' => 'Workbooks Self-Assessment CRM ROI Calculator Settings',
'description' => 'Manage WB CRM Requirements settings and configurations.',
'access arguments' => array('administer wb spc requirements'),
'page callback' => 'drupal_get_form',
'page arguments' => array('wb_spc_admin_settings_form'),
);
$items[variable_get('wb_spc_path')] = array(
'title' => 'Workbooks Self-Assessment CRM ROI Calculator',
'page callback' => 'drupal_get_form',
'page arguments' => array('wb_spc_form'),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
$items['wb_spc/test'] = array(
'title' => 'TESTING - Workbooks Self-Assessment CRM ROI Calculator',
'page callback' => 'wb_spc_test',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
$items['wb_spc/results/%'] = array(
'title' => 'WB Show PDF',
'page callback' => 'wb_spc_show_pdf',
'page arguments' => array(2),
'access arguments' => array('access content'),
);
return $items;
}
In the page (the one you see as a user), add this:
drupal_set_title('Page title goes here');
Change the <h1>, i believe the page title will be changed also if you do. If you want page title to be other than <h1> use the method drupal_set_title('Page title goes here');
To change it from only a certain page use:
if($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] == 'www.yourdomain.com/rest/of/url'){
drupal_set_title('Page title goes here');
}
I am writing an application in Zend Framework 2 which is going to run from a few different subdomain, and I want to have a different module for each sub domain, to keep things tidy.
My problem is when I add more than 1 sub domain to the routing, it loses one of the sub domains.
eg: This setup works
testbed.localhost (module/Application)
a.testbed.localhost (module/A)
If I add an extra one it will the route all requests for a to the Application Index Controller
eg
testbed.localhost (module/Application), a.testbed.localhost (module/A), b.testbed.localhost (module/B)
This is the module.config.php for module/A
'router' => array(
'routes' => array(
'ads' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'a.testbed.localhost',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'__NAMESPACE__' => 'A\Controller',
'controller' => 'A\Controller\A',
'action' => 'index',
),
),
And this is the route in module.config.php in module/B
'router' => array(
'routes' => array(
'ads' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'b.testbed.localhost',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'__NAMESPACE__' => 'B\Controller',
'controller' => 'B\Controller\B',
'action' => 'index',
),
),
Now the namespaces are correct in both the module.config.php files, what I have noticed is the sub domain a.testbed.localhost will work if I remove the reference to it from config/application.config.php
<?php
return array(
'modules' => array(
'Application',
'A',
'B', <--- A doesn't work if B is here
),
And if I swap A & B around in the modules array above, then B will get forwarded to the Application Module and A will work. So it seems to have problems with more than 1 sub domain. Has anyone got any ideas / come across the same thing?
This happens because your route names are the same. I would try a-ads and b-ads for route names and that should resolve your situation.
In the end the configuration is getting merged together. So it's like an array, when the last array is merged it overwrites anything before it.