I read through the Zend Controller doco and it says that it can do routing as follows:
example.com/controller/action
But in Pimcore this seems to be disabled. I have to define static routes.
I don't mind defining the routes, but the thing is my regular expressions aren't very good.
Can someone explain to me if it is possible to enable the normal zend controller style routing as above and stop having to make use of the pimcore's built in static routes?
Thanks
It's not possible to enable the normal zend controller style routing, without breaking pimcore. There are 2 possibilities:
use example.org/?controller=controllername&action=actionname for direct access to a controller-action (as described in the Pimcore Documentation - Magic Parameters)
use the built in static routes. For example:
pattern: |/news/list|, controller: news, action: list
have a look at pimcore plugins for that. /pugin/name/controller/action/ ...
Related
I'm using a Service of type auth for adding an API based login.
I tried to add a User with the FrontendUserRepository of Extbase via #inject.
But this doesn't work.
Am i doing something wrong or is this to early to use the Dependency Injection?
P.S.: I know i can use the repository the following way:
$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$this->frontendUserRepository = $objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
DI with the #Inject annotation works only for objects loaded by a TYPO3\CMS\Extbase\Object\ObjectManager instance. The auth services are beeing instantiated using GeneralUtility::makeInstanceService() which in turn uses GeneralUtility::makeInstance() (see TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::checkAuthentication()), so the #Inject annotation has no effect.
You must use the workaround mentioned already by yourself.
[typo3 7.6]
I think in the auth service all the extbase stuff in not proper loaded. I have lots of errors while trying to use extbase repos in a auth service (which are running great in context of controller). I found one link about a possible init of the missing parts: Extbase innerhalb eines TYPO3 Authentication Services verwenden
The question may sound funny but I think this should be possible.
What I want is to use a repository that is purely custom but is exposed just like a Repository. This service would have methods to get, save, delete and list objects where the data could be from any arbitrary source.
Looking through the code, I think it should be possible since methods are accessed using CrudMethods and RepositoryInvoker. I belief this requires an implementation of RepositoryFactoryInformation that will be discovered by Repositories. I started experimenting a bit and it looks like a full-blown spring-data-noop module.
Am I on the right track or is there an easier way to accomplish this?
I've ended up writing spring-data-custom to create fully customized spring-data repositories, allowing custom code to be used with spring-data-rest etc.
Enable custom repositories (#EnableCustomRepositories)
Annotate eligible entities (#Custom)
Create a repository (extend CustomRepository<T, ID>)
Add custom behavior:
Let repository extend a new interface with the Custom suffix
Create an implementation of the new interface with the Impl prefix
Add one or more CRUD methods named findOne, save, findAll, delete (see DefaultCrudMethods)
Add query methods annotated with #Query
Export repository using spring-data-rest
(copied from README)
As #wwadge correctly mentioned, spring-data-keyvalue is an alternative. Repositories have to implement KeyValueAdapter, e.g. MapKeyValueAdapter.
The easier way is to use spring-data-keyvalue project which does what you are trying to do.
I'm using ASP.Net MVC 4 RTM Web API. I have a controller action with a parameter that I'd like to populate via custom model binding. To achieve this, I created a class that derives from System.Web.Http.Controllers.HttpParameterBinding that sets the value of this parameter. I then created an attribute class that derives from System.Web.Http.ParameterBindingAttribute which I use to decorate the parameter on my controller action.
This is all working great, my HttpParameterBinding class is populating the action parameter correctly. The problem I have is that my custom parameter binding class has a dependency that I'd like resolved via my IoC container (Unity). Is there a way to override how Web API creates HttpParameterBinding instances so that I can build up my custom binding class dependency from Unity? I was able to do something similar for a filter attribute by creating a custom filter provider that uses Unity's BuildUp method to populate dependencies, however I'm not seeing anything similar for Web API's HttpParameterBindings.
In general: to use IoC / Unity in the Web API you need to set it up seperately.
Try downloading the nuget package Unity.WebApi and see if that helps!
Take a look at this article: Parameter Binding in WebAPI
It walks through a couple different options from Converters to Binders to BinderProviders. It sounds like you may be able to write a custom ModelBinderProvider which knows how to provide your dependency. If that isn't high enough in the chain you can look at replacing the default IActionValueBinder service. It's a DefaultActionValueBinder instance, which you can extend or simply re-implement.
I also highly recommend downloading the WebAPI source code, as it's been an incredible help for these issues as I've run into them. Here's the WebAPI source code. I recommend downloading it so you can open it in VS for easy navigation.
Feel free to check out FlitBit too (It's very modular, don't let the number of packages scare you off)! I'm working on a WebAPI package for supporting FlitBit, specifically FlitBit.IoC and FlitBit.Dto. I'll add an update if I work out my IoC issue, since it's very similar to yours.
I'm developing a multilanguage application, and use routes with translated segments. For multilingual support I created special Multilingual plugin.
To use translated segments I need set translator for Zend_Controller_Router_Route before routes init. So only possible place for this in my plugin is routeStartup method, but there is one problem here - for determine right locale I need to use properties of request (Zend_Controller_Request_Abstract), like module, controller and action names, but they are not defined yet here in routeStartup method. They are already defined, for example, in routeShutdown - but I can't set translator for route there, because it have to be done before routes init.
So what can I do:
can I get request properties somehow in routeStartup
or can I re-setup translator later in routeShutdown
P.S: there is a question with exactly the same problem Zend_Controller_Router_Route: Could not find a translator, but proposed answers is not the option for me, because I can't just retrieve language code from url with Regex, I have much more complicated code to define right language code.
Thanks.
What about putting your code in preDispatch? That's what I personally do when I need to check if the person is logged in. Maybe you can move your code there too?
Kindly explain the following regarding Zend Framework and how do I know which one to use, and when and where to use them.
resources.layout.pluginClass
resources.frontcontroller.plugins
The first is described on this page and allows you to provide a specific layout controller plugin class to override the default
pluginClass: the front controller plugin class to use when using Zend_Layout with the MVC components. By default, this is Zend_Layout_Controller_Plugin_Layout
The second, described here allows you to register any number of generic controller plugins
plugins: array of front controller plugin class names. The resource will instantiate each class (with no constructor arguments) and then register the instance with the front controller. If you want to register a plugin with a particular stack index, you need to provide an array with two keys class and stackIndex.