I have some component I want to make it separate currently my components looks like
-protected/components
-GeneralFunction.php
-CustomFunction.php
and my config I have called:
'components' => array(
'general' => array('class' => 'GeneralFunction'),
'custom' => array('class' => 'CustomFunction'),
),
Above code is working fine But I want to separate frontend and backend of my components like:
-protected/components
-frontend
-GeneralFunction.php
-CustomFunction.php
-backend
-GeneralFunction.php
-CustomFunction.php
and my config I am calling:
'components' => array(
'general2' => array('class' => 'frontend.GeneralFunction'),
),
TestController.php
function actionTestComponent(){
echo Yii::app()->general2->test(); exit;
}
I am getting this error message:
2017/12/19 11:17:54 [error] [exception.CException] CException: Alias "frontend.GeneralFunction" is invalid. Make sure it points to an existing directory or file. in C:\xampp\htdocs\yii\framework\YiiBase.php:348
Please help me..
After lots of research I found this:
'general2' => array('class' => 'application.components.frontend.GeneralFunction'),
Related
I am trying to install ScnSocialAuth_ZendSessionManager into my zend 2 application.
i am getting the following error message when i try to go to the login or registration page:
An alias "ScnSocialAuth_ZendSessionManager" was requested but no service could be found.
i have followed the instructions here:
and uploaded it.
i then install
./vendor/socalnick/scn-social-auth/config/scn-social-auth.global.php.dist
/vendor/socalnick/scn-social-auth/config/scn-social-auth.local.php.dist
to my config.
Then within the scn-social-auth.global.php i did the following:
$settings = array(
'zend_db_adapter' => 'Zend\Db\Adapter\Adapter',
'zend_session_manager' => 'Zend\Session\SessionManager'
}
);
return array(
'scn-social-auth' => $settings,
'service_manager' => array(
'aliases' => array(
'ScnSocialAuth_ZendDbAdapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'Zend\Db\Adapter\Adapter',
'ScnSocialAuth_ZendSessionManager' => (isset($settings['zend_session_manager'])) ? $settings['zend_session_manager']: 'Zend\Session\SessionManager',
),
),
);
i also created a ./config/autoload/session.local.php:
<?php
return array(
'service_manager' => array(
'invokables' => array(
'Zend\Session\SessionManager' => 'Zend\Session\SessionManager',
),
),
);
so, i am unclear why i am still getting the error message;
would really appriciate any advise on this.
UPDATE
i also added the module to composer:
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*",
"socalnick/scn-social-auth": "1.*"
}
UPATE
Wilt has asked what values are returned when i var_dump the config values.
the returned values are:
array (size=3)
'ScnSocialAuth_ZendDbAdapter' => string 'Zend\Db\Adapter\Adapter' (length=23)
'ScnSocialAuth_ZendSessionManager' => string 'Zend\Session\SessionManager' (length=27)
'zfcuser_zend_db_adapter' => string 'Zend\Db\Adapter\Adapter' (length=23)
you will observe that the ScnSocialAuth_ZendSessionManager is aliasing the zend sesssion manager.
so, i am unclear why it say that the service cannot be found.
would really appriciate some advice on this.
You need the scn-social-auth.global.php and the scn-social-auth.local.php to you application config folder and set all the config parameters that are required.
In this file you find the key 'ScnSocialAuth_ZendSessionManager'. Your issue is probably related to some configuration problem related to these config files.
Since you said you loaded them I would says something is wrong with your autoload setup.
Does your ZF2 application have the proper system configuration:
'module_listener_options' => array(
'module_paths' => array(
'./module',
'./vendor',
),
'config_glob_paths' => array(
'config/autoload/{{,*.}global,{,*.}local}.php',
)
)
Check once if your merged $config array contains all your keys?
$config = $serviceManager->get('Config');
Working in Yii, i get the error of
SystemManagementController and its behaviors do not have a method or
closure named "createReturnableUrl"
I can not find anything to solve it. it happened right after I added this:
array(
'class' => 'CButtonColumn',
//'viewButtonUrl' => '$this->grid->controller->createReturnableUrl("view",array("id"=>$data->id))',
'updateButtonUrl' => '$this->grid->controller->createReturnableUrl("update",array("id"=>$data->id))',
'deleteButtonUrl' => '$this->grid->controller->createReturnableUrl("delete",array("id"=>$data->id))',
//'deleteConfirmation' => Yii::t('app', 'Are you sure to delete this item?'),
),
to :
<?php
//The following lines needs to be moved to the controller to sepparate the view from the controllers.
$model = new CActiveDataProvider('User');
//The following line should be set by the controller. Containing the names of the colums in a chosen language.
/**/
$colums = array(
'login',
'name_first',
'name_last',
//'password',
'email',
'is_active',
//'sortorder',
array(
'class' => 'CButtonColumn',
//'viewButtonUrl' => '$this->grid->controller->createReturnableUrl("view",array("id"=>$data->id))',
'updateButtonUrl' => '$this->grid->controller->createReturnableUrl("update",array("id"=>$data->id))',
'deleteButtonUrl' => '$this->grid->controller->createReturnableUrl("delete",array("id"=>$data->id))',
//'deleteConfirmation' => Yii::t('app', 'Are you sure to delete this item?'),
),
);
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model,
'columns' => $colums,
'filter' => $model->model)
);
?>
when I remove that piece of code, there is not problem, everything works, but when I add that line it gives me the error.
I use that line in a different class as well and there I dont get the problem, how can I get rid of this?
It looks like the controller does not know about createReturnableUrl. From what I googled that is a behavior of yii that you can attach, are you sure you attached the behavior properly for the SystemManagementController? See if all the other controller that work with the same code have that behavior attached, maybe this one does not.
I am converting a ZF2 "filename.phtml" view to a "filename.twig" view. I am needing help knowing how to pass a variable to a partial. The nature of the partial provides a variety of "social network" share type buttons. What I am giving the partial is the URL of the web page being accessed to "share".
The code I am trying to convert:
echo $this->partial('partial/socialnetworkshare', array('web_page' => $this->url('main-prayersfortoday', array('prayer_reference' => $this->prayer_reference ))));
I haven't correctly figured out how to pass the value of "$this->prayer_reference". This is what I have tried:
{{ partial('partial/socialnetworkshare', {'web_page' : url('main-prayersfortoday') , 'prayer_reference' : prayer_reference }) }}
prayer_ministry is to match this route:
'main-prayersfortoday' => array(
'type' => 'segment',
'options' => array(
'route' => '/prayers-for-today[/:prayer_reference]',
'constraints' => array(
'prayer_reference' => '[0-9]*'
),
'defaults' => array(
'controller' => 'Main\Controller\Main',
'action' => 'prayersfortoday'
)
)
),
The value of "prayer_ministry" is passing through this controller:
$viewModel
->setTemplate('main/main/prayersfortodaydocument')
->setVariable('prayer_reference', $this->params()->fromRoute('prayer_reference'))
->setVariable('document', $document);
I very much appreciate your help. Thank you.
I think what you're after is something like this, using the include tag:
{% include 'partial/socialnetworkshare' with {
'web_page': path('main-prayersfortoday'),
'prayer_reference': prayer_reference
} %}
In Symfony, we have Twig extensions which provide the Twig path() function similar to $this->url() in Zend. You may need to register you own Twig extension to provide this in Zend.
I have a table product_media and cake is not inflecting media to medium.
I have added the following to app/Config/bootstrap.php:
Inflector::rules('singular', array('irregular' => array('media' => 'medium')));
This works fine for a table named media but does not work for my table named product_media.
Anyone know why?
It probably matches the whole word only if no specific rules are given. Try this:
Inflector::rules(
'singular',
array(
'rules' => array(
'/(.*)media$/i' => '\1medium'
)
)
);
Inflector::rules('uninflected', array('media', 'medium'));
or
Inflector::rules('uninflected' => array('singulars'),
'irregular' => array('media' => 'medium')
I'm trying to internationalize all the pages on my CakePHP site with the following format:
/en/about
/zh/about (for Chinese version)
etc.
I already have all the routes defined at router.php, eg.
Router::connect('/about/*', array('controller' => 'pages', 'action' => 'about'));
Router::connect('/login/*', array('controller' => 'users', 'action' => 'login'));
// etc...
How do I make it so that /language/ prefix is automatically applied to all the Router::connect()s?
At CakePHP library's router.php, there is an example for the similar routing and is given as such:
Router::connect('/:lang/:controller/:action/:id',
array(), array('id' => '[0-9]+', 'lang' => '[a-z]{2}'));
This however, only works for the default routing type (eg. /pages/about/) and not a specially defined one like /about for my example.
In other words, it would work when user visits /zh/pages/about but not when user visits /zh/about
Any suggestions or do I have to manually rewrite all my Router::connect()s to include lang?
Try this:
Router::connect('/:lang/:controller', array(), array('lang' => '[a-z]{2}'));
Router::connect('/:lang/:controller/:action', array(), array('lang' => '[a-z]{2}'));
Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{2}'));