w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » SYMFONY2 » Page 1
incorrect asset url for sonata admin assets
Here's how I solved it: # app/config.yml sonata_admin: ... templates: layout: SonataAdminBundle::standard_layout_override.html.twig since twig's asset() does not generate same URL as assetic stylesheets & javascripts block, I created a file that overrides stylesheets & javascripts block: # app/Resources/SonataAdminBundle/views/standard_layout_override.html.twig {% extends 'SonataA

Categories : Symfony2

doctrine query onetonmany / notIn with objects / symfony forms querybuilder
I got thinks thanks to Javad: (slight modification, I'm using an array result, not dql): $qb = $this->_em->createQueryBuilder(); $ids = $qb ->select('p.id') ->from('AppBundle:MarketPlaceProduct','p','p.id') ->leftJoin('p.userIngredients', 'i') ->where('i.user = ?1') ->setParameter(1,$user) ->getQuery() ->getResult(); //I don't know why I co

Categories : Symfony2

Symfony2: Use different form types in a collection based on sent data
This bundle should solve your problem: https://github.com/infinite-networks/InfiniteFormBundle#polycollection

Categories : Symfony2

Twig loop and skip in loop
Try: {% for product in products %} {% if product.title != 'lookbook' %} <div class="product> <h3>{{ product.fulltitle }}</h3> <a href="{{ product.url | url }}" title="{{ product.fulltitle }}"> <img src="{{ product.image | url_image('220x220x2', product.fulltitle) }}" /> </a> </div>

Categories : Symfony2

Fatal error: Uncaught exception 'ReflectionException' with message 'Class ClCommonBundleEntityinteger does not exist
I had the same question and resolved it. Because My Entity's setting. You can't type hint on a scalar type (integer/string/boolean etc) in PHP. e.g. public function setSortOrder(integer $sortOrder) Should be: public function setSortOrder($sortOrder)

Categories : Symfony2

Symfony2 pass prototype parameter to container on load
In your Extension class you have to declare your scroller service definitions manually: use SymfonyDependencyInjectionDependencyInjectionDefinitionDecorator; // ... public function load(array $configs, ContainerBuilder $container) { // ... $scrollers = $config['scrollers']; foreach ($scrollers as $name => $scroller) { // Inherit the definition of "sifast_symash.scrolle

Categories : Symfony2

How to reduce size of /vendor directory in a Silex project
Unfortunately, there is not really a way to optimize included libraries for distribution. The only optimization I would suggest is to separate your development dependencies. Assuming you're using symfony/browser-kit and symfony/css-selector for testing, you could put those into the require-dev section in your composer.json. { "require": { "doctrine/dbal": ">=2.2.0,<2.4.0-dev",

Categories : Symfony2

Symfony : What is the meaning of auto_mapping and auto_generate_proxy_classes
auto_mapping is where doctrine will automatically load the mapping from your bundle Resources/config/doctrine directory. Setting it to false will mean that you will need to load the mappings yourself. It can be handy if you have mappings for entities rather than mapped superclasses in a vendor bundle that you want to over ride. You can do this either by way of stating the mappings in the doctrin

Categories : Symfony2

LiipImageBundle & KNP Gaufrette bundle failing to resolve s3 image path?
After going through all the code of LiipImaginBundle & debugging, it turned out to be content type issue which was caused by FOSRestBundle's format_listener: rules: - { path: '^/', priorities: [ '*/*' ], fallback_format: html, prefer_extension: true } Changing it to format_listener: rules: - { path: '^/', priorities: [ 'html', '*/*' ], fallback_format: html, prefer

Categories : Symfony2

custom formtype wraps ArrayCollection in ArrayCollection
Not sure but could it be because you're both extending the entity type and defining it as parent? Try replacing the extends EntityType with extends AbstractType...

Categories : Symfony2

Symfony 2 : validate console comand arguments
Unfortunately, currently there's no way to implement command argument validation in Symfony. The best way to implement these checks would be overriding SymfonyComponentConsoleCommand::initialize method in your command and then applying the validation rules there, throwing exceptions if passed arguments are invalid. Update: Matthias Noback has implemented symfony-console-form (https://github.com/m

Categories : Symfony2

Symfony2: looking for mechanism similar to bundle inheritance
You can create a separate bundle that will inerhit from calendar-bundle one and use the features of "brand new bundle" inside the "old one". To do that I recommend you to define services and use them: it's very trivial. For what it's worth I suppose that symfony2 use "single" inheritance only because, generally, a bundle is strictly related to some functionalities that could be grouped togheter.

Categories : Symfony2

Symfony2 Doctrine custom types generating unneeded migrations
Here is a response from Steve Müller from this bug report : http://www.doctrine-project.org/jira/browse/DBAL-1085 I think you will have to mark your custom type as requiring a SQL comment, otherwise the schema manager cannot distinguish between DateTime type and your custom type because both map to the same native SQL type. See here: https://github.com/doctrine/dbal/blob/master/l

Categories : Symfony2

Get a routing parameter in Twig template (which is not in query)?
I discovered that all parameters defined directly within defaults table (in routing) are filling the attributes part of the ParameterBag, so you can access them like this in Twig templates : {{ app.request.attributes.get('my_parameter') }} my_parameter would be replace by section for the example I gave.

Categories : Symfony2

isvalid() function in symfony always give false
Your action class is not saving the form if it's valid. You should save and redirect if the form is valid: if ($this->registration_form->isValid()) { $this->registration_form->save(); $this->redirect('registration/thankyou'); } If you need the form value on the next page, don't pass them in url, but flash instead: $this->getUser()->setFlash('registration_form', $this

Categories : Symfony2

Adding extra field in many_to_many symfony2 relationship
Here are the similar questions: Doctrine2: Best way to handle many-to-many with extra columns in reference table Doctrine 2 and Many-to-many link table with an extra field TL;DR: Unfortunately, relationships can't have any extra fields. You need to create one more entity, which would have two relations (with Skill and Training entities) and property for target level.

Categories : Symfony2

Use current user id - symfony 2
I would suggest against the hidden field as it could be easily manipulated. The better way would be to inject SecurityContext into your form and bind the logged in user to that object via POST_SUBMIT event.

Categories : Symfony2

composer set a git repository as type component
I would suggest to use bower for fetching frontend libraries. Composer was created for managing php libs dependencies. It is importand to separate this layers because it's the easiest solution to implement.

Categories : Symfony2

Symfony include static html in template
Try this: {{ include('FashionMediaBundle:Resources:static:pricing.html') }} If you want to put this file in another directory I suggest you to use a symbolic link (I don't know if Twig can include a file which is not in the Resources directory).

Categories : Symfony2

Backbone does not load
Turns out that the app was using a router. Hopefully this helps someone in having the same problem in the future. The code for it looks like this: define([ 'jquery', 'underscore', 'backbone', 'vm' ], function ($, _, Backbone, Vm) { var AppRouter = Backbone.Router.extend({ instance: null }); var initialize = function ( options ) { var appView = opti

Categories : Symfony2

Symfony, FosUserBundle with console and GEDMO - Blameable
You have to disable Blameable filter. <?php // This will disable filter (adapt the filter name with your configuration) $em->getFilters()->disable('blameable'); /* Your code with entity manager flush */ // This will enable filter $em->getFilters()->enable('blameable');

Categories : Symfony2

How to Configure a Redirect without a custom Controller
Maybe you should create kernel.listener.accessDenied? Using Symfony2's AccessDeniedHandlerInterface

Categories : Symfony2

Not able to get children of children using StofDoctrineExtension Tree
You are resetting the nodes variable on each foreach. To get all nodes you could create an array and add all subsequent nodes onto the end of that. $pages = $this->getDoctrine()->getRepository('BloggerBlogBundle:Page'); $nodes = $pages->getChildren(); $parent = $nodes[0]; //get Parent node $children = $parent->getChildren(); // get Children of Parent Nodes $subChildren = array();

Categories : Symfony2

symfony2 saving and retrieving datetime field
Add a type to your field in your form builder : class ProductType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('createdAt', 'datetime'); } /** * @param OptionsResolverInterface $resolver */ public func

Categories : Symfony2

How to install DoctrineExtensions in Symfony 2.5 and latest
From your error: A YAML file cannot contain tabs as indentation at line 106 (near " dql:") You have tabs in this file: doctrine: orm: auto_generate_proxy_classes: %kernel.debug% entity_managers: default: auto_mapping: true dql: datetime_functions: MONTH: DoctrineExtensionsQueryMysqlMonth YEAR: DoctrineExtension

Categories : Symfony2

How to filter the instances of an entity that a user can see in Sonata Admin
You can customize the query used to generate the list in your VehicleAdmin class: http://sonata-project.org/bundles/admin/master/doc/reference/action_list.html#customizing-the-query-used-to-generate-the-list

Categories : Symfony2

Twig dump isn't printing anything
In Symfony 2.6, there is a new VarDumper component and DebugBundle. These override twig's dump() function to give a lot more and nicer dump output. However, you have to register the DebugBundle in your AppKernel, otherwise it'll just ignore the call. To do this, you should add this to app/AppKernel.php: // app/AppKernel.php // ... public function registerBundles() { // ... if (in_array

Categories : Symfony2

Doctrine 2 Native Query select from joined entity
Well, well, well...it looks like you have to add rc.id AS ref_country_id, in query and $rsm->addFieldResult('rc','ref_country_id','id'); like this: $rsm = new DoctrineORMQueryResultSetMapping(); $rsm->addEntityResult('EntityCrmBusinessPartner', 'bp'); $rsm->addFieldResult('bp','id','id'); $rsm->addFieldResult('bp','vat','vat'); $rsm->addFieldResult('bp','business_partner_name','n

Categories : Symfony2

Symfony2 refactoring issues, services, configuration, container?
I solved the issue this way, I'd appreciate if someone can tell me about the correctness of the code. I still need to meditate on what I did :P Controller: public function indexAction() { $weather = $this->get('_weather_service'); return $this->render('WeaTherBundle:Weather:index.html.twig', array( 'weather' => $weather->getWeather() )); } servi

Categories : Symfony2

Symfony2 assetic javascript Files have different names in markup vs. on disk
This looks like a bug. One of my JS files began with an uppercase letter, and the files were being sorted differently when being written to HTML than when being written to disk. I just filed the following bug report. Hope this helps someone: Environment: CentOS release 6.5 (Final) Symfony 2.5 PHP 5.3.3 When referencing a whole directory of assets, eg. Resources/public/js/Default: Ascript.

Categories : Symfony2

Get twig variable from a specific route
You are way better of with render controller call: <html><body> {% block menu %} {% endblock menu %} {% block columnleft %} {% render(controller('TestBundle:Default:topItems')) %} {% endblock columnleft %} {% block body %} {% endblock body %} </body></html> and then create the controller: /** * @Template() */ public function topItems(){ // SOME LOGIC

Categories : Symfony2

can't load page in development environment Symfony2
This is an infinite loop: while ($check == false){ // $check is never true foreach($teamArr as $oneteam){ if(empty($oneteam->getUserUserid())){ $team = $oneteam; break; // This only breaks the foreach loop } } } To prevent it from executing infinitely, you must manipulate $check to

Categories : Symfony2

How to properly configure 'sonata_type_collection' field in Sonata Admin
You might want to set the by_reference option to false. protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('title') ->add('content') ->add('tags', 'sonata_type_collection', array('by_reference' => false), array('edit' => 'inline',

Categories : Symfony2

From Array to Doctrine/ArrayCollection: entity id (date) issue
It seems the only solution is to create a brand new doctrine type (what I called "dirty solution" here) because UnitOfWork need string or integer to work properly. Source: Doctrine 2 ORM DateTime field in identifier

Categories : Symfony2

Symfony2 doctrine association mapping error handling
Yeah it fails because an entry or number of entries in your schema violates your foreign key constraint. This has nothing to do with your mapping or doctrine ORM. This is an sql returned error and no you can't force it to skip any failed entries because doctrine is just an abstraction layer for your database. In any case, this is the whole point of foreign keys, to preserve data integrity. Sorry

Categories : Symfony2

Doctrine EntityRepository for extended Entity
Thinking about this, the entity manager is missing and that is why it cannot find the repository. In your controller/service, use: $em = $em= $this->getDoctrine()->getManager(); $clients = $em->getRepository('AcmeAppBundle:Client')->getClientsWithActiveCampaign(); The $clients variable should be populated now, or at least you will get a different error. The getClientsWithActiveCam

Categories : Symfony2

Symfony2 - Custom ROLES
Your regular expression seems to be the problem, ^/$ matches only one / and nothing else. This is what you mean I guess: access_control: - { path: ^/.*, role: ROLE_USER } Also your role hierarchy can be simplified: role_hierarchy: ROLE_USER: [ROLE_GUEST] # ROLE_USER implies ROLE_GUEST ROLE_ADMIN: [ROLE_USER] # ROLE_ADMIN implies ROLE_USER ROLE_SUPER_ADMIN: [ROLE_AD

Categories : Symfony2

How to display a photo in Sonata Admin Bundle
I found, we must create a new template especially for the photo. ===> How to get images listed in sonata admin bundle backend

Categories : Symfony2

JMSSerializer how to change handler for specific type one time
On your one time entry, you could do the following /** * @Type("DateTime<'Y-m-d'>") */ private $updatedAt; http://jmsyst.com/libs/serializer/master/reference/annotations#type

Categories : Symfony2




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.