Symfony, Fos User Bundle, link to auth/login - symfony

Maybe it's very silly question but how i can make link to my main page, login site (auth/login) from for example '/auth/resetting/check-email'. Im using Fos User Bundle.

Inside these files you will find every public route that is being used.
You can then use those route names to create the url.
Since this is an official repository these files are also present in your project.

Related

Is there a way to move Symfony 6's controllers to several other directories?

I'm starting to develop a project that will be quite big (hear lots of files) and I want to have an organization that's different from Symfony's default one: instead of having one dir for all my controllers, another for all my forms, etc, I want to have one dir per functionality, ie a directory for my homepage which will contain the controller, the templates, another dir for the blog page with the controller, forms and templates, and so on.
I tried what was explained in this (old) answer, and it didn't work : my routes weren't recognized, and a php bin/console debug:router showed they weren't listed anymore.
I feel I will have something to adapt in my routes.yaml file, which looks like this for now, and which explains why it doesn't work because it explicitely searches in the src\Controller directory:
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
I looked in the documentation I found, but I didn't find anything useful (I think I will have to remove the path and change it to something else, but I don't know what yet.
The above solutions are only for differentiating controller and template files. But For Entity, Events, and Forms it will not work.
It seems like you want to separate files for each module or functionality. For example, settings.yaml, controller, entity, forms, events, etc...
For that Symfony provides a Bundle feature. You can create a new Bundle in Symfony and use it as a separate feature. For more details please read this link

Is there a way to access Doctrine repositories from stand-alone code?

I have a Symfony 4 app which is complete and working. Any uploaded files are put inside an upload folder outside the doc root and accessed via a separate cdn url.
Inside the upload folder I have a htaccess file that redirects any request, let’s say for example an image, to a php file which then serves the image.
What I want to be able to do is send an auth key along with the image request so that the standalone index.php file can check the user is valid from the database.
This means I need some way of accessing the symfony entity manager from outside of symfony, by including it. The other option would be a curl request to a symfony controller, but I’d rather not add additional network requests if possible. The third option is a separate pdo direct to the database and make sql queries... but again I’d prefer to use the symfony entity manager by including symfony somehow so I can use other features if needed.
I actually tried including the symfony bootstrap in the index.php but that then drags in the need for routing to work which isn’t needed in this case.
You can access EntityManager like that:
require __DIR__.'/../vendor/autoload.php';
(new Dotenv())->load(__DIR__.'/../.env');
$kernel = new Kernel('dev', true);
$kernel->boot();
$user = $kernel->getContainer()->get('doctrine.orm.entity_manager')->getRepository(Repo::class)->find(id);
dd($user->getRoles());

Showing configuration options depending on users access to bundle

I am creating an app that will be extended by several bundles. Users will have access to different bundles based on roles. Some of these bundles will have configuration options, and I want one page with all config forms.
What I want to do is create a page that every bundle will "hook" into, and show the configuration form if the bundle has one.
There will also be a dashboard page that each bundle should "hook" into and show a dashboard widget.
Is there any way of achieving this in symfony? And if so, how?
I finally understood the The DependencyInjection Component so I guess the answer lies there. In detail, I will try to create an event in the configuration controller, and all bundles will have a subscriber to this event, and somehow have the forms available for the configuration twig file. But that is another question.

Getting user home folder through alfresco rest api

Using Alfresco web scripts I can login and get ticket but I can't find any script to get user home folder. I can get folders inside another folder using below script: GET /alfresco/service/slingshot/doclib/doclist/{type}/node/{store_type}/{store_id}/{id} But after login I don't know the user home id. Does anybody know how to do it?
The userhome onces authenticated is considered to be a root object if you are dealing with classic webscripts.
https://wiki.alfresco.com/wiki/5.0_JavaScript_API#Root_Scope_Objects
You can access it via
var name = userhome.properties.name
Or you can use any of the other properties you may need via the Scripting Node API.
If you are looking for a webscript itself that just returns back the userhome you may need to create your own webscript to access just their User Home information. This can be done quickly and I recommend following this tutorial to learn how to quickly create one that fits what you are looking to do
http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html

MVC3 - add a folder to controllers?

I want to learn is it possible to add additional folder to Controller folder. My reason is pretty simple: I want to divide my project administration and client sides.
Example: I have a controller named Post that has actions Index, Details, Delete, Create, Edit. I want to make one controller as user controller that will consist of Index, Details and another controller as admin controller that will consist of Delte, Create, Edit. Then I will be able to easy distinguish what is what and put admin validation on whole admin class.
Another reason is that I want my url for administrating my site to look like /admin/post/delete, not /post/delete.
So is it possible, and if so then what would be the best way to implement this?
Sound like you want to use MVC Areas? http://www.c-sharpcorner.com/UploadFile/b19d5a/areas-in-Asp-Net-mvc3/
It's just a convention on placing controllers in Controllers folder.
Actually MVC finds controller in current loaded assemblies.
You can place them even in other assemblies.
So, fell free to create additional folders inside Controllers
If you are using Ruby on Rails, yes, you can. In your routes files, config/routes.rb, add this:
map.namespace :admin do |admin|
admin.resources :posts
end
Go to your terminal and navigate to your project, run rake routes. Now you get your posts controller under admin namespace... and your url will be:
.../admin/posts

Resources