I'm not sure what kind of pattern you're trying to acheive...
This is fine, creates a global service by the name of ImgStorage:
$di->set('ImgStorage',
[
'className' => 'Gallery\Classes\AmazonS3'
]
);
You can acces it like this:
// controller context
$this->ImgStorage->someMethodOfAmazonS3();
This will be your cuplrit, you shouldn't create a controller class as a service. Even though it will be instantiated, that instance will be a different from what the Phalcon dispatcher will create.
$di->set('AbstractController',
[
'className' => 'AbstractController',
'calls' => [
[
'method' => 'setStorage',
'arguments' => [
[
'type' => 'service',
'name' => 'ImgStorage'
]
]
]
]
]
);
For this functionality (as i understand), you don't have to subclass an abstract controller, you can access the ImgStorage service from any controller:
// AbstractController.php:
abstract class AbstractController extends Controller {
// ???
}
// IndexController.php:
class IndexController extends AbstractController {
public function indexAction() {
$this->ImgStorage->someMethodOfAmazonS3();
}
}