These are chat archives for PHPixie/Hotline

11th
Sep 2017
Anton Kolenkov
@dorantor
Sep 11 00:40

@dracony is it possible with current routing system to define route this way

// bundles/api/assets/config/routeResolver.php
        'endpoint1'  => array(
            'path'      => '<apiVersion>/<uuid>/<processor>',
            'attributePatterns' => array(
                'uuid'    => '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}',
            ),
        ),

and map it to something like this?
bundles/api/src/HTTP/v1/Task.php
but don't understand what should be in bundles/api/src/HTTP.php
Only thing I can think of is that I need some kind of wrapper, that will do version mapping with

// bundles/api/src/HTTP.php
    protected $classMap = array(
        'task' => 'Project\Api\HTTP\Task',
        'task1' => 'Project\Api\HTTP\v1\Task',
        'task2' => 'Project\Api\HTTP\v2\Task',
    );

But this way it's becoming too verbose and cumbersome.

Roman Tsiupa
@dracony
Sep 11 00:56
You dont really need to do it like that
just route this pattern to a particular controller
e.g. UUIDProcessor
and just write a process() function there that would route uuid to the proper place
Roman Tsiupa
@dracony
Sep 11 01:01
class UUIDProcessor implements \PHPixie\Processors\Processor {
      public function process($request) {
                  // call any class you like here

      }
}
Anton Kolenkov
@dorantor
Sep 11 07:16
The key issue here is versions.
Different versions should map to different processors.
sobolevna
@sobolevna
Sep 11 10:10
@dorantor There is no problem -- just update method \Project\Api\HTTP::getProcessorNameFor() so that it would catch your version and redirect the process to your particular processor
Anton Kolenkov
@dorantor
Sep 11 14:21
aha! thx @sobolevna
last question - what is the proper way to build\prepare processor?
sobolevna
@sobolevna
Sep 11 14:26
@dorantor What do you mean?
Anton Kolenkov
@dorantor
Sep 11 14:30
wait, misunderstood your advice
I don't need it
as soon as I will prepare correct name, phpixie will do everything for me