SonataUserBundle does not attempt to load any styles - php

I've configured SonataUserBundle together with SonataAdminBundle. I now have access to URLs like /login, /register, /profile. This is how the login page looks like. Other pages also do not have any styles loaded.
Does Sonata provide any default styles for these pages. I though that maybe I have a problem with dependency version. This is 'Sonata' fragment of my composer.json:
"sonata-project/admin-bundle": "~2.3",
"sonata-project/doctrine-orm-admin-bundle": "^2.3",
"sonata-project/easy-extends-bundle": "^2.1",
"sonata-project/user-bundle": "^2.2",
"knplabs/knp-menu": "~1.1",
"knplabs/knp-menu-bundle": "~1.1",
"sonata-project/core-bundle": "~2.3"
I've also installed the assets with php app/console assets:install web --symlink, cleared the cache with php app/console cache:clear.
When I inspect the 'Network' tab in the Chrome Dev tools, no asset files are ever attempted to be loaded.
I'd rather expect something like this.
What am I missing here?

You shall check first in your configuration with the reference one on the official documentation :
https://sonata-project.org/bundles/admin/master/doc/reference/configuration.html
for the 2.3 version, you should have :
assets:
stylesheets:
# Defaults:
- bundles/sonataadmin/vendor/bootstrap/dist/css/bootstrap.min.css
- bundles/sonataadmin/vendor/AdminLTE/css/font-awesome.min.css
- bundles/sonataadmin/vendor/AdminLTE/css/ionicons.min.css
- bundles/sonataadmin/vendor/AdminLTE/css/AdminLTE.css
- bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css
- bundles/sonataadmin/vendor/jqueryui/themes/base/jquery-ui.css
- bundles/sonataadmin/vendor/select2/select2.css
- bundles/sonataadmin/vendor/select2/select2-bootstrap.css
- bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css
- bundles/sonataadmin/css/styles.css
- bundles/sonataadmin/css/layout.css
javascripts:
# Defaults:
- bundles/sonataadmin/vendor/jquery/dist/jquery.min.js
- bundles/sonataadmin/vendor/jquery.scrollTo/jquery.scrollTo.min.js
- bundles/sonatacore/vendor/moment/min/moment.min.js
- bundles/sonataadmin/vendor/bootstrap/dist/js/bootstrap.min.js
- bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js
- bundles/sonataadmin/vendor/jqueryui/ui/minified/jquery-ui.min.js
- bundles/sonataadmin/vendor/jqueryui/ui/minified/i18n/jquery-ui-i18n.min.js
- bundles/sonataadmin/jquery/jquery.form.js
- bundles/sonataadmin/jquery/jquery.confirmExit.js
- bundles/sonataadmin/vendor/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js
- bundles/sonataadmin/vendor/select2/select2.min.js
- bundles/sonataadmin/App.js
- bundles/sonataadmin/Admin.js

Related

Behat change result status when add javascript annotation

I want to use behat to example test and I used Mink and Selenium to test javascript. I have a a element in html file and when I click on the link then JQuery add to DOM new element. I want to test this case.
composer.json
{
"require": {
"behat/behat": "^3.1",
"bossa/phpspec2-expect": "^1.0",
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink": "^1.7"
}
}
behat.yml
default:
extensions:
Behat\MinkExtension:
goutte: ~
browser_name: firefox
selenium2:
wd_host: http://0.0.0.1:4444/wd/hub
example.feature
Feature: example
Scenario: Test javascript for
Given I am on "http://www.example.com/"
When I follow "clickButton" #a has id clickButton
Then I should see "Works!"
Behat throw error in Then I should see "Works!" step and it is fine, because this element not exists on body.
But when add #javascript annotation
#javascript
Feature: example
Scenario: Test javascript for
Given I am on "http://www.example.com/"
When I follow "clickButton"
Then I should see "Works!"
Behat throw exception:
When I follow "clickButton" # FeatureContext::clickLink()
Link with id|title|alt|text "clickButton" not found. (Behat\Mink\Exception\ElementNotFoundException)
What's wrong? I have Selenium on server.

Could not load type "sonata_simple_formatter_type"

I'm using Symfony framework and SonataBundle to build the admin application.
When I'm trying to setup a field with type blob and using the "sonata_simple_formatter_type" of SonataFormatterBundle, i was got the error:
Could not load type "sonata_simple_formatter_type"
Here is my composer.json file:
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
//*...*/
"sonata-project/admin-bundle": "2.3.10",
"sonata-project/doctrine-orm-admin-bundle": "2.3.3",
"sonata-project/user-bundle": "2.2.4",
"sonata-project/formatter-bundle": "2.3.3",
I was prefer to this link to making the admin app: sonata formatter
To fix the error, you also need to configure SonataFormatterBundle: https://sonata-project.org/bundles/formatter/master/doc/reference/installation.html
For the SonataAdminBundle you also need to do some extra configuration: https://sonata-project.org/bundles/formatter/master/doc/reference/formatter_widget.html#sonata-admin-integration

How rename namespace Application in SonataUserBundle?

My composer file:
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "1.3.3",
"sonata-project/core-bundle": "2.3.*#dev",
"sonata-project/admin-bundle": "2.4.*#dev",
"sonata-project/doctrine-orm-admin-bundle" : "*",
"sonata-project/easy-extends-bundle": "2.1.*#dev",
"sonata-project/user-bundle": "~2.2",
"knplabs/knp-menu-bundle": "~1.1",
"hwi/oauth-bundle": "~0.4#dev",
"sonata-project/cache-bundle": "~2.2"
If I use "php app/console sonata:easy-extends:generate -d src/ SonataUserBundle" - command generate namespace "Application", all my Bundles in namespace "WPE"...
I want user bundle in my namespace.
User entity renamed to "WPE\UserBundle\Entity\User", login, admin all work, but
users list in sonata send error "Class Application\Sonata\UserBundle\Entity\User does not exist"
I find (Find in path... in IDE PhpStorm) "Application\Sonata\UserBundle" in cache files and sonata documentation.
How I can use my namespace "WPE"?
Rename Application\Sonata\UserBundle to your YourVendor\UserBundle\Entity\User.
Rename Application\Sonata\UserBundle... namespace to YourVendor\UserBundle\... in all files.
Remove new Application\Sonata\UserBundle\ApplicationSonataUserBundle() from Appkernel.php and add YourVendor\UserBundle() in AppKernel.php.
Change config:
sonata_user:
#security_acl: true # Uncomment for ACL support
manager_type: orm # can be orm or mongodb
class:
user: YourVendor\UserBundle\Entity\User
group: YourVendor\UserBundle\Entity\Group
fos_user:
db_driver: orm # can be orm or odm
firewall_name: main
user_class: YourVendor\UserBundle\Entity\User
#user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: YourVendor\UserBundle\Entity\Group
#group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager
service:
user_manager: sonata.user.orm.user_manager
If your are using orm mapping:
mappings:
YourVendorUserBundle: ~
#ApplicationSonataUserBundle: ~
A PRAGMATIC WAY TO SOLVE THIS ISSUE
The easiest way to solve this problem is to use global namespace inside your VB, the global namespace is the only namespace allowed Application\YourBundle\Entity.
So, inside your mapping definition or inside your VB code, you will use one final namespace: problem solved. How to achieve this:
Declare only SuperClass inside a VB, don’t use final entity,
Call your entity BaseXXXX and make it abstract, change the properties from private to protected,
The same goes for a repository,
Always use Application\YourBundle\Entity\XXXX inside your code.
Of course, you need to create for each VB bundle:
a valid structure inside the Application directory,
a valid entity mapping definition,
a model inside the entity folder.
The last part is quite inefficient without an efficient tool to generate for you this structure: EasyExtendsBundle to the rescue.
HOW TO MAKE YOUR BUNDLE EASY EXTENDABLE?
Mainly all you need is to follow instructions in previous paragraph:
Declare you entity/repository as described above,
Use your entity/repository as described above,
Before generation you also need “skeleton” file that will describe AB entity. Skeleton file can either xml or yml. For fully working example see SonataMediaBundle.
At last you can run:
php app/console sonata:easy-extends:generate YourVBBundleName
Note that the –dest option allows you to choose the target directory, such as src. Default destination is app/.
If you want to use :
php app/console sonata:easy-extends:generate YourVBBundleName
You can modify some SonataAdmin fiels , it's not the best way but that can help you to run at least the commande and generate your bundle:
1 - In Sonata\EasyExtendsBundle\Bundle\BundleMetadata (ligne 95) make change like this:
$this->extendedNamespace = sprintf('WPE\\%s\\%s', $this->vendor, $information[1]);
2 - In Sonata\EasyExtendsBundle\Command\GenerateCommand (ligne 67) :
'application_dir' => sprintf("%s/WPE", $dest)
3 - in Sonata\EasyExtendsBundle\Generator\BundleGenerator (ligne 70 ) :
$file = sprintf('%s/WPE%s.php', $bundleMetadata->getExtendedDirectory(), $bundleMetadata->getName());
4 - In sonata-project / Resources / skeleton / bundle / bundle.mustache :
class WPE{{ bundle }} extends Bundle
{
/.../
}
5 - In Sonata\UserBundle\DependencyInjection\SonataUserExtension (ligne 162/163):
$defaultConfig['class']['user'] = sprintf('WPE\\Sonata\\UserBundle\\%s\\User', $modelType);
$defaultConfig['class']['group'] = sprintf('WPE\\Sonata\\UserBundle\\%s\\Group', $modelType);
Then Run php app/console sonata:easy-extends:generate.
Other way you can copy the UserBundle under WPE and make your change :
In config.yml
Your name spaces
You entities
your service
and Your class admin

Weird issue, translations works if logged in, if not then didn't work in Symfony 2.5.6

I come here with this weird issue around Symfony2 translations since I don't know what else to do. As title says "translations works if a user is logged in, otherwise doesn't. Here is what I've done:
Set default locale and translator at config.yml:
framework:
translator: { fallback: "%locale%" }
default_locale: "%locale%"
Set locale value at parameters.yml
locale: es
Set language at base template:
<html lang="{{ app.request.locale }}">
Check locale after page loads in Twig template where issue is happening:
{{ app.request.locale }} // returns "es" it's right
Clear the cache several/many/manyyyyyyyyyyy times:
1st approach (didn't work):
php app/console cache:clear
php app/console cache:warmup
2nd approach (didn't work):
rm -rf /app/cache
3th approach (didn't work): cd to app/cache and select each file one by one (using mc from Linux) and remove all them including directories by pressing F8
Clear browser cache and test in Firefox/Chrome
I've checked the app/cache dir under translations directory and there is a file catalogue.es.php which contains all the translated strings so translation is working.
My translation are defined in a messages.es.yml file at AppBundle/Resources/translations and this is an example of the content:
registro:
natural:
panelTitulo: Datos del Usuario
columnas:
tipo_usuario: Tipo de Usuario
campos:
tipoTramite: Tipo de Trámite
Then in my view this is how I access those translations:
{{'registro.natural.panelTitulo'|trans}}
{{'registro.columnas.tipo_usuario'|trans}}
But this, when user is not logged in, does not work, but, if I logged in and try this translation instead:
{{'campos.tipoTramite'|trans}}
{{ 'registro.columnas.tipo_usuario'|trans }}
and both works (I'm using FOSUserBundle for User management but translations doesn't belongs to any domain, just in the directory I mention earlier) so I'm complete lost since I don't know what else to do. Can any give me some advice around this? Translation only work if user has logged in in a application? I'm doing something wrong? How is that possible?
Extra information
This is the relevant part of my composer.json file those are the bundles I'm using on my application right now, any one problematic?
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.5.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "3.0.*#dev",
"friendsofsymfony/user-bundle": "~2.0#dev",
"friendsofsymfony/jsrouting-bundle": "2.0.*#dev",
"friendsofsymfony/rest-bundle": "1.5.*#dev",
"jms/serializer-bundle": "0.13.*#dev",
"jms/di-extra-bundle": "1.4.*#dev",
"jms/security-extra-bundle": "dev-master",
"knplabs/knp-paginator-bundle": "2.4.*#dev",
"knplabs/knp-menu": "2.0.*#dev",
"knplabs/knp-menu-bundle": "2.0.*#dev",
"stof/doctrine-extensions-bundle": "1.2.*#dev",
"misd/phone-number-bundle": "~1.0",
"raulfraile/ladybug-bundle": "~1.0",
"h4cc/alice-fixtures-bundle": "dev-master",
"oneup/uploader-bundle": "dev-master",
"willdurand/js-translation-bundle": "2.1.*#dev",
"vich/uploader-bundle": "1.0.*#dev"
}
messages is a fairly common keyword for a translation domain and I suspect that conflicting bundles are overriding your translation file in certain scenarios. To fix this:
Rename your messages.es.yml file to AppBundle.es.yml
Use this format {{ 'registro.natural.panelTitulo'|trans({}, 'AppBundle') }} for all usage of your bundle translations, especially when working with Twig files outside of AppBundle
Clear your caches

What does the Value in PHP Composer's key/value Pair Represent?

In a PHP composer.json file, the require field contains a number of key/value pairs.
"require": {
"php": ">=5.3.3",
"symfony/console": "~2.3#dev",
"symfony/finder": "2.2.1",
"symfony/yaml": "2.2.1",
"symfony/process": "2.2.1",
"symfony/validator": "2.2.1",
"n98/junit-xml": "dev-master",
"fzaninotto/faker": "1.1.0",
"composer/composer": "dev-master"
},
What, exactly, is the value of each key/value pair used for?
I get that conceptually these are just version numbers. For example, the following
"symfony/finder": "2.2.1"
tells composer that version 2.2.1 of the symfony/finder package is required.
What I'm unclear on is
The syntax allowed for versioning (i.e. what does ~2.3#dev mean)
Why some versions are just text (dev-master)
My assumption is these somehow related to branches or tags in a version control system, or maybe the explicit version defined in a package's composer.json file, but I haven't been able to glean how, exactly, this works.
If anyone knows, or can point me to the right section of the manual where this is explained, I'd appreciate it.
The ~2.3#dev means: "using ~ specifies a minimum version, but allows the last digit specified to go up." and dev means its a dev version, "Available options (in order of stability) are dev, alpha, beta, RC, and stable."
it means its a master branch
All of this i found it here:
http://getcomposer.org/doc/01-basic-usage.md#package-versions
http://getcomposer.org/doc/04-schema.md#minimum-stability
http://getcomposer.org/doc/articles/aliases.md
http://getcomposer.org/doc/04-schema.md#require-dev

Categories